authorgravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2022-10-25 16:52:29+11:00
committergravatar for 4678790+dweiller@users.noreply.github.comDominic <4678790+dweiller@users.noreply.github.com> 2022-11-02 12:54:35+11:00
log55c91fc42d048a18c724bdaffe3709bef8aa143e
tree36adf282f6f3509e97a6d348ceb96a712a240608
parentebf9ffd342a30c7c79657f5dbfc83fde0647e630

stage2: add test_runner_path for user provided test runner


2 files changed, 15 insertions(+), 6 deletions(-)

src/Compilation.zig+10-6
...@@ -994,6 +994,7 @@ pub const InitOptions = struct {...@@ -994,6 +994,7 @@ pub const InitOptions = struct {
994 reference_trace: ?u32 = null,994 reference_trace: ?u32 = null,
995 test_filter: ?[]const u8 = null,995 test_filter: ?[]const u8 = null,
996 test_name_prefix: ?[]const u8 = null,996 test_name_prefix: ?[]const u8 = null,
997 test_runner_path: ?[]const u8 = null,
997 subsystem: ?std.Target.SubSystem = null,998 subsystem: ?std.Target.SubSystem = null,
998 /// WASI-only. Type of WASI execution model ("command" or "reactor").999 /// WASI-only. Type of WASI execution model ("command" or "reactor").
999 wasi_exec_model: ?std.builtin.WasiExecModel = null,1000 wasi_exec_model: ?std.builtin.WasiExecModel = null,
...@@ -1578,12 +1579,15 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {...@@ -1578,12 +1579,15 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation {
1578 errdefer std_pkg.destroy(gpa);1579 errdefer std_pkg.destroy(gpa);
15791580
1580 const root_pkg = if (options.is_test) root_pkg: {1581 const root_pkg = if (options.is_test) root_pkg: {
1581 const test_pkg = try Package.createWithDir(1582 const test_pkg = if (options.test_runner_path) |test_runner|
1582 gpa,1583 try Package.create(gpa, null, test_runner)
1583 options.zig_lib_directory,1584 else
1584 null,1585 try Package.createWithDir(
1585 "test_runner.zig",1586 gpa,
1586 );1587 options.zig_lib_directory,
1588 null,
1589 "test_runner.zig",
1590 );
1587 errdefer test_pkg.destroy(gpa);1591 errdefer test_pkg.destroy(gpa);
15881592
1589 break :root_pkg test_pkg;1593 break :root_pkg test_pkg;
src/main.zig+5
...@@ -503,6 +503,7 @@ const usage_build_generic =...@@ -503,6 +503,7 @@ const usage_build_generic =
503 \\ --test-cmd-bin Appends test binary path to test cmd args503 \\ --test-cmd-bin Appends test binary path to test cmd args
504 \\ --test-evented-io Runs the test in evented I/O mode504 \\ --test-evented-io Runs the test in evented I/O mode
505 \\ --test-no-exec Compiles test binary without running it505 \\ --test-no-exec Compiles test binary without running it
506 \\ --test-runner [path] Specify a custom test runner
506 \\507 \\
507 \\Debug Options (Zig Compiler Development):508 \\Debug Options (Zig Compiler Development):
508 \\ -ftime-report Print timing diagnostics509 \\ -ftime-report Print timing diagnostics
...@@ -726,6 +727,7 @@ fn buildOutputType(...@@ -726,6 +727,7 @@ fn buildOutputType(
726 var runtime_args_start: ?usize = null;727 var runtime_args_start: ?usize = null;
727 var test_filter: ?[]const u8 = null;728 var test_filter: ?[]const u8 = null;
728 var test_name_prefix: ?[]const u8 = null;729 var test_name_prefix: ?[]const u8 = null;
730 var test_runner_path: ?[]const u8 = null;
729 var override_local_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LOCAL_CACHE_DIR");731 var override_local_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LOCAL_CACHE_DIR");
730 var override_global_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_GLOBAL_CACHE_DIR");732 var override_global_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_GLOBAL_CACHE_DIR");
731 var override_lib_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LIB_DIR");733 var override_lib_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LIB_DIR");
...@@ -1043,6 +1045,8 @@ fn buildOutputType(...@@ -1043,6 +1045,8 @@ fn buildOutputType(
1043 test_filter = args_iter.nextOrFatal();1045 test_filter = args_iter.nextOrFatal();
1044 } else if (mem.eql(u8, arg, "--test-name-prefix")) {1046 } else if (mem.eql(u8, arg, "--test-name-prefix")) {
1045 test_name_prefix = args_iter.nextOrFatal();1047 test_name_prefix = args_iter.nextOrFatal();
1048 } else if (mem.eql(u8, arg, "--test-runner")) {
1049 test_runner_path = args_iter.nextOrFatal();
1046 } else if (mem.eql(u8, arg, "--test-cmd")) {1050 } else if (mem.eql(u8, arg, "--test-cmd")) {
1047 try test_exec_args.append(args_iter.nextOrFatal());1051 try test_exec_args.append(args_iter.nextOrFatal());
1048 } else if (mem.eql(u8, arg, "--cache-dir")) {1052 } else if (mem.eql(u8, arg, "--cache-dir")) {
...@@ -2943,6 +2947,7 @@ fn buildOutputType(...@@ -2943,6 +2947,7 @@ fn buildOutputType(
2943 .test_evented_io = test_evented_io,2947 .test_evented_io = test_evented_io,
2944 .test_filter = test_filter,2948 .test_filter = test_filter,
2945 .test_name_prefix = test_name_prefix,2949 .test_name_prefix = test_name_prefix,
2950 .test_runner_path = test_runner_path,
2946 .disable_lld_caching = !have_enable_cache,2951 .disable_lld_caching = !have_enable_cache,
2947 .subsystem = subsystem,2952 .subsystem = subsystem,
2948 .wasi_exec_model = wasi_exec_model,2953 .wasi_exec_model = wasi_exec_model,