-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[llvm-lit][test] Precommit tests for curly braces in lit internal shell #102976
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-testing-tools Author: Connie (connieyzhu) ChangesThis patch creates tests to check lit's failure to execute curly braces {}. This is a prequisite patch to #102830. Full diff: https://github.com/llvm/llvm-project/pull/102976.diff 2 Files Affected:
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)
|
575eb26
to
6a0796d
Compare
CC: @ilovepi @petrhosek @jh7370 Hi there, I'm writing some tests for curly braces in lit's internal shell before I implement the functionality in #102830. I wasn't sure if I should write more in-depth tests in this patch, since the same syntax error will be given for every test at the moment, or if I should just include more tests in my later patch once I have implemented the proper functionality. |
6a0796d
to
7267d01
Compare
There's some value in showing that each test used to fail, but now passes. I'm not sure it needs to be particularly exhaustive, but whatever basic tests you're considering are probably reasonable to include in this patch. Typically its nice if none of the RUN lines change, but you can easily spot a difference in the test behavior. I know I appreciate that in the middle or backend tests I review. |
This patch creates tests to check lit's failure to execute curly braces {}.
7267d01
to
c80249b
Compare
# RUN: { echo foo; { echo bar; echo baz; }; } | FileCheck --check-prefix=NESTED %s | ||
# RUN: { { echo foo; echo bar; }; echo baz; } | FileCheck --check-prefix=NESTED %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is checking things well enough. The nested {...}
probably needs to result in something that's distinct from the regular case. As written, you cant distinguish the nested version from the un-nested version. Maybe you can use a |
or file redirection + cat
?
llvm/utils/lit/tests/shtest-shell.py
Outdated
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover from debugging?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, forgot to delete that. I will remove it in my next change.
This patch moves tests that check for errors into separate files so that the each error can be accounted for.
# TWO-CMDS: bar | ||
|
||
## Test nested curly brace. | ||
# RUN: { echo foo > %t/temp.txt; { echo bar; echo baz; }; cat %t/temp.txt; } | FileCheck --check-prefix=NESTED %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a mkdir %t
, so I'm not sure this works as intended. If you don't need other files, you can just use %t
.
# NESTED: bar | ||
# NESTED: baz | ||
# NESTED: foo |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# NESTED: bar | |
# NESTED: baz | |
# NESTED: foo | |
# NESTED: bar | |
# NESTED-NEXT: baz | |
# NESTED-NEXT: foo |
I'm not opposed to this PR being developed, but I don't want it and the follow-on PR landed without the RFC discussion I've requested in the source issue: as noted there, I'm not convinced this functionality is needed in lit (not going to elaborate further here, to avoid splitting the discussion). |
This patch creates tests to check lit's failure to execute curly braces {}. This is a prequisite patch to #102830.