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