| ... | @@ -1357,23 +1357,16 @@ test "build and call child_process" { | ... | @@ -1357,23 +1357,16 @@ test "build and call child_process" { |
| 1357 | var it = try std.process.argsWithAllocator(allocator); | 1357 | var it = try std.process.argsWithAllocator(allocator); |
| 1358 | defer it.deinit(); // no-op unless WASI or Windows | 1358 | defer it.deinit(); // no-op unless WASI or Windows |
| 1359 | const testargs = try testing.getTestArgs(&it); | 1359 | const testargs = try testing.getTestArgs(&it); |
| 1360 | | | |
| 1361 | var tmp = testing.tmpDir(.{ .no_follow = true }); // ie zig-cache/tmp/8DLgoSEqz593PAEE | 1360 | var tmp = testing.tmpDir(.{ .no_follow = true }); // ie zig-cache/tmp/8DLgoSEqz593PAEE |
| 1362 | defer tmp.cleanup(); | 1361 | defer tmp.cleanup(); |
| 1363 | const tmpdirpath = try tmp.getFullPath(allocator); | | |
| 1364 | defer allocator.free(tmpdirpath); | | |
| 1365 | const child_name = "child"; // no need for suffixes (.exe, .wasm) due to '-femit-bin' | 1362 | const child_name = "child"; // no need for suffixes (.exe, .wasm) due to '-femit-bin' |
| 1366 | const suffix_zig = ".zig"; | 1363 | const zigfile_path = try tmp.writeZigFile(allocator, childstr, child_name); |
| 1367 | const child_path = try fs.path.join(allocator, &[_][]const u8{ tmpdirpath, child_name }); | 1364 | defer allocator.free(zigfile_path); |
| 1368 | defer allocator.free(child_path); | | |
| 1369 | const child_zig = try mem.concat(allocator, u8, &[_][]const u8{ child_path, suffix_zig }); | | |
| 1370 | defer allocator.free(child_zig); | | |
| 1371 | | | |
| 1372 | try tmp.dir.writeFile("child.zig", childstr); | | |
| 1373 | try testing.buildExe(testargs.zigexec, child_zig, child_path); | | |
| 1374 | | 1365 | |
| | 1366 | const binary = zigfile_path[0 .. zigfile_path.len - 4]; // '.zig' is 4 characters |
| | 1367 | try testing.buildExe(testargs.zigexec, zigfile_path, binary); |
| 1375 | // spawn compiled file as child_process with argument 'hello world' + expect success | 1368 | // spawn compiled file as child_process with argument 'hello world' + expect success |
| 1376 | const args = [_][]const u8{ child_path, "hello world" }; | 1369 | const args = [_][]const u8{ binary, "hello world" }; |
| 1377 | var child_proc = try ChildProcess.init(&args, allocator); | 1370 | var child_proc = try ChildProcess.init(&args, allocator); |
| 1378 | defer child_proc.deinit(); | 1371 | defer child_proc.deinit(); |
| 1379 | const ret_val = try child_proc.spawnAndWait(); | 1372 | const ret_val = try child_proc.spawnAndWait(); |