diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Compilation.zig | 16 | ||||
| -rw-r--r-- | src/main.zig | 5 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index 958aac5e1b..e8e15b75ad 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -994,6 +994,7 @@ pub const InitOptions = struct { reference_trace: ?u32 = null, test_filter: ?[]const u8 = null, test_name_prefix: ?[]const u8 = null, + test_runner_path: ?[]const u8 = null, subsystem: ?std.Target.SubSystem = null, /// WASI-only. Type of WASI execution model ("command" or "reactor"). wasi_exec_model: ?std.builtin.WasiExecModel = null, @@ -1578,12 +1579,15 @@ pub fn create(gpa: Allocator, options: InitOptions) !*Compilation { errdefer std_pkg.destroy(gpa); const root_pkg = if (options.is_test) root_pkg: { - const test_pkg = try Package.createWithDir( - gpa, - options.zig_lib_directory, - null, - "test_runner.zig", - ); + const test_pkg = if (options.test_runner_path) |test_runner| + try Package.create(gpa, null, test_runner) + else + try Package.createWithDir( + gpa, + options.zig_lib_directory, + null, + "test_runner.zig", + ); errdefer test_pkg.destroy(gpa); break :root_pkg test_pkg; diff --git a/src/main.zig b/src/main.zig index d0edbbed6d..4d861851c2 100644 --- a/src/main.zig +++ b/src/main.zig @@ -503,6 +503,7 @@ const usage_build_generic = \\ --test-cmd-bin Appends test binary path to test cmd args \\ --test-evented-io Runs the test in evented I/O mode \\ --test-no-exec Compiles test binary without running it + \\ --test-runner [path] Specify a custom test runner \\ \\Debug Options (Zig Compiler Development): \\ -ftime-report Print timing diagnostics @@ -726,6 +727,7 @@ fn buildOutputType( var runtime_args_start: ?usize = null; var test_filter: ?[]const u8 = null; var test_name_prefix: ?[]const u8 = null; + var test_runner_path: ?[]const u8 = null; var override_local_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LOCAL_CACHE_DIR"); var override_global_cache_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_GLOBAL_CACHE_DIR"); var override_lib_dir: ?[]const u8 = try optionalStringEnvVar(arena, "ZIG_LIB_DIR"); @@ -1043,6 +1045,8 @@ fn buildOutputType( test_filter = args_iter.nextOrFatal(); } else if (mem.eql(u8, arg, "--test-name-prefix")) { test_name_prefix = args_iter.nextOrFatal(); + } else if (mem.eql(u8, arg, "--test-runner")) { + test_runner_path = args_iter.nextOrFatal(); } else if (mem.eql(u8, arg, "--test-cmd")) { try test_exec_args.append(args_iter.nextOrFatal()); } else if (mem.eql(u8, arg, "--cache-dir")) { @@ -2943,6 +2947,7 @@ fn buildOutputType( .test_evented_io = test_evented_io, .test_filter = test_filter, .test_name_prefix = test_name_prefix, + .test_runner_path = test_runner_path, .disable_lld_caching = !have_enable_cache, .subsystem = subsystem, .wasi_exec_model = wasi_exec_model, |
