Skip to content

Commit 07a4545

Browse files
committed
build.zig: annotate std lib tests maxrss
1 parent 8d0ba6b commit 07a4545

File tree

2 files changed

+74
-67
lines changed

2 files changed

+74
-67
lines changed

build.zig

Lines changed: 52 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -400,47 +400,45 @@ pub fn build(b: *std.Build) !void {
400400
const do_fmt_step = b.step("fmt", "Modify source files in place to have conforming formatting");
401401
do_fmt_step.dependOn(&do_fmt.step);
402402

403-
test_step.dependOn(tests.addPkgTests(
404-
b,
405-
test_filter,
406-
"test/behavior.zig",
407-
"behavior",
408-
"Run the behavior tests",
409-
optimization_modes,
410-
skip_single_threaded,
411-
skip_non_native,
412-
skip_libc,
413-
skip_stage1,
414-
skip_stage2_tests,
415-
));
416-
417-
test_step.dependOn(tests.addPkgTests(
418-
b,
419-
test_filter,
420-
"lib/compiler_rt.zig",
421-
"compiler-rt",
422-
"Run the compiler_rt tests",
423-
optimization_modes,
424-
true, // skip_single_threaded
425-
skip_non_native,
426-
true, // skip_libc
427-
skip_stage1,
428-
skip_stage2_tests or true, // TODO get these all passing
429-
));
430-
431-
test_step.dependOn(tests.addPkgTests(
432-
b,
433-
test_filter,
434-
"lib/c.zig",
435-
"universal-libc",
436-
"Run the universal libc tests",
437-
optimization_modes,
438-
true, // skip_single_threaded
439-
skip_non_native,
440-
true, // skip_libc
441-
skip_stage1,
442-
skip_stage2_tests or true, // TODO get these all passing
443-
));
403+
test_step.dependOn(tests.addModuleTests(b, .{
404+
.test_filter = test_filter,
405+
.root_src = "test/behavior.zig",
406+
.name = "behavior",
407+
.desc = "Run the behavior tests",
408+
.optimize_modes = optimization_modes,
409+
.skip_single_threaded = skip_single_threaded,
410+
.skip_non_native = skip_non_native,
411+
.skip_libc = skip_libc,
412+
.skip_stage1 = skip_stage1,
413+
.skip_stage2 = skip_stage2_tests,
414+
.max_rss = 1 * 1024 * 1024 * 1024,
415+
}));
416+
417+
test_step.dependOn(tests.addModuleTests(b, .{
418+
.test_filter = test_filter,
419+
.root_src = "lib/compiler_rt.zig",
420+
.name = "compiler-rt",
421+
.desc = "Run the compiler_rt tests",
422+
.optimize_modes = optimization_modes,
423+
.skip_single_threaded = true,
424+
.skip_non_native = skip_non_native,
425+
.skip_libc = true,
426+
.skip_stage1 = skip_stage1,
427+
.skip_stage2 = true, // TODO get all these passing
428+
}));
429+
430+
test_step.dependOn(tests.addModuleTests(b, .{
431+
.test_filter = test_filter,
432+
.root_src = "lib/c.zig",
433+
.name = "universal-libc",
434+
.desc = "Run the universal libc tests",
435+
.optimize_modes = optimization_modes,
436+
.skip_single_threaded = true,
437+
.skip_non_native = skip_non_native,
438+
.skip_libc = true,
439+
.skip_stage1 = skip_stage1,
440+
.skip_stage2 = true, // TODO get all these passing
441+
}));
444442

445443
test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));
446444
test_step.dependOn(tests.addStandaloneTests(
@@ -470,19 +468,19 @@ pub fn build(b: *std.Build) !void {
470468
// tests for this feature are disabled until we have the self-hosted compiler available
471469
// test_step.dependOn(tests.addGenHTests(b, test_filter));
472470

473-
test_step.dependOn(tests.addPkgTests(
474-
b,
475-
test_filter,
476-
"lib/std/std.zig",
477-
"std",
478-
"Run the standard library tests",
479-
optimization_modes,
480-
skip_single_threaded,
481-
skip_non_native,
482-
skip_libc,
483-
skip_stage1,
484-
true, // TODO get these all passing
485-
));
471+
test_step.dependOn(tests.addModuleTests(b, .{
472+
.test_filter = test_filter,
473+
.root_src = "lib/std/std.zig",
474+
.name = "std",
475+
.desc = "Run the standard library tests",
476+
.optimize_modes = optimization_modes,
477+
.skip_single_threaded = skip_single_threaded,
478+
.skip_non_native = skip_non_native,
479+
.skip_libc = skip_libc,
480+
.skip_stage1 = skip_stage1,
481+
.skip_stage2 = true, // TODO get all these passing
482+
.max_rss = 3 * 1024 * 1024 * 1024,
483+
}));
486484

487485
try addWasiUpdateStep(b, version);
488486
}

test/tests.zig

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,7 @@ pub fn addGenHTests(b: *std.Build, test_filter: ?[]const u8) *Step {
639639
return cases.step;
640640
}
641641

642-
pub fn addPkgTests(
643-
b: *std.Build,
642+
const ModuleTestOptions = struct {
644643
test_filter: ?[]const u8,
645644
root_src: []const u8,
646645
name: []const u8,
@@ -651,22 +650,25 @@ 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+
656+
pub 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()) {
665667
// This would be a redundant test.
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,23 +698,30 @@ 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,
711720
single_threaded_txt,
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
}

0 commit comments

Comments
 (0)