Skip to content

Commit 0c19a81

Browse files
authored
Merge pull request ClangBuiltLinux#318 from nathanchance/run-show-errors-with-capture_output
tc_build: builder: Show output of failed commands with capture_output=True
2 parents 5521f94 + 0038bc5 commit 0c19a81

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tc_build/builder.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,16 @@ def run_cmd(self, cmd, capture_output=False, cwd=None):
3636
if self.show_commands:
3737
# Acts sort of like 'set -x' in bash
3838
print(f"$ {' '.join([shlex.quote(str(elem)) for elem in cmd])}", flush=True)
39-
return subprocess.run(cmd, capture_output=capture_output, check=True, cwd=cwd)
39+
try:
40+
return subprocess.run(cmd,
41+
capture_output=capture_output,
42+
check=True,
43+
cwd=cwd,
44+
text=True)
45+
except subprocess.CalledProcessError as err:
46+
if capture_output:
47+
if err.stdout:
48+
print(err.stdout)
49+
if err.stderr:
50+
print(err.stderr)
51+
raise err

0 commit comments

Comments
 (0)