[update_mc_test_checks.py] Report llvm-mc errors on failure#199820
Conversation
Created using spr 1.3.8-beta.1
|
This is a stacked pull request managed by spr. The following pull requests must be merged before this one:
|
|
@llvm/pr-subscribers-testing-tools Author: Alexander Richardson (arichardson) ChangesPrinting the llvm-mc stderr when the script fails is helpful to Full diff: https://github.com/llvm/llvm-project/pull/199820.diff 3 Files Affected:
diff --git a/llvm/test/tools/UpdateTestChecks/update_mc_test_checks/Inputs/error_reporting.s b/llvm/test/tools/UpdateTestChecks/update_mc_test_checks/Inputs/error_reporting.s
new file mode 100644
index 0000000000000..9f303b19c1cd7
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_mc_test_checks/Inputs/error_reporting.s
@@ -0,0 +1,3 @@
+// RUN: llvm-mc -triple=riscv64 %s | FileCheck %s
+
+add x1, x2, x3, x4
diff --git a/llvm/test/tools/UpdateTestChecks/update_mc_test_checks/error-reporting.test b/llvm/test/tools/UpdateTestChecks/update_mc_test_checks/error-reporting.test
new file mode 100644
index 0000000000000..fca1e753762b3
--- /dev/null
+++ b/llvm/test/tools/UpdateTestChecks/update_mc_test_checks/error-reporting.test
@@ -0,0 +1,11 @@
+# REQUIRES: riscv-registered-target
+## Check that update_mc_test_checks prints a useful error message with stderr when the command fails
+
+# RUN: cp -f %S/Inputs/error_reporting.s %t.s
+# RUN: not %update_mc_test_checks %t.s 2>&1 | FileCheck %s
+
+# CHECK: Error running command: {{.*}}llvm-mc{{.*}} -triple=riscv64
+# CHECK: Exit code: 1
+# CHECK: Stderr:
+# CHECK: error: expected
+# CHECK: Error: Failed to update test
diff --git a/llvm/utils/update_mc_test_checks.py b/llvm/utils/update_mc_test_checks.py
index 565e1ad085dff..d60d1c2df5e0e 100755
--- a/llvm/utils/update_mc_test_checks.py
+++ b/llvm/utils/update_mc_test_checks.py
@@ -79,17 +79,24 @@ def invoke_tool(
if verbose:
print("Command: ", cmd)
- out = subprocess.run(
- cmd,
- shell=True,
- input=full_input.encode(),
- check=check_rc,
- stdout=subprocess.PIPE,
- stderr=subprocess.DEVNULL,
- ).stdout
+ try:
+ completed = subprocess.run(
+ cmd,
+ shell=True,
+ input=full_input.encode(),
+ check=check_rc,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+ except subprocess.CalledProcessError as e:
+ sys.stderr.write(f"Error running command: {cmd}\n")
+ sys.stderr.write(f"Exit code: {e.returncode}\n")
+ if e.stderr:
+ sys.stderr.write(f"Stderr:\n{e.stderr.decode(errors='replace')}\n")
+ raise e
# Fix line endings to unix CR style.
- return out.decode().replace("\r\n", "\n")
+ return completed.stdout.decode().replace("\r\n", "\n")
def isRunLine(l):
|
🪟 Windows x64 Test Results
Failed Tests(click on a test name to see its output) LLVMLLVM.tools/llvm-symbolizer/wasm-basic.sIf these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
🐧 Linux x64 Test Results
Failed Tests(click on a test name to see its output) LLVMLLVM.tools/llvm-symbolizer/wasm-basic.s (Likely Already Failing)This test is already failing at the base commit.If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the |
Printing the llvm-mc stderr when the script fails is helpful to
determine whether it was an issue with the input or the update script.