diff options
| author | Loris Cro <kappaloris@gmail.com> | 2025-07-25 17:38:36 +0200 |
|---|---|---|
| committer | Matthew Lugg <mlugg@mlugg.co.uk> | 2025-07-30 22:40:36 +0100 |
| commit | de23ccfad1630e30d5b5ea1278ab2f375f987568 (patch) | |
| tree | eb91febc2b2b1f5d153a8657cf83fdf8a2206aec /lib/std/Build | |
| parent | eb1a4970dae76b49fe8cf1fa792a571cfebed86d (diff) | |
| download | zig-de23ccfad1630e30d5b5ea1278ab2f375f987568.tar.gz zig-de23ccfad1630e30d5b5ea1278ab2f375f987568.zip | |
build system: print captured stderr on Run step failure
when a Run step that captures stderr fails, no output from it is visible
by the user and, since the step failed, any downstream step that would
process the captured stream will not run, making it impossible for the
user to see the stderr output from the failed process invocation, which
makes for a frustrating puzzle when this happens in CI.
Diffstat (limited to 'lib/std/Build')
| -rw-r--r-- | lib/std/Build/Step/Run.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/std/Build/Step/Run.zig b/lib/std/Build/Step/Run.zig index 57f5d73f0c..819fc6745d 100644 --- a/lib/std/Build/Step/Run.zig +++ b/lib/std/Build/Step/Run.zig @@ -1391,6 +1391,16 @@ fn runCommand( } }, else => { + // On failure, print stderr if captured. + const bad_exit = switch (result.term) { + .Exited => |code| code != 0, + .Signal, .Stopped, .Unknown => true, + }; + + if (bad_exit) if (result.stdio.stderr) |err| { + try step.addError("stderr:\n{s}", .{err}); + }; + try step.handleChildProcessTerm(result.term, cwd, final_argv); }, } |
