In test_clang_cpp, if CalledProcessError is raised, log the stderr for easier debugging (#5595)

Found this is very useful for debugging since otherwise it's hard to
tell what happened in the process.
Based on similar logic in `scripts/target_determinator.py`.
This commit is contained in:
Boaz Brickner
2025-06-04 06:39:02 +00:00
committed by GitHub
parent 5435877745
commit fb33f7c481
+10 -7
View File
@@ -86,13 +86,16 @@ class LLVMSymlinksTest(unittest.TestCase):
# the test file and writing to stdout. We define a macro that we'll
# check is expanded.
bin = self.install_root / "lib/carbon/llvm/bin/clang-cpp"
run = subprocess.run(
[bin, "-D", "TEST=SUCCESS", text_file, "-"],
check=True,
capture_output=True,
text=True,
)
try:
run = subprocess.run(
[bin, "-D", "TEST=SUCCESS", text_file, "-"],
check=True,
capture_output=True,
text=True,
)
except subprocess.CalledProcessError as err:
print(err.stderr, file=sys.stderr)
raise
self.assertEqual(run.stderr, "")
self.assertRegex(run.stdout, r"(^|\n)SUCCESS\n")