From c80249b1b24729f11e9422dbb469d24e292e667c Mon Sep 17 00:00:00 2001 From: Connie Zhu Date: Mon, 12 Aug 2024 20:45:06 +0000 Subject: [PATCH 1/5] [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 0000000000000..24a99f4b9547a --- /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 8f2b865f333a5..bb67388e608d9 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 Date: Thu, 15 Aug 2024 18:10:29 +0000 Subject: [PATCH 2/5] [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 0000000000000..2e32afd88f166 --- /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 24a99f4b9547a..486e90c2fd01a 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 bb67388e608d9..19ba0e0bc7873 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) From 291f0c6925bfe8d1860b85a3167b1c3a003c635a Mon Sep 17 00:00:00 2001 From: Connie Zhu Date: Thu, 15 Aug 2024 19:38:01 +0000 Subject: [PATCH 3/5] [llvm-lit][test] Updated nested curly brace test --- llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 486e90c2fd01a..ede974de09ff2 100644 --- a/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt +++ b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt @@ -12,9 +12,8 @@ # 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 +# RUN: { echo foo > %t/temp.txt; { echo bar; echo baz; }; cat %t/temp.txt; } | FileCheck --check-prefix=NESTED %s -# NESTED: foo # NESTED: bar # NESTED: baz +# NESTED: foo From fb1c31506563c62cd9f7a42e8aea003c16f1cd90 Mon Sep 17 00:00:00 2001 From: Connie Zhu Date: Thu, 15 Aug 2024 19:38:34 +0000 Subject: [PATCH 4/5] [llvm-lit][test] Moved fail tests into individual files This patch moves tests that check for errors into separate files so that the each error can be accounted for. --- .../Inputs/shtest-shell/curly-brace-close-only.txt | 2 ++ .../tests/Inputs/shtest-shell/curly-brace-error.txt | 7 ------- .../Inputs/shtest-shell/curly-brace-open-only.txt | 2 ++ llvm/utils/lit/tests/shtest-shell.py | 12 +++++++++--- 4 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-close-only.txt delete mode 100644 llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-error.txt create mode 100644 llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-open-only.txt diff --git a/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-close-only.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-close-only.txt new file mode 100644 index 0000000000000..35c846847d2f4 --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-close-only.txt @@ -0,0 +1,2 @@ +## Test closing brace without open brace. +# RUN: echo foo; } 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 deleted file mode 100644 index 2e32afd88f166..0000000000000 --- a/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-error.txt +++ /dev/null @@ -1,7 +0,0 @@ -## 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-open-only.txt b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-open-only.txt new file mode 100644 index 0000000000000..ce04704f3c33e --- /dev/null +++ b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace-open-only.txt @@ -0,0 +1,2 @@ +## Test open brace without closing brace. +# RUN: { echo foo diff --git a/llvm/utils/lit/tests/shtest-shell.py b/llvm/utils/lit/tests/shtest-shell.py index 19ba0e0bc7873..bc34df9c3f9a7 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 --dump-input-context=1000 +# RUN: FileCheck --input-file %t.out %s # # Test again in non-UTF shell to catch potential errors with python 2 seen # on stdout-encoding.txt @@ -28,7 +28,13 @@ # CHECK: PASS: shtest-shell :: continuations.txt -# CHECK: FAIL: shtest-shell :: curly-brace-error.txt +# CHECK: FAIL: shtest-shell :: curly-brace-close-only.txt +# CHECK: # executed command: '}' +# CHECK-NEXT: # .---command stderr------------ +# CHECK-NEXT: # | '}': command not found +# CHECK: error: command failed with exit status: 127 + +# CHECK: FAIL: shtest-shell :: curly-brace-open-only.txt # CHECK: # executed command: '{' echo foo # CHECK-NEXT: # .---command stderr------------ # CHECK-NEXT: # | '{': command not found @@ -647,4 +653,4 @@ # CHECK: PASS: shtest-shell :: valid-shell.txt # CHECK: Unresolved Tests (1) -# CHECK: Failed Tests (38) +# CHECK: Failed Tests (39) From c1b5dd0446d2bd6f5fa2ee7b5c7d3cf8775d8cf7 Mon Sep 17 00:00:00 2001 From: Connie Zhu Date: Thu, 15 Aug 2024 20:57:40 +0000 Subject: [PATCH 5/5] [llvm-lit][test][NFC] Formatting changes --- .../lit/tests/Inputs/shtest-shell/curly-brace.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 ede974de09ff2..69b6e75fe79b9 100644 --- a/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt +++ b/llvm/utils/lit/tests/Inputs/shtest-shell/curly-brace.txt @@ -8,12 +8,12 @@ ## Test two commands inside curly brace. # RUN: { echo foo; echo bar; } | FileCheck --check-prefix=TWO-CMDS %s -# TWO-CMDS: foo -# TWO-CMDS: bar +# TWO-CMDS: foo +# TWO-CMDS-NEXT: bar ## Test nested curly brace. -# RUN: { echo foo > %t/temp.txt; { echo bar; echo baz; }; cat %t/temp.txt; } | FileCheck --check-prefix=NESTED %s +# RUN: { echo foo > %t; { echo bar; echo baz; }; cat %t; } | FileCheck --check-prefix=NESTED %s -# NESTED: bar -# NESTED: baz -# NESTED: foo +# NESTED: bar +# NESTED-NEXT: baz +# NESTED-NEXT: foo