From fb33f7c4812b9884d253b80d65ddb602d0fefdae Mon Sep 17 00:00:00 2001 From: Boaz Brickner Date: Wed, 4 Jun 2025 08:39:02 +0200 Subject: [PATCH] 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`. --- toolchain/install/llvm_symlinks_test.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/toolchain/install/llvm_symlinks_test.py b/toolchain/install/llvm_symlinks_test.py index 4621da6339aa..8e1a20b53c58 100644 --- a/toolchain/install/llvm_symlinks_test.py +++ b/toolchain/install/llvm_symlinks_test.py @@ -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")