authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-06 00:27:46-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-03-15 10:48:13-07:00
log7bad6958657c6b4a791c73a3f827f7f848cab762
treed2c2ee46a950c9a7180c30cf862a590eb46b9d14
parentf51413d2cf0bd87079dace7f6481d2a361a19ea6

build.zig: annotate std lib tests maxrss


2 files changed, 74 insertions(+), 67 deletions(-)

build.zig+52-54
......@@ -402,47 +402,45 @@ pub fn build(b: *std.Build) !void {
402402 const do_fmt_step = b.step("fmt", "Modify source files in place to have conforming formatting");
403403 do_fmt_step.dependOn(&do_fmt.step);
404404
405 test_step.dependOn(tests.addPkgTests(
406 b,
407 test_filter,
408 "test/behavior.zig",
409 "behavior",
410 "Run the behavior tests",
411 optimization_modes,
412 skip_single_threaded,
413 skip_non_native,
414 skip_libc,
415 skip_stage1,
416 skip_stage2_tests,
417 ));
418
419 test_step.dependOn(tests.addPkgTests(
420 b,
421 test_filter,
422 "lib/compiler_rt.zig",
423 "compiler-rt",
424 "Run the compiler_rt tests",
425 optimization_modes,
426 true, // skip_single_threaded
427 skip_non_native,
428 true, // skip_libc
429 skip_stage1,
430 skip_stage2_tests or true, // TODO get these all passing
431 ));
432
433 test_step.dependOn(tests.addPkgTests(
434 b,
435 test_filter,
436 "lib/c.zig",
437 "universal-libc",
438 "Run the universal libc tests",
439 optimization_modes,
440 true, // skip_single_threaded
441 skip_non_native,
442 true, // skip_libc
443 skip_stage1,
444 skip_stage2_tests or true, // TODO get these all passing
445 ));
405 test_step.dependOn(tests.addModuleTests(b, .{
406 .test_filter = test_filter,
407 .root_src = "test/behavior.zig",
408 .name = "behavior",
409 .desc = "Run the behavior tests",
410 .optimize_modes = optimization_modes,
411 .skip_single_threaded = skip_single_threaded,
412 .skip_non_native = skip_non_native,
413 .skip_libc = skip_libc,
414 .skip_stage1 = skip_stage1,
415 .skip_stage2 = skip_stage2_tests,
416 .max_rss = 1 * 1024 * 1024 * 1024,
417 }));
418
419 test_step.dependOn(tests.addModuleTests(b, .{
420 .test_filter = test_filter,
421 .root_src = "lib/compiler_rt.zig",
422 .name = "compiler-rt",
423 .desc = "Run the compiler_rt tests",
424 .optimize_modes = optimization_modes,
425 .skip_single_threaded = true,
426 .skip_non_native = skip_non_native,
427 .skip_libc = true,
428 .skip_stage1 = skip_stage1,
429 .skip_stage2 = true, // TODO get all these passing
430 }));
431
432 test_step.dependOn(tests.addModuleTests(b, .{
433 .test_filter = test_filter,
434 .root_src = "lib/c.zig",
435 .name = "universal-libc",
436 .desc = "Run the universal libc tests",
437 .optimize_modes = optimization_modes,
438 .skip_single_threaded = true,
439 .skip_non_native = skip_non_native,
440 .skip_libc = true,
441 .skip_stage1 = skip_stage1,
442 .skip_stage2 = true, // TODO get all these passing
443 }));
446444
447445 test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));
448446 test_step.dependOn(tests.addStandaloneTests(
......@@ -472,19 +470,19 @@ pub fn build(b: *std.Build) !void {
472470 // tests for this feature are disabled until we have the self-hosted compiler available
473471 // test_step.dependOn(tests.addGenHTests(b, test_filter));
474472
475 test_step.dependOn(tests.addPkgTests(
476 b,
477 test_filter,
478 "lib/std/std.zig",
479 "std",
480 "Run the standard library tests",
481 optimization_modes,
482 skip_single_threaded,
483 skip_non_native,
484 skip_libc,
485 skip_stage1,
486 true, // TODO get these all passing
487 ));
473 test_step.dependOn(tests.addModuleTests(b, .{
474 .test_filter = test_filter,
475 .root_src = "lib/std/std.zig",
476 .name = "std",
477 .desc = "Run the standard library tests",
478 .optimize_modes = optimization_modes,
479 .skip_single_threaded = skip_single_threaded,
480 .skip_non_native = skip_non_native,
481 .skip_libc = skip_libc,
482 .skip_stage1 = skip_stage1,
483 .skip_stage2 = true, // TODO get all these passing
484 .max_rss = 3 * 1024 * 1024 * 1024,
485 }));
488486
489487 try addWasiUpdateStep(b, version);
490488}
test/tests.zig+22-13
......@@ -639,8 +639,7 @@ pub fn addGenHTests(b: *std.Build, test_filter: ?[]const u8) *Step {
639639 return cases.step;
640640}
641641
642pub fn addPkgTests(
643 b: *std.Build,
642const ModuleTestOptions = struct {
644643 test_filter: ?[]const u8,
645644 root_src: []const u8,
646645 name: []const u8,
......@@ -651,14 +650,17 @@ pub fn addPkgTests(
651650 skip_libc: bool,
652651 skip_stage1: bool,
653652 skip_stage2: bool,
654) *Step {
655 const step = b.step(b.fmt("test-{s}", .{name}), desc);
653 max_rss: usize = 0,
654};
655
656pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
657 const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
656658
657659 for (test_targets) |test_target| {
658 if (skip_non_native and !test_target.target.isNative())
660 if (options.skip_non_native and !test_target.target.isNative())
659661 continue;
660662
661 if (skip_libc and test_target.link_libc)
663 if (options.skip_libc and test_target.link_libc)
662664 continue;
663665
664666 if (test_target.link_libc and test_target.target.getOs().requiresLibC()) {
......@@ -666,7 +668,7 @@ pub fn addPkgTests(
666668 continue;
667669 }
668670
669 if (skip_single_threaded and test_target.single_threaded)
671 if (options.skip_single_threaded and test_target.single_threaded)
670672 continue;
671673
672674 if (test_target.disable_native and
......@@ -677,12 +679,12 @@ pub fn addPkgTests(
677679 }
678680
679681 if (test_target.backend) |backend| switch (backend) {
680 .stage1 => if (skip_stage1) continue,
682 .stage1 => if (options.skip_stage1) continue,
681683 .stage2_llvm => {},
682 else => if (skip_stage2) continue,
684 else => if (options.skip_stage2) continue,
683685 };
684686
685 const want_this_mode = for (optimize_modes) |m| {
687 const want_this_mode = for (options.optimize_modes) |m| {
686688 if (m == test_target.optimize_mode) break true;
687689 } else false;
688690 if (!want_this_mode) continue;
......@@ -696,15 +698,22 @@ pub fn addPkgTests(
696698
697699 const triple_prefix = test_target.target.zigTriple(b.allocator) catch unreachable;
698700
701 // wasm32-wasi builds need more RAM, idk why
702 const max_rss = if (test_target.target.getOs().tag == .wasi)
703 options.max_rss * 2
704 else
705 options.max_rss;
706
699707 const these_tests = b.addTest(.{
700 .root_source_file = .{ .path = root_src },
708 .root_source_file = .{ .path = options.root_src },
701709 .optimize = test_target.optimize_mode,
702710 .target = test_target.target,
711 .max_rss = max_rss,
703712 });
704713 const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
705714 const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default";
706715 these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s}-{s} ", .{
707 name,
716 options.name,
708717 triple_prefix,
709718 @tagName(test_target.optimize_mode),
710719 libc_prefix,
......@@ -712,7 +721,7 @@ pub fn addPkgTests(
712721 backend_txt,
713722 }));
714723 these_tests.single_threaded = test_target.single_threaded;
715 these_tests.setFilter(test_filter);
724 these_tests.setFilter(options.test_filter);
716725 if (test_target.link_libc) {
717726 these_tests.linkSystemLibrary("c");
718727 }