| author | |
| committer | |
| log | 7ca9f3bc7ba1a413ea7f8b88dfafba3d0f842f6e |
| tree | f326c402505227073fcd57142debe09c5c83cdf0 |
| parent | a54ccd85374407a5015c5d8e0173089e75da9be4 |
it will be set to the path of the zig executable which is running
`zig test`.3 files changed, 15 insertions(+), 1 deletions(-)
lib/std/special/test_runner.zig+8| ... | @@ -11,7 +11,15 @@ pub const io_mode: io.Mode = builtin.test_io_mode; | ... | @@ -11,7 +11,15 @@ pub const io_mode: io.Mode = builtin.test_io_mode; |
| 11 | 11 | ||
| 12 | var log_err_count: usize = 0; | 12 | var log_err_count: usize = 0; |
| 13 | 13 | ||
| 14 | var args_buffer: [std.fs.MAX_PATH_BYTES + std.mem.page_size]u8 = undefined; | ||
| 15 | var args_allocator = std.heap.FixedBufferAllocator.init(&args_buffer); | ||
| 16 | |||
| 14 | pub fn main() anyerror!void { | 17 | pub fn main() anyerror!void { |
| 18 | const args = std.process.argsAlloc(&args_allocator.allocator) catch { | ||
| 19 | @panic("Too many bytes passed over the CLI to the test runner"); | ||
| 20 | }; | ||
| 21 | std.testing.zig_exe_path = args[1]; | ||
| 22 | |||
| 15 | const test_fn_list = builtin.test_functions; | 23 | const test_fn_list = builtin.test_functions; |
| 16 | var ok_count: usize = 0; | 24 | var ok_count: usize = 0; |
| 17 | var skip_count: usize = 0; | 25 | var skip_count: usize = 0; |
lib/std/testing.zig+4| ... | @@ -21,6 +21,10 @@ pub var base_allocator_instance = std.heap.FixedBufferAllocator.init(""); | ... | @@ -21,6 +21,10 @@ pub var base_allocator_instance = std.heap.FixedBufferAllocator.init(""); |
| 21 | /// TODO https://github.com/ziglang/zig/issues/5738 | 21 | /// TODO https://github.com/ziglang/zig/issues/5738 |
| 22 | pub var log_level = std.log.Level.warn; | 22 | pub var log_level = std.log.Level.warn; |
| 23 | 23 | ||
| 24 | /// This is available to any test that wants to execute Zig in a child process. | ||
| 25 | /// It will be the same executable that is running `zig test`. | ||
| 26 | pub var zig_exe_path: []const u8 = undefined; | ||
| 27 | |||
| 24 | /// This function is intended to be used only in tests. It prints diagnostics to stderr | 28 | /// This function is intended to be used only in tests. It prints diagnostics to stderr |
| 25 | /// and then aborts when actual_error_union is not expected_error. | 29 | /// and then aborts when actual_error_union is not expected_error. |
| 26 | pub fn expectError(expected_error: anyerror, actual_error_union: anytype) void { | 30 | pub fn expectError(expected_error: anyerror, actual_error_union: anytype) void { |
src/main.zig+3-1| ... | @@ -1828,7 +1828,9 @@ fn buildOutputType( | ... | @@ -1828,7 +1828,9 @@ fn buildOutputType( |
| 1828 | else => unreachable, | 1828 | else => unreachable, |
| 1829 | } | 1829 | } |
| 1830 | } | 1830 | } |
| 1831 | try argv.append(exe_path); | 1831 | try argv.appendSlice(&[_][]const u8{ |
| 1832 | exe_path, self_exe_path, | ||
| 1833 | }); | ||
| 1832 | } else { | 1834 | } else { |
| 1833 | for (test_exec_args.items) |arg| { | 1835 | for (test_exec_args.items) |arg| { |
| 1834 | try argv.append(arg orelse exe_path); | 1836 | try argv.append(arg orelse exe_path); |