aboutsummaryrefslogtreecommitdiff
path: root/llvm/utils/lit/tests/shtest-shell.py
diff options
context:
space:
mode:
authorJoel E. Denny <jdenny.ornl@gmail.com>2023-10-20 11:53:18 -0400
committerGitHub <noreply@github.com>2023-10-20 11:53:18 -0400
commit080fb3e5b73bcfd90f11335ff3d175cf3199f814 (patch)
tree47a74680d4c583a7e290a6e08c748a8c8fa011c9 /llvm/utils/lit/tests/shtest-shell.py
parent6795bfce4ded6abf2403db62a5fec89a8bcb256a (diff)
downloadllvm-080fb3e5b73bcfd90f11335ff3d175cf3199f814.zip
llvm-080fb3e5b73bcfd90f11335ff3d175cf3199f814.tar.gz
llvm-080fb3e5b73bcfd90f11335ff3d175cf3199f814.tar.bz2
[lit] Clean up internal shell parse errors with ScriptFatal (#68496)
Without this patch, the functions `executeScriptInternal` and thus `runOnce` in `llvm/utils/lit/lit/TestRunner.py` return either a tuple like `(out, err, exitCode, timeoutInfo)` or a `lit.Test.Result` object. They return the latter only when there's a lit internal shell parse error in a RUN line. In my opinion, a more straight-forward way to handle exceptional cases like that is to use python exceptions. For that purpose, this patch introduces `ScriptFatal`. Thus, this patch changes `executeScriptInternal` to always either return the tuple or raise the `ScriptFatal` exception. It updates `runOnce` and `libcxx/utils/libcxx/test/format.py` to catch the exception rather than check for the special return type. This patch also changes `runOnce` to convert the exception to a `Test.UNRESOLVED` result instead of `TEST.FAIL`. The former is the proper result for such a malformed test, for which a rerun (given an `ALLOW_RETRIES:`) serves no purpose. There are at least two benefits from this change. First, `_runShTest` no longer has to specially and cryptically handle this case to avoid unnecessary reruns. Second, an `XFAIL:` directive no longer hides such a failure [as we saw previously](https://reviews.llvm.org/D154987#4501125). To facilitate the `_runShTest` change, this patch inserts the internal shell parse error diagnostic into the format of the test's normal debug output rather than suppressing the latter entirely. That change is also important for [D154987](https://reviews.llvm.org/D154987), which proposes to reuse `ScriptFatal` for python compile errors in PYTHON lines or in `config.prologue`. In that case, the diagnostic might follow debugging output from the test's previous RUN or PYTHON lines, so suppressing the normal debug output would lose information.
Diffstat (limited to 'llvm/utils/lit/tests/shtest-shell.py')
-rw-r--r--llvm/utils/lit/tests/shtest-shell.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/utils/lit/tests/shtest-shell.py b/llvm/utils/lit/tests/shtest-shell.py
index a043582..8685119 100644
--- a/llvm/utils/lit/tests/shtest-shell.py
+++ b/llvm/utils/lit/tests/shtest-shell.py
@@ -561,10 +561,17 @@
# FIXME: The output here sucks.
#
-# CHECK: FAIL: shtest-shell :: error-1.txt
-# CHECK: *** TEST 'shtest-shell :: error-1.txt' FAILED ***
-# CHECK: shell parser error on RUN: at line 3: echo "missing quote
-# CHECK: ***
+# CHECK: UNRESOLVED: shtest-shell :: error-1.txt
+# CHECK-NEXT: *** TEST 'shtest-shell :: error-1.txt' FAILED ***
+# CHECK-NEXT: Exit Code: 1
+# CHECK-EMPTY:
+# CHECK-NEXT: Command Output (stdout):
+# CHECK-NEXT: --
+# CHECK-NEXT: # shell parser error on RUN: at line 3: echo "missing quote
+# CHECK-EMPTY:
+# CHECK-NEXT: --
+# CHECK-EMPTY:
+# CHECK-NEXT: ***
# CHECK: FAIL: shtest-shell :: error-2.txt
# CHECK: *** TEST 'shtest-shell :: error-2.txt' FAILED ***
@@ -643,4 +650,5 @@
# CHECK: ***
# CHECK: PASS: shtest-shell :: valid-shell.txt
-# CHECK: Failed Tests (39)
+# CHECK: Unresolved Tests (1)
+# CHECK: Failed Tests (38)