[llvm] [llvm-lit][test] Precommit tests for curly braces in lit internal shell (PR #102976)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 15 11:11:26 PDT 2024
https://github.com/connieyzhu updated https://github.com/llvm/llvm-project/pull/102976
>From c80249b1b24729f11e9422dbb469d24e292e667c Mon Sep 17 00:00:00 2001
From: Connie Zhu <connieyzhu at google.com>
Date: Mon, 12 Aug 2024 20:45:06 +0000
Subject: [PATCH 1/2] [llvm-lit][test] Precommit tests for curly braces in lit
internal shell
This patch creates tests to check lit's failure to execute curly braces
{}.
---
.../lit/tests/Inputs/shtest-shell/curly-brace.txt | 12 ++++++++++++
llvm/utils/lit/tests/shtest-shell.py | 8 +++++++-
2 files changed, 19 insertions(+), 1 deletion(-)
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt
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..24a99f4b9547ad
--- /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 %s
+
+# ONE-CMD: bar
+
+## Test two commands inside curly brace.
+# RUN: { echo foo; echo bar; } | FileCheck --check-prefix=TWO-CMDS %s
+
+# 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 8f2b865f333a57..bb67388e608d93 100644
--- a/llvm/utils/lit/tests/shtest-shell.py
+++ b/llvm/utils/lit/tests/shtest-shell.py
@@ -28,6 +28,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
@@ -635,4 +641,4 @@
# CHECK: PASS: shtest-shell :: valid-shell.txt
# CHECK: Unresolved Tests (1)
-# CHECK: Failed Tests (36)
+# CHECK: Failed Tests (37)
>From 011441cb3e3ed8f64e9b5491d8135fcdcb6bfcdf Mon Sep 17 00:00:00 2001
From: Connie Zhu <connieyzhu at google.com>
Date: Thu, 15 Aug 2024 18:10:29 +0000
Subject: [PATCH 2/2] [llvm-lit][test] Added tests for syntax errors and nested
braces
---
.../tests/Inputs/shtest-shell/curly-brace-error.txt | 7 +++++++
.../lit/tests/Inputs/shtest-shell/curly-brace.txt | 10 +++++++++-
llvm/utils/lit/tests/shtest-shell.py | 10 ++++++++--
3 files changed, 24 insertions(+), 3 deletions(-)
create mode 100644 llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-error.txt
diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-error.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-error.txt
new file mode 100644
index 00000000000000..2e32afd88f166c
--- /dev/null
+++ b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-error.txt
@@ -0,0 +1,7 @@
+## Test errors on curly brace syntax.
+
+## Test open brace without closing brace.
+# RUN: { echo foo
+
+## Test closing brace without open brace.
+# RUN: echo foo; }
diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt
index 24a99f4b9547ad..486e90c2fd01ae 100644
--- a/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt
+++ b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt
@@ -9,4 +9,12 @@
# RUN: { echo foo; echo bar; } | FileCheck --check-prefix=TWO-CMDS %s
# TWO-CMDS: foo
-# TWO-CMDS: bar
\ No newline at end of file
+# TWO-CMDS: bar
+
+## Test nested curly brace.
+# RUN: { echo foo; { echo bar; echo baz; }; } | FileCheck --check-prefix=NESTED %s
+# RUN: { { echo foo; echo bar; }; echo baz; } | FileCheck --check-prefix=NESTED %s
+
+# NESTED: foo
+# NESTED: bar
+# NESTED: baz
diff --git a/llvm/utils/lit/tests/shtest-shell.py b/llvm/utils/lit/tests/shtest-shell.py
index bb67388e608d93..19ba0e0bc78735 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
@@ -28,6 +28,12 @@
# CHECK: PASS: shtest-shell :: continuations.txt
+# CHECK: FAIL: shtest-shell :: curly-brace-error.txt
+# CHECK: # executed command: '{' echo foo
+# CHECK-NEXT: # .---command stderr------------
+# CHECK-NEXT: # | '{': command not found
+# CHECK: error: command failed with exit status: 127
+
# CHECK: FAIL: shtest-shell :: curly-brace.txt
# CHECK: # executed command: '{' echo bar
# CHECK-NEXT: # .---command stderr------------
@@ -641,4 +647,4 @@
# CHECK: PASS: shtest-shell :: valid-shell.txt
# CHECK: Unresolved Tests (1)
-# CHECK: Failed Tests (37)
+# CHECK: Failed Tests (38)
More information about the llvm-commits
mailing list