Function addTest [src]

Creates an executable containing unit tests. Equivalent to running the command zig test --test-no-exec .... This step does not run the unit tests. Typically, the result of this function will be passed to addRunArtifact, creating a Step.Run. These two steps are separated because they are independently configured and cached.

Prototype

pub fn addTest(b: *Build, options: TestOptions) *Step.Compile

Parameters

b: *Buildoptions: TestOptions

Source

pub fn addTest(b: *Build, options: TestOptions) *Step.Compile { if (options.root_module != null and options.root_source_file != null) { @panic("`root_module` and `root_source_file` cannot both be populated"); } return .create(b, .{ .name = options.name, .kind = .@"test", .root_module = options.root_module orelse b.createModule(.{ .root_source_file = options.root_source_file orelse @panic("`root_module` and `root_source_file` cannot both be null"), .target = options.target orelse b.graph.host, .optimize = options.optimize, .link_libc = options.link_libc, .link_libcpp = options.link_libcpp, .single_threaded = options.single_threaded, .pic = options.pic, .strip = options.strip, .unwind_tables = options.unwind_tables, .omit_frame_pointer = options.omit_frame_pointer, .sanitize_thread = options.sanitize_thread, .error_tracing = options.error_tracing, }), .max_rss = options.max_rss, .filters = if (options.filter != null and options.filters.len > 0) filters: { const filters = b.allocator.alloc([]const u8, 1 + options.filters.len) catch @panic("OOM"); filters[0] = b.dupe(options.filter.?); for (filters[1..], options.filters) |*dest, source| dest.* = b.dupe(source); break :filters filters; } else b.dupeStrings(if (options.filter) |filter| &.{filter} else options.filters), .test_runner = options.test_runner, .use_llvm = options.use_llvm, .use_lld = options.use_lld, .zig_lib_dir = options.zig_lib_dir, }); }