Commit b8472db215
Changed files (1)
test
test/tests.zig
@@ -1106,9 +1106,11 @@ pub fn addStackTraceTests(
) *Step {
const check_exe = b.addExecutable(.{
.name = "check-stack-trace",
- .root_source_file = b.path("test/src/check-stack-trace.zig"),
- .target = b.graph.host,
- .optimize = .Debug,
+ .root_module = b.createModule(.{
+ .root_source_file = b.path("test/src/check-stack-trace.zig"),
+ .target = b.graph.host,
+ .optimize = .Debug,
+ }),
});
const cases = b.allocator.create(StackTracesContext) catch @panic("OOM");
@@ -1330,7 +1332,7 @@ pub fn addCliTests(b: *std.Build) *Step {
run5.step.dependOn(&run4.step);
const unformatted_code_utf16 = "\xff\xfe \x00 \x00 \x00 \x00/\x00/\x00 \x00n\x00o\x00 \x00r\x00e\x00a\x00s\x00o\x00n\x00";
- const fmt6_path = std.fs.path.join(b.allocator, &.{ tmp_path, "fmt6.zig" }) catch @panic("OOM");
+ const fmt6_path = b.pathJoin(&.{ tmp_path, "fmt6.zig" });
const write6 = b.addUpdateSourceFiles();
write6.addBytesToSource(unformatted_code_utf16, fmt6_path);
write6.step.dependOn(&run5.step);
@@ -1514,18 +1516,20 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
options.max_rss;
const these_tests = b.addTest(.{
- .root_source_file = b.path(options.root_src),
- .optimize = test_target.optimize_mode,
- .target = resolved_target,
+ .root_module = b.createModule(.{
+ .root_source_file = b.path(options.root_src),
+ .optimize = test_target.optimize_mode,
+ .target = resolved_target,
+ .link_libc = test_target.link_libc,
+ .pic = test_target.pic,
+ .strip = test_target.strip,
+ .single_threaded = test_target.single_threaded,
+ }),
.max_rss = max_rss,
.filters = options.test_filters,
- .link_libc = test_target.link_libc,
- .single_threaded = test_target.single_threaded,
.use_llvm = test_target.use_llvm,
.use_lld = test_target.use_lld,
.zig_lib_dir = b.path("lib"),
- .pic = test_target.pic,
- .strip = test_target.strip,
});
if (options.no_builtin) these_tests.no_builtin = true;
if (options.build_options) |build_options| {
@@ -1561,12 +1565,17 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
var altered_query = test_target.target;
altered_query.ofmt = null;
- const compile_c = b.addExecutable(.{
- .name = qualified_name,
+ const compile_c = b.createModule(.{
+ .root_source_file = null,
.link_libc = test_target.link_libc,
.target = b.resolveTargetQuery(altered_query),
+ });
+ const compile_c_exe = b.addExecutable(.{
+ .name = qualified_name,
+ .root_module = compile_c,
.zig_lib_dir = b.path("lib"),
});
+
compile_c.addCSourceFile(.{
.file = these_tests.getEmittedBin(),
.flags = &.{
@@ -1611,22 +1620,22 @@ pub fn addModuleTests(b: *std.Build, options: ModuleTestOptions) *Step {
continue;
}
if (test_target.link_libc == false) {
- compile_c.subsystem = .Console;
- compile_c.linkSystemLibrary("kernel32");
- compile_c.linkSystemLibrary("ntdll");
+ compile_c_exe.subsystem = .Console;
+ compile_c.linkSystemLibrary("kernel32", .{});
+ compile_c.linkSystemLibrary("ntdll", .{});
}
if (mem.eql(u8, options.name, "std")) {
if (test_target.link_libc == false) {
- compile_c.linkSystemLibrary("shell32");
- compile_c.linkSystemLibrary("advapi32");
+ compile_c.linkSystemLibrary("shell32", .{});
+ compile_c.linkSystemLibrary("advapi32", .{});
}
- compile_c.linkSystemLibrary("crypt32");
- compile_c.linkSystemLibrary("ws2_32");
- compile_c.linkSystemLibrary("ole32");
+ compile_c.linkSystemLibrary("crypt32", .{});
+ compile_c.linkSystemLibrary("ws2_32", .{});
+ compile_c.linkSystemLibrary("ole32", .{});
}
}
- const run = b.addRunArtifact(compile_c);
+ const run = b.addRunArtifact(compile_c_exe);
run.skip_foreign_checks = true;
run.enableTestRunnerMode();
run.setName(b.fmt("run test {s}", .{qualified_name}));
@@ -1675,6 +1684,20 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
continue;
}
+ const test_mod = b.createModule(.{
+ .root_source_file = b.path("test/c_abi/main.zig"),
+ .target = resolved_target,
+ .optimize = optimize_mode,
+ .link_libc = true,
+ .pic = c_abi_target.pic,
+ .strip = c_abi_target.strip,
+ });
+ test_mod.addCSourceFile(.{
+ .file = b.path("test/c_abi/cfuncs.c"),
+ .flags = &.{"-std=c99"},
+ });
+ for (c_abi_target.c_defines) |define| test_mod.addCMacro(define, "1");
+
const test_step = b.addTest(.{
.name = b.fmt("test-c-abi-{s}-{s}-{s}{s}{s}{s}", .{
triple_txt,
@@ -1691,20 +1714,10 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
if (c_abi_target.use_lld == false) "-no-lld" else "",
if (c_abi_target.pic == true) "-pic" else "",
}),
- .root_source_file = b.path("test/c_abi/main.zig"),
- .target = resolved_target,
- .optimize = optimize_mode,
- .link_libc = true,
+ .root_module = test_mod,
.use_llvm = c_abi_target.use_llvm,
.use_lld = c_abi_target.use_lld,
- .pic = c_abi_target.pic,
- .strip = c_abi_target.strip,
});
- test_step.addCSourceFile(.{
- .file = b.path("test/c_abi/cfuncs.c"),
- .flags = &.{"-std=c99"},
- });
- for (c_abi_target.c_defines) |define| test_step.root_module.addCMacro(define, "1");
// This test is intentionally trying to check if the external ABI is
// done properly. LTO would be a hindrance to this.
@@ -1784,9 +1797,11 @@ pub fn addDebuggerTests(b: *std.Build, options: DebuggerContext.Options) ?*Step
pub fn addIncrementalTests(b: *std.Build, test_step: *Step) !void {
const incr_check = b.addExecutable(.{
.name = "incr-check",
- .root_source_file = b.path("tools/incr-check.zig"),
- .target = b.graph.host,
- .optimize = .Debug,
+ .root_module = b.createModule(.{
+ .root_source_file = b.path("tools/incr-check.zig"),
+ .target = b.graph.host,
+ .optimize = .Debug,
+ }),
});
var dir = try b.build_root.handle.openDir("test/incremental", .{ .iterate = true });