[llvm] [llvm-lit][test] Precommit tests for curly braces in lit internal shell (PR #102976)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 13:50:19 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-testing-tools

Author: Connie (connieyzhu)

<details>
<summary>Changes</summary>

This patch creates tests to check lit's failure to execute curly braces {}. This is a prequisite patch to https://github.com/llvm/llvm-project/pull/102830.

---
Full diff: https://github.com/llvm/llvm-project/pull/102976.diff


2 Files Affected:

- (added) llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt (+12) 
- (modified) llvm/utils/lit/tests/shtest-shell.py (+8-2) 


``````````diff
diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt
new file mode 100644
index 00000000000000..b554b9772db89d
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt
@@ -0,0 +1,12 @@
+## Test curly braces used in grouping commands.
+
+## Test one command inside curly brace.
+# RUN: { echo bar; } | FileCheck --check-prefix=ONE-CMD
+
+# ONE-CMD: bar
+
+## Test two commands inside curly brace.
+# RUN: { echo foo; echo bar; } | FileCheck --check-prefix=TWO-CMDS
+
+# TWO-CMDS: foo
+# TWO-CMDS: bar
\ No newline at end of file
diff --git a/llvm/utils/lit/tests/shtest-shell.py b/llvm/utils/lit/tests/shtest-shell.py
index 86851194880620..a050a57eea64bb 100644
--- a/llvm/utils/lit/tests/shtest-shell.py
+++ b/llvm/utils/lit/tests/shtest-shell.py
@@ -4,7 +4,7 @@
 # FIXME: Temporarily dump test output so we can debug failing tests on
 # buildbots.
 # RUN: cat %t.out
-# RUN: FileCheck --input-file %t.out %s
+# RUN: FileCheck --input-file %t.out %s --dump-input-context=1000
 #
 # Test again in non-UTF shell to catch potential errors with python 2 seen
 # on stdout-encoding.txt
@@ -44,6 +44,12 @@
 
 # CHECK: PASS: shtest-shell :: continuations.txt
 
+# CHECK: FAIL: shtest-shell :: curly-brace.txt
+# CHECK: # executed command: '{' echo bar
+# CHECK-NEXT: # .---command stderr------------
+# CHECK-NEXT: # | '{': command not found
+# CHECK: error: command failed with exit status: 127
+
 # CHECK: PASS: shtest-shell :: dev-null.txt
 
 #      CHECK: FAIL: shtest-shell :: diff-b.txt
@@ -651,4 +657,4 @@
 
 # CHECK: PASS: shtest-shell :: valid-shell.txt
 # CHECK: Unresolved Tests (1)
-# CHECK: Failed Tests (38)
+# CHECK: Failed Tests (39)

``````````

</details>


https://github.com/llvm/llvm-project/pull/102976


More information about the llvm-commits mailing list