diff --git a/std/os/child_process.zig b/std/os/child_process.zig index 8c09f25be..bb5b2eb18 100644 --- a/std/os/child_process.zig +++ b/std/os/child_process.zig @@ -66,10 +66,9 @@ pub const ChildProcess = struct { break; } - // TODO oops! test (self.stdin) |*stdin| { stdin.close(); } - test (self.stdin) |*stdout| { stdout.close(); } - test (self.stdin) |*stderr| { stderr.close(); } + test (self.stdout) |*stdout| { stdout.close(); } + test (self.stderr) |*stderr| { stderr.close(); } // Write @maxValue(ErrInt) to the write end of the err_pipe. This is after // waitpid, so this write is guaranteed to be after the child diff --git a/test/tests.zig b/test/tests.zig index 354776140..97ae39309 100644 --- a/test/tests.zig +++ b/test/tests.zig @@ -195,6 +195,12 @@ pub const CompareOutputContext = struct { debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err)); }; + var stdout = Buffer.initNull(b.allocator); + var stderr = Buffer.initNull(b.allocator); + + %%(??child.stdout).readAll(&stdout); + %%(??child.stderr).readAll(&stderr); + const term = child.wait() %% |err| { debug.panic("Unable to spawn {}: {}\n", full_exe_path, @errorName(err)); }; @@ -211,11 +217,6 @@ pub const CompareOutputContext = struct { }, }; - var stdout = Buffer.initNull(b.allocator); - var stderr = Buffer.initNull(b.allocator); - - %%(??child.stdout).readAll(&stdout); - %%(??child.stderr).readAll(&stderr); if (!mem.eql(u8, self.expected_output, stdout.toSliceConst())) { %%io.stderr.printf( @@ -521,6 +522,12 @@ pub const CompileErrorContext = struct { debug.panic("Unable to spawn {}: {}\n", b.zig_exe, @errorName(err)); }; + var stdout_buf = Buffer.initNull(b.allocator); + var stderr_buf = Buffer.initNull(b.allocator); + + %%(??child.stdout).readAll(&stdout_buf); + %%(??child.stderr).readAll(&stderr_buf); + const term = child.wait() %% |err| { debug.panic("Unable to spawn {}: {}\n", b.zig_exe, @errorName(err)); }; @@ -537,11 +544,6 @@ pub const CompileErrorContext = struct { }, }; - var stdout_buf = Buffer.initNull(b.allocator); - var stderr_buf = Buffer.initNull(b.allocator); - - %%(??child.stdout).readAll(&stdout_buf); - %%(??child.stderr).readAll(&stderr_buf); const stdout = stdout_buf.toSliceConst(); const stderr = stderr_buf.toSliceConst(); @@ -783,6 +785,12 @@ pub const ParseHContext = struct { debug.panic("Unable to spawn {}: {}\n", b.zig_exe, @errorName(err)); }; + var stdout_buf = Buffer.initNull(b.allocator); + var stderr_buf = Buffer.initNull(b.allocator); + + %%(??child.stdout).readAll(&stdout_buf); + %%(??child.stderr).readAll(&stderr_buf); + const term = child.wait() %% |err| { debug.panic("Unable to spawn {}: {}\n", b.zig_exe, @errorName(err)); }; @@ -803,12 +811,6 @@ pub const ParseHContext = struct { }, }; - var stdout_buf = Buffer.initNull(b.allocator); - var stderr_buf = Buffer.initNull(b.allocator); - - %%(??child.stdout).readAll(&stdout_buf); - %%(??child.stderr).readAll(&stderr_buf); - const stdout = stdout_buf.toSliceConst(); const stderr = stderr_buf.toSliceConst();