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 {...@@ -85,6 +85,7 @@ pub fn build(b: *std.Build) !void {
85 docs_step.dependOn(std_docs_step);85 docs_step.dependOn(std_docs_step);
8686
87 const no_matrix = b.option(bool, "no-matrix", "Limit test matrix to exactly one target configuration") orelse false;87 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;
88 const skip_debug = b.option(bool, "skip-debug", "Main test suite skips debug builds") orelse false;89 const skip_debug = b.option(bool, "skip-debug", "Main test suite skips debug builds") orelse false;
89 const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse no_matrix;90 const skip_release = b.option(bool, "skip-release", "Main test suite skips release builds") orelse no_matrix;
90 const skip_release_small = b.option(bool, "skip-release-small", "Main test suite skips release-small builds") orelse skip_release;91 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 {...@@ -417,6 +418,13 @@ pub fn build(b: *std.Build) !void {
417 }418 }
418 const optimization_modes = chosen_opt_modes_buf[0..chosen_mode_index];419 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
420 const fmt_include_paths = &.{ "lib", "src", "test", "tools", "build.zig", "build.zig.zon" };428 const fmt_include_paths = &.{ "lib", "src", "test", "tools", "build.zig", "build.zig.zon" };
421 const fmt_exclude_paths = &.{ "test/cases", "test/behavior/zon" };429 const fmt_exclude_paths = &.{ "test/cases", "test/behavior/zon" };
422 const do_fmt = b.addFmt(.{430 const do_fmt = b.addFmt(.{
...@@ -472,7 +480,7 @@ pub fn build(b: *std.Build) !void {...@@ -472,7 +480,7 @@ pub fn build(b: *std.Build) !void {
472 .include_paths = &.{},480 .include_paths = &.{},
473 .skip_single_threaded = skip_single_threaded,481 .skip_single_threaded = skip_single_threaded,
474 .skip_non_native = skip_non_native,482 .skip_non_native = skip_non_native,
475 .test_default_only = no_matrix,483 .test_only = test_only,
476 .skip_spirv = skip_spirv,484 .skip_spirv = skip_spirv,
477 .skip_wasm = skip_wasm,485 .skip_wasm = skip_wasm,
478 .skip_freebsd = skip_freebsd,486 .skip_freebsd = skip_freebsd,
...@@ -497,7 +505,7 @@ pub fn build(b: *std.Build) !void {...@@ -497,7 +505,7 @@ pub fn build(b: *std.Build) !void {
497 .include_paths = &.{},505 .include_paths = &.{},
498 .skip_single_threaded = true,506 .skip_single_threaded = true,
499 .skip_non_native = skip_non_native,507 .skip_non_native = skip_non_native,
500 .test_default_only = no_matrix,508 .test_only = test_only,
501 .skip_spirv = skip_spirv,509 .skip_spirv = skip_spirv,
502 .skip_wasm = skip_wasm,510 .skip_wasm = skip_wasm,
503 .skip_freebsd = skip_freebsd,511 .skip_freebsd = skip_freebsd,
...@@ -523,7 +531,7 @@ pub fn build(b: *std.Build) !void {...@@ -523,7 +531,7 @@ pub fn build(b: *std.Build) !void {
523 .include_paths = &.{},531 .include_paths = &.{},
524 .skip_single_threaded = true,532 .skip_single_threaded = true,
525 .skip_non_native = skip_non_native,533 .skip_non_native = skip_non_native,
526 .test_default_only = no_matrix,534 .test_only = test_only,
527 .skip_spirv = skip_spirv,535 .skip_spirv = skip_spirv,
528 .skip_wasm = skip_wasm,536 .skip_wasm = skip_wasm,
529 .skip_freebsd = skip_freebsd,537 .skip_freebsd = skip_freebsd,
...@@ -549,7 +557,7 @@ pub fn build(b: *std.Build) !void {...@@ -549,7 +557,7 @@ pub fn build(b: *std.Build) !void {
549 .include_paths = &.{},557 .include_paths = &.{},
550 .skip_single_threaded = skip_single_threaded,558 .skip_single_threaded = skip_single_threaded,
551 .skip_non_native = skip_non_native,559 .skip_non_native = skip_non_native,
552 .test_default_only = no_matrix,560 .test_only = test_only,
553 .skip_spirv = skip_spirv,561 .skip_spirv = skip_spirv,
554 .skip_wasm = skip_wasm,562 .skip_wasm = skip_wasm,
555 .skip_freebsd = skip_freebsd,563 .skip_freebsd = skip_freebsd,
test/tests.zig+17-6
...@@ -2310,7 +2310,7 @@ pub fn addCliTests(b: *std.Build) *Step {...@@ -2310,7 +2310,7 @@ pub fn addCliTests(b: *std.Build) *Step {
2310 return step;2310 return step;
2311}2311}
23122312
2313const ModuleTestOptions = struct {2313pub const ModuleTestOptions = struct {
2314 test_filters: []const []const u8,2314 test_filters: []const []const u8,
2315 test_target_filters: []const []const u8,2315 test_target_filters: []const []const u8,
2316 test_extra_targets: bool,2316 test_extra_targets: bool,
...@@ -2319,7 +2319,7 @@ const ModuleTestOptions = struct {...@@ -2319,7 +2319,7 @@ const ModuleTestOptions = struct {
2319 desc: []const u8,2319 desc: []const u8,
2320 optimize_modes: []const OptimizeMode,2320 optimize_modes: []const OptimizeMode,
2321 include_paths: []const []const u8,2321 include_paths: []const []const u8,
2322 test_default_only: bool,2322 test_only: ?TestOnly,
2323 skip_single_threaded: bool,2323 skip_single_threaded: bool,
2324 skip_non_native: bool,2324 skip_non_native: bool,
2325 skip_spirv: bool,2325 skip_spirv: bool,
...@@ -2335,20 +2335,31 @@ const ModuleTestOptions = struct {...@@ -2335,20 +2335,31 @@ const ModuleTestOptions = struct {
2335 max_rss: usize = 0,2335 max_rss: usize = 0,
2336 no_builtin: bool = false,2336 no_builtin: bool = false,
2337 build_options: ?*Step.Options = null,2337 build_options: ?*Step.Options = null,
2338
2339 pub const TestOnly = union(enum) {
2340 default: void,
2341 fuzz: OptimizeMode,
2342 };
2338};2343};
23392344
2340pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {2345pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
2341 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);2346 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
23422347
2343 if (options.test_default_only) {2348 if (options.test_only) |test_only| {
2344 const test_target = &test_targets[0];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 };
2345 const resolved_target = b.resolveTargetQuery(test_target.target);2356 const resolved_target = b.resolveTargetQuery(test_target.target);
2346 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");2357 const triple_txt = resolved_target.query.zigTriple(b.allocator) catch @panic("OOM");
2347 addOneModuleTest(b, step, test_target, &resolved_target, triple_txt, options);2358 addOneModuleTest(b, step, test_target, &resolved_target, triple_txt, options);
2348 return step;2359 return step;
2349 }2360 }
23502361
2351 for_targets: for (&test_targets) |*test_target| {2362 for_targets: for (test_targets) |test_target| {
2352 if (test_target.skip_modules.len > 0) {2363 if (test_target.skip_modules.len > 0) {
2353 for (test_target.skip_modules) |skip_mod| {2364 for (test_target.skip_modules) |skip_mod| {
2354 if (std.mem.eql(u8, options.name, skip_mod)) continue :for_targets;2365 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 {...@@ -2425,7 +2436,7 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
2425fn addOneModuleTest(2436fn addOneModuleTest(
2426 b: *std.Build,2437 b: *std.Build,
2427 step: *Step,2438 step: *Step,
2428 test_target: *const TestTarget,2439 test_target: TestTarget,
2429 resolved_target: *const std.Build.ResolvedTarget,2440 resolved_target: *const std.Build.ResolvedTarget,
2430 triple_txt: []const u8,2441 triple_txt: []const u8,
2431 options: ModuleTestOptions,2442 options: ModuleTestOptions,