[llvm] [AMDGPU][test] fix the error case in update_mc_test_check script (PR #112731)
Brox Chen via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 18 08:56:34 PDT 2024
================
@@ -32,7 +31,20 @@ def invoke_tool(exe, cmd_args, testline, verbose=False):
cmd = 'echo "' + testline + '" | ' + exe + " " + args
if verbose:
print("Command: ", cmd)
- out = subprocess.check_output(cmd, shell=True)
+
+ # if not is used in runline, the command might or might not
+ # return non-zero code on a single line run
+ try:
+ out = subprocess.check_output(cmd, shell=True, stderr=subprocess.DEVNULL)
+ except:
+ if prefix_not:
+ cmd = 'echo "' + testline + '" | ' + "not " + exe + " " + args
+ if verbose:
+ print("Command: ", cmd)
+ out = subprocess.check_output(cmd, shell=True, stderr=subprocess.DEVNULL)
----------------
broxigarchen wrote:
When the runline is start a `not`, the overall file is expected to fail and return a non-zero exit code. However, when the whole test is split and executed line-by-line, each line might, or might not fail and we don't know about it.
Thus I launch two run of the command, one with `not` one without `not`, and we take the output when it gives zero exit code.
https://github.com/llvm/llvm-project/pull/112731
More information about the llvm-commits
mailing list