authorgravatar for goon.pri.low@gmail.comKendall Condon <goon.pri.low@gmail.com> 2026-02-13 17:50:30-05:00
committergravatar for goon.pri.low@gmail.comKendall Condon <goon.pri.low@gmail.com> 2026-02-13 17:58:09-05:00
log5b9bb0a4045aaae387b049f4b28f350aef0dbed2
tree3750dce14ec2fe042225d9776e05b5267ae27656
parente40557b1f75863d9a66af301e83c8c48f0df81d5

add -Dfuzz-only

Runs only one configuration suitable for fuzzing.

2 files changed, 29 insertions(+), 10 deletions(-)

build.zig+12-4
......@@ -85,6 +85,7 @@ pub fn build(b: *std.Build) !void {
8585 docs_step.dependOn(std_docs_step);
8686
8787 const no_matrix = b.option(bool, "no-matrix", "Limit test matrix to exactly one target configuration") orelse false;
88 const fuzz_only = b.option(bool, "fuzz-only", "Limit test matrix to one target suitable for fuzzing") orelse false;
8889 const skip_debug = b.option(bool, "skip-debug", "Main test suite skips debug builds") orelse false;
8990 const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse no_matrix;
9091 const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;
......@@ -417,6 +418,13 @@ pub fn build(b: *std.Build) !void {
417418 }
418419 const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];
419420
421 const test_only: ?tests.ModuleTestOptions.TestOnly = if (no_matrix)
422 .default
423 else if (fuzz_only)
424 .{ .fuzz = optimize }
425 else
426 null;
427
420428 const fmt_include_paths = &.{ "lib", "src", "test", "tools", "build.zig", "build.zig.zon" };
421429 const fmt_exclude_paths = &.{ "test/cases", "test/behavior/zon" };
422430 const do_fmt = b.addFmt(.{
......@@ -472,7 +480,7 @@ pub fn build(b: *std.Build) !void {
472480 .include_paths = &.{},
473481 .skip_single_threaded = skip_single_threaded,
474482 .skip_non_native = skip_non_native,
475 .test_default_only = no_matrix,
483 .test_only = test_only,
476484 .skip_spirv = skip_spirv,
477485 .skip_wasm = skip_wasm,
478486 .skip_freebsd = skip_freebsd,
......@@ -497,7 +505,7 @@ pub fn build(b: *std.Build) !void {
497505 .include_paths = &.{},
498506 .skip_single_threaded = true,
499507 .skip_non_native = skip_non_native,
500 .test_default_only = no_matrix,
508 .test_only = test_only,
501509 .skip_spirv = skip_spirv,
502510 .skip_wasm = skip_wasm,
503511 .skip_freebsd = skip_freebsd,
......@@ -523,7 +531,7 @@ pub fn build(b: *std.Build) !void {
523531 .include_paths = &.{},
524532 .skip_single_threaded = true,
525533 .skip_non_native = skip_non_native,
526 .test_default_only = no_matrix,
534 .test_only = test_only,
527535 .skip_spirv = skip_spirv,
528536 .skip_wasm = skip_wasm,
529537 .skip_freebsd = skip_freebsd,
......@@ -549,7 +557,7 @@ pub fn build(b: *std.Build) !void {
549557 .include_paths = &.{},
550558 .skip_single_threaded = skip_single_threaded,
551559 .skip_non_native = skip_non_native,
552 .test_default_only = no_matrix,
560 .test_only = test_only,
553561 .skip_spirv = skip_spirv,
554562 .skip_wasm = skip_wasm,
555563 .skip_freebsd = skip_freebsd,
test/tests.zig+17-6
......@@ -2310,7 +2310,7 @@ pub fn addCliTests(b: *std.Build) *Step {
23102310 return step;
23112311}
23122312
2313const ModuleTestOptions = struct {
2313pub const ModuleTestOptions = struct {
23142314 test_filters: []const []const u8,
23152315 test_target_filters: []const []const u8,
23162316 test_extra_targets: bool,
......@@ -2319,7 +2319,7 @@ const ModuleTestOptions = struct {
23192319 desc: []const u8,
23202320 optimize_modes: []const OptimizeMode,
23212321 include_paths: []const []const u8,
2322 test_default_only: bool,
2322 test_only: ?TestOnly,
23232323 skip_single_threaded: bool,
23242324 skip_non_native: bool,
23252325 skip_spirv: bool,
......@@ -2335,20 +2335,31 @@ const ModuleTestOptions = struct {
23352335 max_rss: usize = 0,
23362336 no_builtin: bool = false,
23372337 build_options: ?*Step.Options = null,
2338
2339 pub const TestOnly = union(enum) {
2340 default: void,
2341 fuzz: OptimizeMode,
2342 };
23382343};
23392344
23402345pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
23412346 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
23422347
2343 if (options.test_default_only) {
2344 const test_target = &test_targets[0];
2348 if (options.test_only) |test_only| {
2349 const test_target: TestTarget = switch (test_only) {
2350 .default => test_targets[0],
2351 .fuzz => |optimize| .{
2352 .optimize_mode = optimize,
2353 .use_llvm = true,
2354 },
2355 };
23452356 const resolved_target = b.resolveTargetQuery(test_target.target);
23462357 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
23472358 addOneModuleTest(b, step, test_target, &resolved_target, triple_txt, options);
23482359 return step;
23492360 }
23502361
2351 for_targets: for (&test_targets) |*test_target| {
2362 for_targets: for (test_targets) |test_target| {
23522363 if (test_target.skip_modules.len > 0) {
23532364 for (test_target.skip_modules) |skip_mod| {
23542365 if (std.mem.eql(u8, options.name, skip_mod)) continue :for_targets;
......@@ -2425,7 +2436,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
24252436fn addOneModuleTest(
24262437 b: *std.Build,
24272438 step: *Step,
2428 test_target: *const TestTarget,
2439 test_target: TestTarget,
24292440 resolved_target: *const std.Build.ResolvedTarget,
24302441 triple_txt: []const u8,
24312442 options: ModuleTestOptions,