Commit 7bad695865
test/tests.zig
@@ -639,8 +639,7 @@ pub fn addGenHTests(b: *std.Build, test_filter: ?[]const u8) *Step {
return cases.step;
}
-pub fn addPkgTests(
- b: *std.Build,
+const ModuleTestOptions = struct {
test_filter: ?[]const u8,
root_src: []const u8,
name: []const u8,
@@ -651,14 +650,17 @@ pub fn addPkgTests(
skip_libc: bool,
skip_stage1: bool,
skip_stage2: bool,
-) *Step {
- const step = b.step(b.fmt("test-{s}", .{name}), desc);
+ max_rss: usize = 0,
+};
+
+pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
+ const step = b.step(b.fmt("test-{s}", .{options.name}), options.desc);
for (test_targets) |test_target| {
- if (skip_non_native and !test_target.target.isNative())
+ if (options.skip_non_native and !test_target.target.isNative())
continue;
- if (skip_libc and test_target.link_libc)
+ if (options.skip_libc and test_target.link_libc)
continue;
if (test_target.link_libc and test_target.target.getOs().requiresLibC()) {
@@ -666,7 +668,7 @@ pub fn addPkgTests(
continue;
}
- if (skip_single_threaded and test_target.single_threaded)
+ if (options.skip_single_threaded and test_target.single_threaded)
continue;
if (test_target.disable_native and
@@ -677,12 +679,12 @@ pub fn addPkgTests(
}
if (test_target.backend) |backend| switch (backend) {
- .stage1 => if (skip_stage1) continue,
+ .stage1 => if (options.skip_stage1) continue,
.stage2_llvm => {},
- else => if (skip_stage2) continue,
+ else => if (options.skip_stage2) continue,
};
- const want_this_mode = for (optimize_modes) |m| {
+ const want_this_mode = for (options.optimize_modes) |m| {
if (m == test_target.optimize_mode) break true;
} else false;
if (!want_this_mode) continue;
@@ -696,15 +698,22 @@ pub fn addPkgTests(
const triple_prefix = test_target.target.zigTriple(b.allocator) catch unreachable;
+ // wasm32-wasi builds need more RAM, idk why
+ const max_rss = if (test_target.target.getOs().tag == .wasi)
+ options.max_rss * 2
+ else
+ options.max_rss;
+
const these_tests = b.addTest(.{
- .root_source_file = .{ .path = root_src },
+ .root_source_file = .{ .path = options.root_src },
.optimize = test_target.optimize_mode,
.target = test_target.target,
+ .max_rss = max_rss,
});
const single_threaded_txt = if (test_target.single_threaded) "single" else "multi";
const backend_txt = if (test_target.backend) |backend| @tagName(backend) else "default";
these_tests.setNamePrefix(b.fmt("{s}-{s}-{s}-{s}-{s}-{s} ", .{
- name,
+ options.name,
triple_prefix,
@tagName(test_target.optimize_mode),
libc_prefix,
@@ -712,7 +721,7 @@ pub fn addPkgTests(
backend_txt,
}));
these_tests.single_threaded = test_target.single_threaded;
- these_tests.setFilter(test_filter);
+ these_tests.setFilter(options.test_filter);
if (test_target.link_libc) {
these_tests.linkSystemLibrary("c");
}
build.zig
@@ -402,47 +402,45 @@ pub fn build(b: *std.Build) !void {
const do_fmt_step = b.step("fmt", "Modify source files in place to have conforming formatting");
do_fmt_step.dependOn(&do_fmt.step);
- test_step.dependOn(tests.addPkgTests(
- b,
- test_filter,
- "test/behavior.zig",
- "behavior",
- "Run the behavior tests",
- optimization_modes,
- skip_single_threaded,
- skip_non_native,
- skip_libc,
- skip_stage1,
- skip_stage2_tests,
- ));
-
- test_step.dependOn(tests.addPkgTests(
- b,
- test_filter,
- "lib/compiler_rt.zig",
- "compiler-rt",
- "Run the compiler_rt tests",
- optimization_modes,
- true, // skip_single_threaded
- skip_non_native,
- true, // skip_libc
- skip_stage1,
- skip_stage2_tests or true, // TODO get these all passing
- ));
-
- test_step.dependOn(tests.addPkgTests(
- b,
- test_filter,
- "lib/c.zig",
- "universal-libc",
- "Run the universal libc tests",
- optimization_modes,
- true, // skip_single_threaded
- skip_non_native,
- true, // skip_libc
- skip_stage1,
- skip_stage2_tests or true, // TODO get these all passing
- ));
+ test_step.dependOn(tests.addModuleTests(b, .{
+ .test_filter = test_filter,
+ .root_src = "test/behavior.zig",
+ .name = "behavior",
+ .desc = "Run the behavior tests",
+ .optimize_modes = optimization_modes,
+ .skip_single_threaded = skip_single_threaded,
+ .skip_non_native = skip_non_native,
+ .skip_libc = skip_libc,
+ .skip_stage1 = skip_stage1,
+ .skip_stage2 = skip_stage2_tests,
+ .max_rss = 1 * 1024 * 1024 * 1024,
+ }));
+
+ test_step.dependOn(tests.addModuleTests(b, .{
+ .test_filter = test_filter,
+ .root_src = "lib/compiler_rt.zig",
+ .name = "compiler-rt",
+ .desc = "Run the compiler_rt tests",
+ .optimize_modes = optimization_modes,
+ .skip_single_threaded = true,
+ .skip_non_native = skip_non_native,
+ .skip_libc = true,
+ .skip_stage1 = skip_stage1,
+ .skip_stage2 = true, // TODO get all these passing
+ }));
+
+ test_step.dependOn(tests.addModuleTests(b, .{
+ .test_filter = test_filter,
+ .root_src = "lib/c.zig",
+ .name = "universal-libc",
+ .desc = "Run the universal libc tests",
+ .optimize_modes = optimization_modes,
+ .skip_single_threaded = true,
+ .skip_non_native = skip_non_native,
+ .skip_libc = true,
+ .skip_stage1 = skip_stage1,
+ .skip_stage2 = true, // TODO get all these passing
+ }));
test_step.dependOn(tests.addCompareOutputTests(b, test_filter, optimization_modes));
test_step.dependOn(tests.addStandaloneTests(
@@ -472,19 +470,19 @@ pub fn build(b: *std.Build) !void {
// tests for this feature are disabled until we have the self-hosted compiler available
// test_step.dependOn(tests.addGenHTests(b, test_filter));
- test_step.dependOn(tests.addPkgTests(
- b,
- test_filter,
- "lib/std/std.zig",
- "std",
- "Run the standard library tests",
- optimization_modes,
- skip_single_threaded,
- skip_non_native,
- skip_libc,
- skip_stage1,
- true, // TODO get these all passing
- ));
+ test_step.dependOn(tests.addModuleTests(b, .{
+ .test_filter = test_filter,
+ .root_src = "lib/std/std.zig",
+ .name = "std",
+ .desc = "Run the standard library tests",
+ .optimize_modes = optimization_modes,
+ .skip_single_threaded = skip_single_threaded,
+ .skip_non_native = skip_non_native,
+ .skip_libc = skip_libc,
+ .skip_stage1 = skip_stage1,
+ .skip_stage2 = true, // TODO get all these passing
+ .max_rss = 3 * 1024 * 1024 * 1024,
+ }));
try addWasiUpdateStep(b, version);
}