| ... | @@ -2188,6 +2188,16 @@ fn buildOutputType( | ... | @@ -2188,6 +2188,16 @@ fn buildOutputType( |
| 2188 | warn("--watch is not recommended with the stage1 backend; it leaks memory and is not capable of incremental compilation", .{}); | 2188 | warn("--watch is not recommended with the stage1 backend; it leaks memory and is not capable of incremental compilation", .{}); |
| 2189 | } | 2189 | } |
| 2190 | | 2190 | |
| | 2191 | if (test_exec_args.items.len == 0 and object_format == .c) default_exec_args: { |
| | 2192 | // Default to using `zig run` to execute the produced .c code from `zig test`. |
| | 2193 | const c_code_loc = emit_bin_loc orelse break :default_exec_args; |
| | 2194 | const c_code_directory = c_code_loc.directory orelse comp.bin_file.options.emit.?.directory; |
| | 2195 | const c_code_path = try fs.path.join(arena, &[_][]const u8{ |
| | 2196 | c_code_directory.path orelse ".", c_code_loc.basename, |
| | 2197 | }); |
| | 2198 | try test_exec_args.appendSlice(&.{ self_exe_path, "run", "-lc", c_code_path }); |
| | 2199 | } |
| | 2200 | |
| 2191 | const run_or_test = switch (arg_mode) { | 2201 | const run_or_test = switch (arg_mode) { |
| 2192 | .run => true, | 2202 | .run => true, |
| 2193 | .zig_test => !test_no_exec, | 2203 | .zig_test => !test_no_exec, |