14 changes: 6 additions & 8 deletions llvm/utils/lit/lit/cl_arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,23 @@ def parse_args():
"-v",
"--verbose",
dest="showOutput",
help="Show test output for failures",
help="For failed tests, show all output. For example, each command is"
" printed before it is executed, so the last printed command is the one"
" that failed.",
action="store_true",
)
format_group.add_argument(
"-vv",
"--echo-all-commands",
dest="echoAllCommands",
dest="showOutput",
help="Deprecated alias for -v.",
action="store_true",
help="Echo all commands as they are executed to stdout. In case of "
"failure, last command shown will be the failing one.",
)
format_group.add_argument(
"-a",
"--show-all",
dest="showAllOutput",
help="Display all commandlines and output",
help="Enable -v, but for all tests not just failed tests.",
action="store_true",
)
format_group.add_argument(
Expand Down Expand Up @@ -299,9 +300,6 @@ def parse_args():
opts = parser.parse_args(args)

# Validate command line options
if opts.echoAllCommands:
opts.showOutput = True

if opts.incremental:
print(
"WARNING: --incremental is deprecated. Failing tests now always run first."
Expand Down
1 change: 0 additions & 1 deletion llvm/utils/lit/lit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ def main(builtin_params={}):
order=opts.order,
params=params,
config_prefix=opts.configPrefix,
echo_all_commands=opts.echoAllCommands,
per_test_coverage=opts.per_test_coverage,
)

Expand Down
2 changes: 1 addition & 1 deletion llvm/utils/lit/tests/Inputs/lit-opts/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ config.suffixes = [".txt"]
config.test_format = lit.formats.ShTest()
config.test_source_root = None
config.test_exec_root = None
config.substitutions.append(("%var", lit_config.params.get("var", "")))
config.substitutions.append(("%var", lit_config.params.get("var", "default")))
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@
; REDEFINE: %{cflags} = -triple x86_64-apple-darwin10.6.0 -fopenmp-simd
; REDEFINE: %{fcflags} = -check-prefix=SIMD
; RUN: %{check}
; CHECK: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -triple x86_64-apple-darwin10.6.0 -fopenmp-simd -emit-llvm -o - {{.*}} | FileCheck -check-prefix=SIMD {{.*}}
; CHECK:# | %clang_cc1 -verify -fopenmp -fopenmp-version=51 -triple x86_64-apple-darwin10.6.0 -fopenmp-simd -emit-llvm -o - {{.*}} | FileCheck -check-prefix=SIMD {{.*}}

; REDEFINE: %{cflags} = -triple x86_64-unknown-linux-gnu -fopenmp-simd
; REDEFINE: %{fcflags} = -check-prefix=SIMD
; RUN: %{check}
; CHECK: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -triple x86_64-unknown-linux-gnu -fopenmp-simd -emit-llvm -o - {{.*}} | FileCheck -check-prefix=SIMD {{.*}}
; CHECK:# | %clang_cc1 -verify -fopenmp -fopenmp-version=51 -triple x86_64-unknown-linux-gnu -fopenmp-simd -emit-llvm -o - {{.*}} | FileCheck -check-prefix=SIMD {{.*}}

; REDEFINE: %{cflags} = -triple x86_64-apple-darwin10.6.0
; REDEFINE: %{fcflags} = -check-prefix=NO-SIMD
; RUN: %{check}
; CHECK: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -triple x86_64-apple-darwin10.6.0 -emit-llvm -o - {{.*}} | FileCheck -check-prefix=NO-SIMD {{.*}}
; CHECK:# | %clang_cc1 -verify -fopenmp -fopenmp-version=51 -triple x86_64-apple-darwin10.6.0 -emit-llvm -o - {{.*}} | FileCheck -check-prefix=NO-SIMD {{.*}}

; REDEFINE: %{cflags} = -triple x86_64-unknown-linux-gnu
; REDEFINE: %{fcflags} = -check-prefix=NO-SIMD
; RUN: %{check}
; CHECK: %clang_cc1 -verify -fopenmp -fopenmp-version=51 -triple x86_64-unknown-linux-gnu -emit-llvm -o - {{.*}} | FileCheck -check-prefix=NO-SIMD {{.*}}
; CHECK:# | %clang_cc1 -verify -fopenmp -fopenmp-version=51 -triple x86_64-unknown-linux-gnu -emit-llvm -o - {{.*}} | FileCheck -check-prefix=NO-SIMD {{.*}}

; CHECK: Passed: 1
8 changes: 4 additions & 4 deletions llvm/utils/lit/tests/Inputs/shtest-define/expansion-order.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#
# REDEFINE: %{global:greeting}=Hello
# RUN: %{global:echo}
# CHECK: GLOBAL: Hello World
# CHECK:# | GLOBAL: Hello World

# We can redefine the test suite config's substitutions multiple times. Again,
# the expansion order remains the same (%{global:echo} before %{global:greeting}
Expand All @@ -17,7 +17,7 @@
# REDEFINE: %{global:greeting}=Goodbye %{global:what}
# REDEFINE: %{global:what}=Sleep
# RUN: %{global:echo}
# CHECK: GLOBAL: Goodbye Sleep Sleep
# CHECK:# | GLOBAL: Goodbye Sleep Sleep

# A new local substitution is prepended to the substitution list so that it can
# depend on all substitutions that were defined previously, including those from
Expand All @@ -26,7 +26,7 @@
# DEFINE: %{local:greeting}=Hey %{global:what}
# DEFINE: %{local:echo}=echo "LOCAL: %{local:greeting} %{global:what}"
# RUN: %{local:echo}
# CHECK: LOCAL: Hey Sleep Sleep
# CHECK:# | LOCAL: Hey Sleep Sleep

# As for substitutions from the test suite config, redefining local
# substitutions should not change the expansion order. Again, the expansion
Expand All @@ -36,6 +36,6 @@
# REDEFINE: %{local:greeting}=So Long %{global:what}
# REDEFINE: %{global:what}=World
# RUN: %{local:echo}
# CHECK: LOCAL: So Long World World
# CHECK:# | LOCAL: So Long World World

# CHECK: Passed: 1
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
# Does it work as expected directly in RUN lines?
# RUN: echo %(line), %(line-1), %(line+2)
# CHECK: [[#@LINE-1]], [[#@LINE-2]], [[#@LINE+1]]
# CHECK:# | [[#@LINE-1]], [[#@LINE-2]], [[#@LINE+1]]

# %(line) substitutions refer to the original DEFINE/REDEFINE line not the RUN
# line they eventually appear within.
#
# DEFINE: %{lines} = %(line)
# RUN: echo '%{lines}'
# CHECK: [[#@LINE-2]]
# CHECK:# | [[#@LINE-2]]
#
# REDEFINE: %{lines} = %(line), \
# REDEFINE: %(line), \
# REDEFINE: %(line)
# RUN: echo '%{lines}'
# CHECK: [[#@LINE-4]], [[#@LINE-3]], [[#@LINE-2]]
# CHECK:# | [[#@LINE-4]], [[#@LINE-3]], [[#@LINE-2]]

# %(line+N) and %{line-N) should work too.
#
# DEFINE: %{lines-rel} = %(line+1), \
# DEFINE: %(line), \
# DEFINE: %(line-1)
# RUN: echo '%{lines-rel}'
# CHECK: [[#@LINE-3]], [[#@LINE-3]], [[#@LINE-3]]
# CHECK:# | [[#@LINE-3]], [[#@LINE-3]], [[#@LINE-3]]
#
# REDEFINE: %{lines-rel} = %(line+5), \
# REDEFINE: %(line+0), \
# REDEFINE: %(line-10)
# RUN: echo '%{lines-rel}'
# CHECK: [[#@LINE+1]], [[#@LINE-3]], [[#@LINE-12]]
# CHECK:# | [[#@LINE+1]], [[#@LINE-3]], [[#@LINE-12]]

# CHECK: Passed: 1
12 changes: 6 additions & 6 deletions llvm/utils/lit/tests/Inputs/shtest-define/name-chars.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
# DEFINE: %{abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789} = ok
# RUN: echo '%{abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789}'
# CHECK: ok
# CHECK:# | ok

# DEFINE: %{FooBar} = ok at %(line)
# RUN: echo '%{FooBar}'
# CHECK: ok at [[#@LINE - 2]]
# CHECK:# | ok at [[#@LINE - 2]]

# DEFINE: %{fooBar} = ok at %(line)
# RUN: echo '%{fooBar}'
# CHECK: ok at [[#@LINE - 2]]
# CHECK:# | ok at [[#@LINE - 2]]

# DEFINE: %{foo-bar-} = ok at %(line)
# RUN: echo '%{foo-bar-}'
# CHECK: ok at [[#@LINE - 2]]
# CHECK:# | ok at [[#@LINE - 2]]

# DEFINE: %{foo:bar:} = ok at %(line)
# RUN: echo '%{foo:bar:}'
# CHECK: ok at [[#@LINE - 2]]
# CHECK:# | ok at [[#@LINE - 2]]

# DEFINE: %{_foo_bar_} = ok at %(line)
# RUN: echo '%{_foo_bar_}'
# CHECK: ok at [[#@LINE - 2]]
# CHECK:# | ok at [[#@LINE - 2]]

# CHECK: Passed: 1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# RUN: echo '%{outer}'

# CHECK-NON-RECUR:%{inner}
# CHECK-RECUR:expanded
# CHECK-NON-RECUR:# | %{inner}
# CHECK-RECUR:# | expanded

# CHECK: Passed: 1
8 changes: 4 additions & 4 deletions llvm/utils/lit/tests/Inputs/shtest-define/value-equals.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

# DEFINE: %{equals} = FileCheck -check-prefixes=FOO,BAR
# RUN: echo '%{equals}'
# CHECK: FileCheck -check-prefixes=FOO,BAR
# CHECK:# | FileCheck -check-prefixes=FOO,BAR
#
# REDEFINE: %{equals} == == =
# RUN: echo '%{equals}'
# CHECK: = == =
# CHECK:# | = == =

# DEFINE: %{continue-equals} = FileCheck -strict-whitespace -match-full-lines \
# DEFINE: -check-prefixes=FOO,BAR
# RUN: echo '%{continue-equals}'
# CHECK: FileCheck -strict-whitespace -match-full-lines -check-prefixes=FOO,BAR
# CHECK:# | FileCheck -strict-whitespace -match-full-lines -check-prefixes=FOO,BAR
#
# REDEFINE: %{continue-equals} = FileCheck -input-file=test.txt \
# REDEFINE: -implicit-check-not=foobar \
# REDEFINE: -check-prefixes=FOO,BAR
# RUN: echo '%{continue-equals}'
# CHECK: FileCheck -input-file=test.txt -implicit-check-not=foobar -check-prefixes=FOO,BAR
# CHECK:# | FileCheck -input-file=test.txt -implicit-check-not=foobar -check-prefixes=FOO,BAR

# CHECK: Passed: 1
4 changes: 2 additions & 2 deletions llvm/utils/lit/tests/Inputs/shtest-define/value-escaped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

# DEFINE: %{escape} = \g<0>\n
# RUN: echo '%{escape}'
# CHECK: {{\\?}}\g<0>{{\\?}}\n
# CHECK:# | {{\\?}}\g<0>{{\\?}}\n

# REDEFINE: %{escape} = \n \
# REDEFINE: \g<param>
# RUN: echo '%{escape}'
# CHECK: {{\\?}}\n {{\\?}}\g<param>
# CHECK:# | {{\\?}}\n {{\\?}}\g<param>

# CHECK: Passed: 1
34 changes: 17 additions & 17 deletions llvm/utils/lit/tests/Inputs/shtest-define/ws-and-continuations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@
#
# DEFINE: %{empty}=
# RUN: echo "'%{empty}'"
# CHECK:''
# CHECK:# | ''
#
# REDEFINE: %{empty}=
# RUN: echo "'%{empty}'"
# CHECK:''
# CHECK:# | ''

# A value consisting only of whitespace is trimmed to the empty string.
#
# v~~ intentional whitespace
# DEFINE: %{ws}=
# RUN: echo "'%{ws}'"
# CHECK:''
# CHECK:# | ''
#
# v intentional whitespace
# REDEFINE: %{ws}=
# RUN: echo "'%{ws}'"
# CHECK:''
# CHECK:# | ''

# Whitespace is not required around the name or value.
#
# DEFINE:%{no-whitespace}=abc
# RUN: echo "'%{no-whitespace}'"
# CHECK:'abc'
# CHECK:# | 'abc'
#
# REDEFINE:%{no-whitespace}=HelloWorld
# RUN: echo "'%{no-whitespace}'"
# CHECK:'HelloWorld'
# CHECK:# | 'HelloWorld'

# Whitespace is not required between substitutions in a value.
#
# DEFINE: %{adjacent0} = foo
# DEFINE: %{adjacent1} = bar
# DEFINE: %{has-adjacent-substs} = %{adjacent0}%{adjacent1}
# RUN: echo "'%{has-adjacent-substs}'"
# CHECK:'foobar'
# CHECK:# | 'foobar'
#
# REDEFINE: %{has-adjacent-substs} = %{adjacent0}%{adjacent1}%{adjacent0}
# RUN: echo "'%{has-adjacent-substs}'"
# CHECK:'foobarfoo'
# CHECK:# | 'foobarfoo'

# Exact whitespace is preserved within the value, but whitespace enclosing the
# name or value is discarded. ('%{' and '}' are part of the name, and
Expand All @@ -50,11 +50,11 @@
# v~~ intentional whitespace
# DEFINE: %{whitespace} = abc def
# RUN: echo "'%{whitespace}'"
# CHECK:'abc def'
# CHECK:# | 'abc def'
# v intentional whitespace
# REDEFINE: %{whitespace} = Hello World
# RUN: echo "'%{whitespace}'"
# CHECK:'Hello World'
# CHECK:# | 'Hello World'

# Line continuations in the value are permitted and collapse whitespace.
#
Expand All @@ -66,12 +66,12 @@
# DEFINE: pqr
# ^ intentional whitespace
# RUN: echo "'%{continue}'"
# CHECK:'abc def ghi jkl mno pqr'
# CHECK:# | 'abc def ghi jkl mno pqr'
#
# REDEFINE: %{continue} = abc \
# REDEFINE: def
# RUN: echo "'%{continue}'"
# CHECK:'abc def'
# CHECK:# | 'abc def'

# Whitespace at the end of the line after a '\' is ignored, and it's treated as
# a line continuation. Otherwise, the behavior would be hard to understand
Expand All @@ -83,15 +83,15 @@
# ^ intentional whitespace
# DEFINE: baz
# RUN: echo "'%{ws-after-continue}'"
# CHECK:'foo bar baz'
# CHECK:# | 'foo bar baz'
#
# v intentional whitespace
# REDEFINE: %{ws-after-continue}=foo \
# REDEFINE: bar \
# ^~~~~~~~~~~~ intentional whitespace
# REDEFINE: baz
# RUN: echo "'%{ws-after-continue}'"
# CHECK:'foo bar baz'
# CHECK:# | 'foo bar baz'

# A line continuation is recognized anywhere. It should be used only where
# whitespace is permitted because it reduces to a single space.
Expand All @@ -107,7 +107,7 @@
# DEFINE:\
# DEFINE:a
# RUN: echo "'%{blank-lines}'"
# CHECK:'a'
# CHECK:# | 'a'
#
# REDEFINE: \
# REDEFINE: %{blank-lines} \
Expand All @@ -120,7 +120,7 @@
# REDEFINE: \
# REDEFINE: c
# RUN: echo "'%{blank-lines}'"
# CHECK:'a b c'
# CHECK:# | 'a b c'

# The fourth DEFINE line is deceptive because it looks like a new substitution,
# but it's actually a continuation of the previous value.
Expand All @@ -130,6 +130,6 @@
# DEFINE: %{deceptive-continue}=echo \
# DEFINE: %{name}=%{value}
# RUN: %{deceptive-continue}
# CHECK:x=3
# CHECK:# | x=3

# CHECK:{{ *}}Passed: 1
64 changes: 40 additions & 24 deletions llvm/utils/lit/tests/Inputs/shtest-if-else/test.txt
Original file line number Diff line number Diff line change
@@ -1,92 +1,108 @@
# CHECK: -- Testing:{{.*}}
# CHECK-NEXT: PASS: shtest-if-else :: test.txt (1 of 1)
# CHECK-NEXT: Script:
# CHECK: Command Output (stdout):
# CHECK-NEXT: --

# RUN: %if feature %{ echo "test-1" %}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-1]]'; echo "test-1"
# CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "test-1"

# If %else is not present it is treated like %else %{%}. Empty commands
# are ignored.
#
# RUN: %if nofeature %{ echo "fail" %}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-1]]'
# CHECK: # {{RUN}}: at line [[#@LINE-1]] has no command after substitutions
# CHECK-NOT: fail

# RUN: %if nofeature %{ echo "fail" %} %else %{ echo "test-2" %}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-1]]'; echo "test-2"
# CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "test-2"

# Spaces inside curly braces are not ignored
#
# RUN: echo test-%if feature %{ 3 %} %else %{ fail %}-test
# RUN: echo test-%if feature %{ 4 4 %} %else %{ fail %}-test
# RUN: echo test-%if nofeature %{ fail %} %else %{ 5 5 %}-test
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-3]]'; echo test- 3 -test
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-3]]'; echo test- 4 4 -test
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-3]]'; echo test- 5 5 -test
# CHECK: # {{RUN}}: at line [[#@LINE-3]]
# CHECK-NEXT: echo test- 3 -test
# CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo test- 4 4 -test
# CHECK: # {{RUN}}: at line [[#@LINE-5]]
# CHECK-NEXT: echo test- 5 5 -test

# Escape line breaks for multi-line expressions
#
# RUN: %if feature \
# RUN: %{ echo \
# RUN: "test-5" \
# RUN: %}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-4]]'; echo "test-5"
# CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo "test-5"

# RUN: %if nofeature \
# RUN: %{ echo "fail" %} \
# RUN: %else \
# RUN: %{ echo "test-6" %}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-4]]'; echo "test-6"
# CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo "test-6"

# RUN: echo "test%if feature %{%} %else %{%}-7"
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-1]]'; echo "test-7"
# CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "test-7"

# Escape %if. Without %if..%else context '%{' and '%}' are treated
# literally.
#
# RUN: echo %%if feature %{ echo "test-8" %}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-1]]'; echo %if feature %{ echo "test-8" %}
# CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo %if feature %{ echo "test-8" %}

# Nested expressions are supported:
#
# RUN: echo %if feature %{ %if feature %{ %if nofeature %{"fail"%} %else %{"test-9"%} %} %}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-1]]'; echo "test-9"
# CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "test-9"

# Binary expression evaluation and regex match can be used as
# conditions.
#
# RUN: echo %if feature && !nofeature %{ "test-10" %}
# RUN: echo %if feature && nofeature %{ "fail" %} %else %{ "test-11" %}
# RUN: echo %if {{fea.+}} %{ "test-12" %} %else %{ "fail" %}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-3]]'; echo "test-10"
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-3]]'; echo "test-11"
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-3]]'; echo "test-12"
# CHECK: # {{RUN}}: at line [[#@LINE-3]]
# CHECK-NEXT: echo "test-10"
# CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo "test-11"
# CHECK: # {{RUN}}: at line [[#@LINE-5]]
# CHECK-NEXT: echo "test-12"

# Spaces between %if and %else are ignored. If there is no %else -
# space after %if %{...%} is not ignored.
#
# RUN: echo XX %if feature %{YY%} ZZ
# RUN: echo AA %if feature %{BB%} %else %{CC%} DD
# RUN: echo AA %if nofeature %{BB%} %else %{CC%} DD
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-3]]'; echo XX YY ZZ
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-3]]'; echo AA BB DD
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-3]]'; echo AA CC DD
# CHECK: # {{RUN}}: at line [[#@LINE-3]]
# CHECK-NEXT: echo XX YY ZZ
# CHECK: # {{RUN}}: at line [[#@LINE-4]]
# CHECK-NEXT: echo AA BB DD
# CHECK: # {{RUN}}: at line [[#@LINE-5]]
# CHECK-NEXT: echo AA CC DD

# '{' and '}' can be used without escaping
#
# RUN: %if feature %{echo {}%}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-1]]'; echo {}
# CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo {}

# Spaces are not required
#
# RUN: echo %if feature%{"ok"%}%else%{"fail"%}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-1]]'; echo "ok"
# CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo "ok"

# Substitutions with braces are handled correctly
#
# RUN: echo %{sub} %if feature%{test-%{sub}%}%else%{"fail"%}
# CHECK-NEXT: {{^.*'RUN}}: at line [[#@LINE-1]]'; echo ok test-ok

# CHECK-NEXT: --
# CHECK-NEXT: Exit Code: 0
# CHECK: # {{RUN}}: at line [[#@LINE-1]]
# CHECK-NEXT: echo ok test-ok
3 changes: 2 additions & 1 deletion llvm/utils/lit/tests/Inputs/shtest-output-printing/basic.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# RUN: true
# RUN: echo hi
# RUN: not not wc missing-file &> %t.out
# RUN: not not wc missing-file &> %t.out || true
# RUN: not %{python} %S/write-a-lot.py &> %t.out
1 change: 1 addition & 0 deletions llvm/utils/lit/tests/Inputs/shtest-output-printing/lit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ import lit.formats

config.name = "shtest-output-printing"
config.suffixes = [".txt"]
config.substitutions.append(("%{python}", sys.executable))
config.test_format = lit.formats.ShTest(execute_external=False)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python

import sys

sys.stdout.write("All work and no play makes Jack a dull boy.\n" * 1000);
sys.stdout.flush()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RUN: @echo 2> %t
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RUN: touch %t
RUN: @echo < %t
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RUN: echo 2> %t
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
RUN: touch %t
RUN: echo < %t
25 changes: 22 additions & 3 deletions llvm/utils/lit/tests/allow-retries.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,28 @@

# This test does not succeed within the allowed retry limit
#
# RUN: not %{lit} %{inputs}/allow-retries/does-not-succeed-within-limit.py | FileCheck --check-prefix=CHECK-TEST3 %s
# CHECK-TEST3: Failed Tests (1):
# CHECK-TEST3: allow-retries :: does-not-succeed-within-limit.py
# Check that the execution trace isn't corrupt due to reprocessing the script
# multiple times (e.g., '%dbg(...)' processing used to accumulate across
# retries).
#
# RUN: not %{lit} %{inputs}/allow-retries/does-not-succeed-within-limit.py -v |\
# RUN: FileCheck --check-prefix=CHECK-TEST3 -match-full-lines %s
#
# CHECK-TEST3: FAIL: allow-retries :: does-not-succeed-within-limit.py (1 of 1)
# CHECK-TEST3-NEXT: {{\**}} TEST 'allow-retries :: does-not-succeed-within-limit.py' FAILED {{\**}}
# CHECK-TEST3-NEXT: Exit Code: 1
# CHECK-TEST3-EMPTY:
# CHECK-TEST3-NEXT: Command Output (stdout):
# CHECK-TEST3-NEXT: --
# CHECK-TEST3-NEXT: # {{RUN}}: at line 3
# CHECK-TEST3-NEXT: false
# CHECK-TEST3-NEXT: # executed command: false
# CHECK-TEST3-NEXT: # note: command had no output on stdout or stderr
# CHECK-TEST3-NEXT: # error: command failed with exit status: 1
# CHECK-TEST3-EMPTY:
# CHECK-TEST3-NEXT: --
# CHECK-TEST3: Failed Tests (1):
# CHECK-TEST3: allow-retries :: does-not-succeed-within-limit.py

# This test should be UNRESOLVED since it has more than one ALLOW_RETRIES
# lines, and that is not allowed.
Expand Down
4 changes: 2 additions & 2 deletions llvm/utils/lit/tests/lit-opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#
# RUN: env LIT_OPTS=-a \
# RUN: %{lit} -s %{inputs}/lit-opts \
# RUN: | FileCheck -check-prefix=SHOW-ALL -DVAR= %s
# RUN: | FileCheck -check-prefix=SHOW-ALL -DVAR=default %s

# Check that LIT_OPTS understands multiple options with arbitrary spacing.
#
Expand All @@ -28,6 +28,6 @@

# SHOW-ALL: Testing: 1 tests
# SHOW-ALL: PASS: lit-opts :: test.txt (1 of 1)
# SHOW-ALL: {{^}}[[VAR]]
# SHOW-ALL: echo [[VAR]]
# SHOW-ALL-NOT: PASS
# SHOW-ALL: Passed: 1
16 changes: 8 additions & 8 deletions llvm/utils/lit/tests/shtest-define.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,15 @@
# RUN: %{lit} -va %{my-inputs}/shared-substs-*.txt 2>&1 | \
# RUN: FileCheck -check-prefix=SHARED-SUBSTS -match-full-lines %s
#
# SHARED-SUBSTS: shared-substs-0.txt
# SHARED-SUBSTS: GLOBAL: World
# SHARED-SUBSTS: LOCAL0: LOCAL0:Hello LOCAL0:World
# SHARED-SUBSTS: LOCAL0: subst
# SHARED-SUBSTS:# | shared-substs-0.txt
# SHARED-SUBSTS:# | GLOBAL: World
# SHARED-SUBSTS:# | LOCAL0: LOCAL0:Hello LOCAL0:World
# SHARED-SUBSTS:# | LOCAL0: subst
#
# SHARED-SUBSTS: shared-substs-1.txt
# SHARED-SUBSTS: GLOBAL: World
# SHARED-SUBSTS: LOCAL1: LOCAL1:Hello LOCAL1:World
# SHARED-SUBSTS: LOCAL1: subst
# SHARED-SUBSTS:# | shared-substs-1.txt
# SHARED-SUBSTS:# | GLOBAL: World
# SHARED-SUBSTS:# | LOCAL1: LOCAL1:Hello LOCAL1:World
# SHARED-SUBSTS:# | LOCAL1: subst
#
# REDEFINE: %{test} = shared-substs-0.txt
# RUN: %{record-test}
Expand Down
131 changes: 79 additions & 52 deletions llvm/utils/lit/tests/shtest-env.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,88 +10,115 @@
# CHECK: -- Testing: 16 tests{{.*}}

# CHECK: FAIL: shtest-env :: env-args-last-is-assign.txt ({{[^)]*}})
# CHECK: $ "env" "FOO=1"
# CHECK: Error: 'env' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env FOO=1
# CHECK: # executed command: env FOO=1
# CHECK: # | Error: 'env' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-args-last-is-u-arg.txt ({{[^)]*}})
# CHECK: $ "env" "-u" "FOO"
# CHECK: Error: 'env' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env -u FOO
# CHECK: # executed command: env -u FOO
# CHECK: # | Error: 'env' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-args-last-is-u.txt ({{[^)]*}})
# CHECK: $ "env" "-u"
# CHECK: Error: 'env' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env -u
# CHECK: # executed command: env -u
# CHECK: # | Error: 'env' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-args-nested-none.txt ({{[^)]*}})
# CHECK: $ "env" "env" "env"
# CHECK: Error: 'env' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env env env
# CHECK: # executed command: env env env
# CHECK: # | Error: 'env' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-args-none.txt ({{[^)]*}})
# CHECK: $ "env"
# CHECK: Error: 'env' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env
# CHECK: # executed command: env
# CHECK: # | Error: 'env' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-calls-cd.txt ({{[^)]*}})
# CHECK: $ "env" "-u" "FOO" "BAR=3" "cd" "foobar"
# CHECK: Error: 'env' cannot call 'cd'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env -u FOO BAR=3 cd foobar
# CHECK: # executed command: env -u FOO BAR=3 cd foobar
# CHECK: # | Error: 'env' cannot call 'cd'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-calls-colon.txt ({{[^)]*}})
# CHECK: $ "env" "-u" "FOO" "BAR=3" ":"
# CHECK: Error: 'env' cannot call ':'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env -u FOO BAR=3 :
# CHECK: # executed command: env -u FOO BAR=3 :
# CHECK: # | Error: 'env' cannot call ':'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-calls-echo.txt ({{[^)]*}})
# CHECK: $ "env" "-u" "FOO" "BAR=3" "echo" "hello" "world"
# CHECK: Error: 'env' cannot call 'echo'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env -u FOO BAR=3 echo hello world
# CHECK: # executed command: env -u FOO BAR=3 echo hello world
# CHECK: # | Error: 'env' cannot call 'echo'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: PASS: shtest-env :: env-calls-env.txt ({{[^)]*}})
# CHECK: $ "env" "env" "{{[^"]*}}" "print_environment.py"
# CHECK: $ "env" "FOO=2" "env" "BAR=1" "{{[^"]*}}" "print_environment.py"
# CHECK: $ "env" "-u" "FOO" "env" "-u" "BAR" "{{[^"]*}}" "print_environment.py"
# CHECK: $ "env" "-u" "FOO" "BAR=1" "env" "-u" "BAR" "FOO=2" "{{[^"]*}}" "print_environment.py"
# CHECK: $ "env" "-u" "FOO" "BAR=1" "env" "-u" "BAR" "FOO=2" "env" "BAZ=3" "{{[^"]*}}" "print_environment.py"
# CHECK-NOT: ${{.*}}print_environment.py
# CHECK: env env [[PYTHON:.+]] print_environment.py | {{.*}}
# CHECK: # executed command: env env [[PYTHON_BARE:.+]] print_environment.py
# CHECK: env FOO=2 env BAR=1 [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env FOO=2 env BAR=1 [[PYTHON_BARE]] print_environment.py
# CHECK: env -u FOO env -u BAR [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env -u FOO env -u BAR [[PYTHON_BARE]] print_environment.py
# CHECK: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 [[PYTHON_BARE]] print_environment.py
# CHECK: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env -u FOO BAR=1 env -u BAR FOO=2 env BAZ=3 [[PYTHON_BARE]] print_environment.py
# CHECK-NOT: {{^[^#]}}
# CHECK: --

# CHECK: FAIL: shtest-env :: env-calls-export.txt ({{[^)]*}})
# CHECK: $ "env" "-u" "FOO" "BAR=3" "export" "BAZ=3"
# CHECK: Error: 'env' cannot call 'export'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env -u FOO BAR=3 export BAZ=3
# CHECK: # executed command: env -u FOO BAR=3 export BAZ=3
# CHECK: # | Error: 'env' cannot call 'export'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-calls-mkdir.txt ({{[^)]*}})
# CHECK: $ "env" "-u" "FOO" "BAR=3" "mkdir" "foobar"
# CHECK: Error: 'env' cannot call 'mkdir'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env -u FOO BAR=3 mkdir foobar
# CHECK: # executed command: env -u FOO BAR=3 mkdir foobar
# CHECK: # | Error: 'env' cannot call 'mkdir'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-calls-not-builtin.txt ({{[^)]*}})
# CHECK: $ "env" "-u" "FOO" "BAR=3" "not" "rm" "{{.*}}.no-such-file"
# CHECK: Error: 'env' cannot call 'rm'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env -u FOO BAR=3 not rm {{.+}}.no-such-file
# CHECK: # executed command: env -u FOO BAR=3 not rm {{.+}}.no-such-file
# CHECK: # | Error: 'env' cannot call 'rm'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-env :: env-calls-rm.txt ({{[^)]*}})
# CHECK: $ "env" "-u" "FOO" "BAR=3" "rm" "foobar"
# CHECK: Error: 'env' cannot call 'rm'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: env -u FOO BAR=3 rm foobar
# CHECK: # executed command: env -u FOO BAR=3 rm foobar
# CHECK: # | Error: 'env' cannot call 'rm'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: PASS: shtest-env :: env-u.txt ({{[^)]*}})
# CHECK: $ "{{[^"]*}}" "print_environment.py"
# CHECK: $ "env" "-u" "FOO" "{{[^"]*}}" "print_environment.py"
# CHECK: $ "env" "-u" "FOO" "-u" "BAR" "{{[^"]*}}" "print_environment.py"
# CHECK-NOT: ${{.*}}print_environment.py
# CHECK: [[PYTHON]] print_environment.py | {{.*}}
# CHECK: env -u FOO [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env -u FOO [[PYTHON_BARE]] print_environment.py
# CHECK: env -u FOO -u BAR [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env -u FOO -u BAR [[PYTHON_BARE]] print_environment.py
# CHECK-NOT: {{^[^#]}}
# CHECK: --

# CHECK: PASS: shtest-env :: env.txt ({{[^)]*}})
# CHECK: $ "env" "A_FOO=999" "{{[^"]*}}" "print_environment.py"
# CHECK: $ "env" "A_FOO=1" "B_BAR=2" "C_OOF=3" "{{[^"]*}}" "print_environment.py"
# CHECK-NOT: ${{.*}}print_environment.py
# CHECK: env A_FOO=999 [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env A_FOO=999 [[PYTHON_BARE]] print_environment.py
# CHECK: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env A_FOO=1 B_BAR=2 C_OOF=3 [[PYTHON_BARE]] print_environment.py
# CHECK-NOT: {{^[^#]}}
# CHECK: --

# CHECK: PASS: shtest-env :: mixed.txt ({{[^)]*}})
# CHECK: $ "env" "A_FOO=999" "-u" "FOO" "{{[^"]*}}" "print_environment.py"
# CHECK: $ "env" "A_FOO=1" "-u" "FOO" "B_BAR=2" "-u" "BAR" "C_OOF=3" "{{[^"]*}}" "print_environment.py"
# CHECK-NOT: ${{.*}}print_environment.py
# CHECK: env A_FOO=999 -u FOO [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env A_FOO=999 -u FOO [[PYTHON_BARE]] print_environment.py
# CHECK: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON]] print_environment.py | {{.*}}
# CHECK: # executed command: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 [[PYTHON_BARE]] print_environment.py
# CHECK-NOT: {{^[^#]}}
# CHECK: --

# CHECK: Passed: 4
# CHECK: Failed: 12
Expand Down
72 changes: 43 additions & 29 deletions llvm/utils/lit/tests/shtest-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,27 @@

# CHECK: PASS: shtest-format :: external_shell/pass.txt

# CHECK: FAIL: shtest-format :: fail.txt
# CHECK-NEXT: *** TEST 'shtest-format :: fail.txt' FAILED ***
# CHECK-NEXT: Script:
# CHECK-NEXT: --
# CHECK-NEXT: printf "line 1
# CHECK-NEXT: false
# CHECK-NEXT: --
# CHECK-NEXT: Exit Code: 1
#
# CHECK: Command Output (stdout):
# CHECK-NEXT: --
# CHECK-NEXT: $ ":" "RUN: at line 1"
# CHECK-NEXT: $ "printf"
# CHECK-NEXT: # command output:
# CHECK-NEXT: line 1: failed test output on stdout
# CHECK-NEXT: line 2: failed test output on stdout
# CHECK: FAIL: shtest-format :: fail.txt
# CHECK-NEXT: *** TEST 'shtest-format :: fail.txt' FAILED ***
# CHECK-NEXT: Exit Code: 1
# CHECK-EMPTY:
# CHECK-NEXT: Command Output (stdout):
# CHECK-NEXT: --
# CHECK-NEXT: # RUN: at line 1
# CHECK-NEXT: printf "line 1: failed test output on stdout\nline 2: failed test output on stdout"
# CHECK-NEXT: executed command: printf 'line 1: failed test output on stdout\nline 2: failed test output on stdout'
# CHECK-NEXT: # .---command stdout------------
# CHECK-NEXT: # | line 1: failed test output on stdout
# CHECK-NEXT: # | line 2: failed test output on stdout
# CHECK-NEXT: # `-----------------------------
# CHECK-NEXT: # RUN: at line 2
# CHECK-NEXT: false
# CHECK-NEXT: # executed command: false
# CHECK-NEXT: # note: command had no output on stdout or stderr
# CHECK-NEXT: # error: command failed with exit status: 1
# CHECK-EMPTY:
# CHECK-NEXT: --


# CHECK: UNRESOLVED: shtest-format :: no-test-line.txt
# CHECK: PASS: shtest-format :: pass.txt
Expand All @@ -69,12 +74,18 @@
# CHECK: XFAIL: shtest-format :: xfail-feature.txt
# CHECK: XFAIL: shtest-format :: xfail-target.txt
# CHECK: XFAIL: shtest-format :: xfail.txt
# CHECK: XPASS: shtest-format :: xpass.txt
# CHECK-NEXT: *** TEST 'shtest-format :: xpass.txt' FAILED ***
# CHECK-NEXT: Script
# CHECK-NEXT: --
# CHECK-NEXT: true
# CHECK-NEXT: --

# CHECK: XPASS: shtest-format :: xpass.txt
# CHECK-NEXT: *** TEST 'shtest-format :: xpass.txt' FAILED ***
# CHECK-NEXT: Exit Code: 0
# CHECK-EMPTY:
# CHECK-NEXT: Command Output (stdout):
# CHECK-NEXT: --
# CHECK-NEXT: # RUN: at line 1
# CHECK-NEXT: true
# CHECK-NEXT: # executed command: true
# CHECK-EMPTY:
# CHECK-NEXT: --

# CHECK: Failed Tests (4)
# CHECK: shtest-format :: external_shell/fail.txt
Expand Down Expand Up @@ -109,13 +120,16 @@
# XUNIT: </failure>
# XUNIT-NEXT: </testcase>

# XUNIT: <testcase classname="shtest-format.external_shell" name="fail_with_control_chars.txt" time="{{[0-9]+\.[0-9]+}}">
# XUNIT-NEXT: <failure><![CDATA[Script:
# XUNIT: Command Output (stdout):
# XUNIT-NEXT: --
# XUNIT-NEXT: a line with [2;30;41mcontrol characters[0m.
# XUNIT: </failure>
# XUNIT-NEXT: </testcase>
# XUNIT: <testcase classname="shtest-format.external_shell" name="fail_with_control_chars.txt" time="{{[0-9]+\.[0-9]+}}">
# XUNIT-NEXT: <failure><![CDATA[Exit Code: 1
# XUNIT-EMPTY:
# XUNIT-NEXT: Command Output (stdout):
# XUNIT-NEXT: --
# XUNIT-NEXT: a line with [2;30;41mcontrol characters[0m.
# XUNIT-EMPTY:
# XUNIT-NEXT: --
# XUNIT: ]]></failure>
# XUNIT-NEXT: </testcase>

# XUNIT: <testcase classname="shtest-format.external_shell" name="pass.txt" time="{{[0-9]+\.[0-9]+}}"/>

Expand Down
3 changes: 2 additions & 1 deletion llvm/utils/lit/tests/shtest-if-else.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# RUN: %{lit} -v --show-all %{inputs}/shtest-if-else/test.txt \
# RUN: | FileCheck %{inputs}/shtest-if-else/test.txt --match-full-lines
# RUN: | FileCheck %{inputs}/shtest-if-else/test.txt --match-full-lines \
# RUN: --implicit-check-not='RUN:'

# RUN: not %{lit} -v --show-all %{inputs}/shtest-if-else/test-neg1.txt 2>&1 \
# RUN: | FileCheck %{inputs}/shtest-if-else/test-neg1.txt
Expand Down
45 changes: 20 additions & 25 deletions llvm/utils/lit/tests/shtest-inject.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
# Check that we can inject commands at the beginning of a ShTest.
# Check that we can inject preamble commands at the beginning of a ShTest.
#
# For one case, check the execution trace as these preamble commands have
# "preamble command" instead of the usual "{{RUN}}: at line N".

# RUN: %{lit} %{inputs}/shtest-inject/test-empty.txt --show-all | FileCheck --check-prefix=CHECK-TEST1 %s
#
# CHECK-TEST1: Script:
# CHECK-TEST1: --
# CHECK-TEST1: echo "THIS WAS"
# CHECK-TEST1: echo "INJECTED"
# CHECK-TEST1: --
#
# CHECK-TEST1: THIS WAS
# CHECK-TEST1: INJECTED
# CHECK-TEST1: Command Output (stdout):
# CHECK-TEST1-NEXT: --
# CHECK-TEST1-NEXT: # preamble command line
# CHECK-TEST1-NEXT: echo "THIS WAS"
# CHECK-TEST1-NEXT: # executed command: echo 'THIS WAS'
# CHECK-TEST1-NEXT: # .---command stdout{{-*}}
# CHECK-TEST1-NEXT: # | THIS WAS
# CHECK-TEST1-NEXT: # `---{{-*}}
# CHECK-TEST1-NEXT: # preamble command line
# CHECK-TEST1-NEXT: echo "INJECTED"
# CHECK-TEST1-NEXT: # executed command: echo INJECTED
# CHECK-TEST1-NEXT: # .---command stdout{{-*}}
# CHECK-TEST1-NEXT: # | INJECTED
# CHECK-TEST1-NEXT: # `---{{-*}}
# CHECK-TEST1-EMPTY:
# CHECK-TEST1-NEXT: --
#
# CHECK-TEST1: Passed: 1

# RUN: %{lit} %{inputs}/shtest-inject/test-one.txt --show-all | FileCheck --check-prefix=CHECK-TEST2 %s
#
# CHECK-TEST2: Script:
# CHECK-TEST2: --
# CHECK-TEST2: echo "THIS WAS"
# CHECK-TEST2: echo "INJECTED"
# CHECK-TEST2: echo "IN THE FILE"
# CHECK-TEST2: --
#
# CHECK-TEST2: THIS WAS
# CHECK-TEST2: INJECTED
# CHECK-TEST2: IN THE FILE
Expand All @@ -30,15 +34,6 @@

# RUN: %{lit} %{inputs}/shtest-inject/test-many.txt --show-all | FileCheck --check-prefix=CHECK-TEST3 %s
#
# CHECK-TEST3: Script:
# CHECK-TEST3: --
# CHECK-TEST3: echo "THIS WAS"
# CHECK-TEST3: echo "INJECTED"
# CHECK-TEST3: echo "IN THE FILE"
# CHECK-TEST3: echo "IF IT WORKS"
# CHECK-TEST3: echo "AS EXPECTED"
# CHECK-TEST3: --
#
# CHECK-TEST3: THIS WAS
# CHECK-TEST3: INJECTED
# CHECK-TEST3: IN THE FILE
Expand Down
217 changes: 132 additions & 85 deletions llvm/utils/lit/tests/shtest-not.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,132 +10,179 @@
# CHECK: -- Testing: 17 tests{{.*}}

# CHECK: FAIL: shtest-not :: exclamation-args-nested-none.txt {{.*}}
# CHECK: $ "!" "!" "!"
# CHECK: Error: '!' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: ! ! !
# CHECK: # executed command: ! ! !
# CHECK: # | Error: '!' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: exclamation-args-none.txt {{.*}}
# CHECK: $ "!"
# CHECK: Error: '!' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: !
# CHECK: # executed command: !
# CHECK: # | Error: '!' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: exclamation-calls-external.txt {{.*}}

# CHECK: $ "!" "{{[^"]*}}" "fail.py"
# CHECK: $ "!" "!" "{{[^"]*}}" "pass.py"
# CHECK: $ "!" "!" "!" "{{[^"]*}}" "fail.py"
# CHECK: $ "!" "!" "!" "!" "{{[^"]*}}" "pass.py"
# CHECK: ! [[PYTHON:.*]] fail.py
# CHECK: # executed command: ! [[PYTHON_BARE:.*]] fail.py
# CHECK: ! ! [[PYTHON]] pass.py
# CHECK: # executed command: ! ! [[PYTHON_BARE]] pass.py
# CHECK: ! ! ! [[PYTHON]] fail.py
# CHECK: # executed command: ! ! ! [[PYTHON_BARE]] fail.py
# CHECK: ! ! ! ! [[PYTHON]] pass.py
# CHECK: # executed command: ! ! ! ! [[PYTHON_BARE]] pass.py

# CHECK: $ "!" "{{[^"]*}}" "pass.py"
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: ! [[PYTHON]] pass.py
# CHECK: # executed command: ! [[PYTHON_BARE]] pass.py
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: not-args-last-is-crash.txt {{.*}}
# CHECK: $ "not" "--crash"
# CHECK: Error: 'not' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not --crash
# CHECK: # executed command: not --crash
# CHECK: # | Error: 'not' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: not-args-nested-none.txt {{.*}}
# CHECK: $ "not" "not" "not"
# CHECK: Error: 'not' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not not not
# CHECK: # executed command: not not not
# CHECK: # | Error: 'not' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: not-args-none.txt {{.*}}
# CHECK: $ "not"
# CHECK: Error: 'not' requires a subcommand
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not
# CHECK: # executed command: not
# CHECK: # | Error: 'not' requires a subcommand
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: not-calls-cd.txt {{.*}}
# CHECK: $ "not" "not" "cd" "foobar"
# CHECK: $ "not" "--crash" "cd" "foobar"
# CHECK: Error: 'not --crash' cannot call 'cd'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not not cd foobar
# CHECK: # executed command: not not cd foobar
# CHECK: not --crash cd foobar
# CHECK: # executed command: not --crash cd foobar
# CHECK: # | Error: 'not --crash' cannot call 'cd'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: not-calls-colon.txt {{.*}}
# CHECK: $ "not" "not" ":" "foobar"
# CHECK: $ "not" "--crash" ":"
# CHECK: Error: 'not --crash' cannot call ':'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not not : foobar
# CHECK: # executed command: not not : foobar
# CHECK: not --crash :
# CHECK: # executed command: not --crash :
# CHECK: # | Error: 'not --crash' cannot call ':'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: not-calls-diff-with-crash.txt {{.*}}
# CHECK: $ "not" "--crash" "diff" "-u" {{.*}}
# CHECK-NOT: "$"
# CHECK: not --crash diff -u {{.*}}
# CHECK: # executed command: not --crash diff -u {{.*}}
# CHECK-NOT: # executed command: {{.*}}
# CHECK-NOT: {{[Ee]rror}}
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: # error: command failed with exit status: {{.*}}
# CHECK-NOT: # executed command: {{.*}}
# CHECK-NOT: {{[Ee]rror}}
# CHECK-NOT: "$"

# CHECK: FAIL: shtest-not :: not-calls-diff.txt {{.*}}
# CHECK: $ "not" "diff" {{.*}}
# CHECK: $ "not" "not" "not" "diff" {{.*}}
# CHECK: $ "not" "not" "not" "not" "not" "diff" {{.*}}
# CHECK: $ "diff" {{.*}}
# CHECK: $ "not" "not" "diff" {{.*}}
# CHECK: $ "not" "not" "not" "not" "diff" {{.*}}
# CHECK: $ "not" "diff" {{.*}}
# CHECK-NOT: "$"
# CHECK: not diff {{.*}}
# CHECK: # executed command: not diff {{.*}}
# CHECK: not not not diff {{.*}}
# CHECK: # executed command: not not not diff {{.*}}
# CHECK: not not not not not diff {{.*}}
# CHECK: # executed command: not not not not not diff {{.*}}
# CHECK: diff {{.*}}
# CHECK: # executed command: diff {{.*}}
# CHECK: not not diff {{.*}}
# CHECK: # executed command: not not diff {{.*}}
# CHECK: not not not not diff {{.*}}
# CHECK: # executed command: not not not not diff {{.*}}
# CHECK: not diff {{.*}}
# CHECK: # executed command: not diff {{.*}}
# CHECK-NOT: # executed command: {{.*}}

# CHECK: FAIL: shtest-not :: not-calls-echo.txt {{.*}}
# CHECK: $ "not" "not" "echo" "hello" "world"
# CHECK: $ "not" "--crash" "echo" "hello" "world"
# CHECK: Error: 'not --crash' cannot call 'echo'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not not echo hello world
# CHECK: # executed command: not not echo hello world
# CHECK: not --crash echo hello world
# CHECK: # executed command: not --crash echo hello world
# CHECK: # | Error: 'not --crash' cannot call 'echo'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: not-calls-env-builtin.txt {{.*}}
# CHECK: $ "not" "--crash" "env" "-u" "FOO" "BAR=3" "rm" "{{.*}}.no-such-file"
# CHECK: Error: 'env' cannot call 'rm'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not --crash env -u FOO BAR=3 rm {{.*}}.no-such-file
# CHECK: # executed command: not --crash env -u FOO BAR=3 rm {{.*}}.no-such-file
# CHECK: # | Error: 'env' cannot call 'rm'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: not-calls-export.txt {{.*}}
# CHECK: $ "not" "not" "export" "FOO=1"
# CHECK: $ "not" "--crash" "export" "BAZ=3"
# CHECK: Error: 'not --crash' cannot call 'export'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not not export FOO=1
# CHECK: # executed command: not not export FOO=1
# CHECK: not --crash export BAZ=3
# CHECK: # executed command: not --crash export BAZ=3
# CHECK: # | Error: 'not --crash' cannot call 'export'
# CHECK: # error: command failed with exit status: {{.*}}


# CHECK: PASS: shtest-not :: not-calls-external.txt {{.*}}

# CHECK: $ "not" "{{[^"]*}}" "fail.py"
# CHECK: $ "not" "not" "{{[^"]*}}" "pass.py"
# CHECK: $ "not" "not" "not" "{{[^"]*}}" "fail.py"
# CHECK: $ "not" "not" "not" "not" "{{[^"]*}}" "pass.py"

# CHECK: $ "not" "not" "--crash" "{{[^"]*}}" "pass.py"
# CHECK: $ "not" "not" "--crash" "{{[^"]*}}" "fail.py"
# CHECK: $ "not" "not" "--crash" "not" "{{[^"]*}}" "pass.py"
# CHECK: $ "not" "not" "--crash" "not" "{{[^"]*}}" "fail.py"

# CHECK: $ "env" "not" "{{[^"]*}}" "fail.py"
# CHECK: $ "not" "env" "{{[^"]*}}" "fail.py"
# CHECK: $ "env" "FOO=1" "not" "{{[^"]*}}" "fail.py"
# CHECK: $ "not" "env" "FOO=1" "BAR=1" "{{[^"]*}}" "fail.py"
# CHECK: $ "env" "FOO=1" "BAR=1" "not" "env" "-u" "FOO" "BAR=2" "{{[^"]*}}" "fail.py"
# CHECK: $ "not" "env" "FOO=1" "BAR=1" "not" "env" "-u" "FOO" "-u" "BAR" "{{[^"]*}}" "pass.py"
# CHECK: $ "not" "not" "env" "FOO=1" "env" "FOO=2" "BAR=1" "{{[^"]*}}" "pass.py"
# CHECK: $ "env" "FOO=1" "-u" "BAR" "env" "-u" "FOO" "BAR=1" "not" "not" "{{[^"]*}}" "pass.py"

# CHECK: $ "not" "env" "FOO=1" "BAR=1" "env" "FOO=2" "BAR=2" "not" "--crash" "{{[^"]*}}" "pass.py"
# CHECK: $ "not" "env" "FOO=1" "BAR=1" "not" "--crash" "not" "{{[^"]*}}" "pass.py"
# CHECK: $ "not" "not" "--crash" "env" "-u" "BAR" "not" "env" "-u" "FOO" "BAR=1" "{{[^"]*}}" "pass.py"
# CHECK: not [[PYTHON]] fail.py
# CHECK: # executed command: not [[PYTHON_BARE]] fail.py
# CHECK: not not [[PYTHON]] pass.py
# CHECK: # executed command: not not [[PYTHON_BARE]] pass.py
# CHECK: not not not [[PYTHON]] fail.py
# CHECK: # executed command: not not not [[PYTHON_BARE]] fail.py
# CHECK: not not not not [[PYTHON]] pass.py
# CHECK: # executed command: not not not not [[PYTHON_BARE]] pass.py

# CHECK: not not --crash [[PYTHON]] pass.py
# CHECK: # executed command: not not --crash [[PYTHON_BARE]] pass.py
# CHECK: not not --crash [[PYTHON]] fail.py
# CHECK: # executed command: not not --crash [[PYTHON_BARE]] fail.py
# CHECK: not not --crash not [[PYTHON]] pass.py
# CHECK: # executed command: not not --crash not [[PYTHON_BARE]] pass.py
# CHECK: not not --crash not [[PYTHON]] fail.py
# CHECK: # executed command: not not --crash not [[PYTHON_BARE]] fail.py

# CHECK: env not [[PYTHON]] fail.py | {{.*}}
# CHECK: # executed command: env not [[PYTHON_BARE]] fail.py
# CHECK: not env [[PYTHON]] fail.py | {{.*}}
# CHECK: # executed command: not env [[PYTHON_BARE]] fail.py
# CHECK: env FOO=1 not [[PYTHON]] fail.py | {{.*}}
# CHECK: # executed command: env FOO=1 not [[PYTHON_BARE]] fail.py
# CHECK: not env FOO=1 BAR=1 [[PYTHON]] fail.py | {{.*}}
# CHECK: # executed command: not env FOO=1 BAR=1 [[PYTHON_BARE]] fail.py
# CHECK: env FOO=1 BAR=1 not env -u FOO BAR=2 [[PYTHON]] fail.py | {{.*}}
# CHECK: # executed command: env FOO=1 BAR=1 not env -u FOO BAR=2 [[PYTHON_BARE]] fail.py
# CHECK: not env FOO=1 BAR=1 not env -u FOO -u BAR [[PYTHON]] pass.py | {{.*}}
# CHECK: # executed command: not env FOO=1 BAR=1 not env -u FOO -u BAR [[PYTHON_BARE]] pass.py
# CHECK: not not env FOO=1 env FOO=2 BAR=1 [[PYTHON]] pass.py | {{.*}}
# CHECK: # executed command: not not env FOO=1 env FOO=2 BAR=1 [[PYTHON_BARE]] pass.py
# CHECK: env FOO=1 -u BAR env -u FOO BAR=1 not not [[PYTHON]] pass.py | {{.*}}
# CHECK: # executed command: env FOO=1 -u BAR env -u FOO BAR=1 not not [[PYTHON_BARE]] pass.py

# CHECK: not env FOO=1 BAR=1 env FOO=2 BAR=2 not --crash [[PYTHON]] pass.py | {{.*}}
# CHECK: # executed command: not env FOO=1 BAR=1 env FOO=2 BAR=2 not --crash [[PYTHON_BARE]] pass.py
# CHECK: not env FOO=1 BAR=1 not --crash not [[PYTHON]] pass.py | {{.*}}
# CHECK: # executed command: not env FOO=1 BAR=1 not --crash not [[PYTHON_BARE]] pass.py
# CHECK: not not --crash env -u BAR not env -u FOO BAR=1 [[PYTHON]] pass.py | {{.*}}
# CHECK: # executed command: not not --crash env -u BAR not env -u FOO BAR=1 [[PYTHON_BARE]] pass.py


# CHECK: FAIL: shtest-not :: not-calls-fail2.txt {{.*}}
# CHECK-NEXT: {{.*}} TEST 'shtest-not :: not-calls-fail2.txt' FAILED {{.*}}
# CHECK-NEXT: Script:
# CHECK-NEXT: --
# CHECK: --
# CHECK-NEXT: Exit Code: 1

# CHECK: FAIL: shtest-not :: not-calls-mkdir.txt {{.*}}
# CHECK: $ "not" "mkdir" {{.*}}
# CHECK: $ "not" "--crash" "mkdir" "foobar"
# CHECK: Error: 'not --crash' cannot call 'mkdir'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not mkdir {{.*}}
# CHECK: # executed command: not mkdir {{.*}}
# CHECK: not --crash mkdir foobar
# CHECK: # executed command: not --crash mkdir foobar
# CHECK: # | Error: 'not --crash' cannot call 'mkdir'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: FAIL: shtest-not :: not-calls-rm.txt {{.*}}
# CHECK: $ "not" "rm" {{.*}}
# CHECK: $ "not" "--crash" "rm" "foobar"
# CHECK: Error: 'not --crash' cannot call 'rm'
# CHECK: error: command failed with exit status: {{.*}}
# CHECK: not rm {{.*}}
# CHECK: # executed command: not rm {{.*}}
# CHECK: not --crash rm foobar
# CHECK: # executed command: not --crash rm foobar
# CHECK: # | Error: 'not --crash' cannot call 'rm'
# CHECK: # error: command failed with exit status: {{.*}}

# CHECK: Passed: 1
# CHECK: Failed: 16
Expand Down
64 changes: 39 additions & 25 deletions llvm/utils/lit/tests/shtest-output-printing.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,45 @@
# Check the various features of the ShTest format.
#
# RUN: not %{lit} -v %{inputs}/shtest-output-printing > %t.out
# RUN: FileCheck --input-file %t.out %s
# RUN: FileCheck --input-file %t.out --match-full-lines %s
#
# END.

# CHECK: -- Testing:

# CHECK: FAIL: shtest-output-printing :: basic.txt
# CHECK-NEXT: *** TEST 'shtest-output-printing :: basic.txt' FAILED ***
# CHECK-NEXT: Script:
# CHECK-NEXT: --
# CHECK: --
# CHECK-NEXT: Exit Code: 1
#
# CHECK: Command Output
# CHECK-NEXT: --
# CHECK-NEXT: $ ":" "RUN: at line 1"
# CHECK-NEXT: $ "true"
# CHECK-NEXT: $ ":" "RUN: at line 2"
# CHECK-NEXT: $ "echo" "hi"
# CHECK-NEXT: # command output:
# CHECK-NEXT: hi
#
# CHECK: $ ":" "RUN: at line 3"
# CHECK-NEXT: $ "not" "not" "wc" "missing-file"
# CHECK-NEXT: # redirected output from '{{.*(/|\\\\)}}basic.txt.tmp.out':
# CHECK-NEXT: {{cannot open missing-file|missing-file.* No such file or directory}}
# CHECK: note: command had no output on stdout or stderr
# CHECK-NEXT: error: command failed with exit status: 1
# CHECK: -- Testing: {{.*}}
# CHECK: FAIL: shtest-output-printing :: basic.txt {{.*}}
# CHECK-NEXT: ***{{\**}} TEST 'shtest-output-printing :: basic.txt' FAILED ***{{\**}}
# CHECK-NEXT: Exit Code: 1
# CHECK-EMPTY:
# CHECK-NEXT: Command Output (stdout):
# CHECK-NEXT: --
# CHECK-NEXT: # RUN: at line 1
# CHECK-NEXT: true
# CHECK-NEXT: # executed command: true
# CHECK-NEXT: # RUN: at line 2
# CHECK-NEXT: echo hi
# CHECK-NEXT: # executed command: echo hi
# CHECK-NEXT: # .---command stdout------------
# CHECK-NEXT: # | hi
# CHECK-NEXT: # `-----------------------------
# CHECK-NEXT: # RUN: at line 3
# CHECK-NEXT: not not wc missing-file &> [[FILE:.*]] || true
# CHECK-NEXT: # executed command: not not wc missing-file
# CHECK-NEXT: # .---redirected output from '[[FILE]]'
# CHECK-NEXT: # | wc: {{cannot open missing-file|missing-file.* No such file or directory}}
# CHECK-NEXT: # `-----------------------------
# CHECK-NEXT: # note: command had no output on stdout or stderr
# CHECK-NEXT: # error: command failed with exit status: 1
# CHECK-NEXT: # executed command: true
# CHECK-NEXT: # RUN: at line 4
# CHECK-NEXT: not {{.*}}/python{{.*}} {{.*}}/write-a-lot.py &> [[FILE:.*]]
# CHECK-NEXT: # executed command: not {{.*}}/python{{.*}} {{.*}}/write-a-lot.py
# CHECK-NEXT: # .---redirected output from '[[FILE]]'
# CHECK-NEXT: # | All work and no play makes Jack a dull boy.
# CHECK-NEXT: # | All work and no play makes Jack a dull boy.
# CHECK-NEXT: # | All work and no play makes Jack a dull boy.
# CHECK: # | ...
# CHECK-NEXT: # `---data was truncated--------
# CHECK-NEXT: # note: command had no output on stdout or stderr
# CHECK-NEXT: # error: command failed with exit status: 1
# CHECK-EMPTY:
# CHECK-NEXT:--
12 changes: 6 additions & 6 deletions llvm/utils/lit/tests/shtest-pushd-popd.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
# CHECK: -- Testing: 4 tests{{.*}}

# CHECK: FAIL: shtest-pushd-popd :: popd-args.txt ({{[^)]*}})
# CHECK: $ "popd" "invalid"
# CHECK: 'popd' does not support arguments
# CHECK: popd invalid
# CHECK: # | 'popd' does not support arguments

# CHECK: FAIL: shtest-pushd-popd :: popd-no-stack.txt ({{[^)]*}})
# CHECK: $ "popd"
# CHECK: popd: directory stack empty
# CHECK: popd
# CHECK: # | popd: directory stack empty

# CHECK: FAIL: shtest-pushd-popd :: pushd-too-many-args.txt ({{[^)]*}})
# CHECK: $ "pushd" "a" "b"
# CHECK: 'pushd' supports only one argument
# CHECK: pushd a b
# CHECK: # | 'pushd' supports only one argument

# CHECK: Passed: 1
# CHECK: Failed: 3
Expand Down
6 changes: 3 additions & 3 deletions llvm/utils/lit/tests/shtest-recursive-substitution.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@

# RUN: %{lit} %{inputs}/shtest-recursive-substitution/substitutes-within-limit --show-all | FileCheck --check-prefix=CHECK-TEST1 %s
# CHECK-TEST1: PASS: substitutes-within-limit :: test.py
# CHECK-TEST1: $ "echo" "STOP"
# CHECK-TEST1: echo STOP

# RUN: not %{lit} %{inputs}/shtest-recursive-substitution/does-not-substitute-within-limit --show-all | FileCheck --check-prefix=CHECK-TEST2 %s
# CHECK-TEST2: UNRESOLVED: does-not-substitute-within-limit :: test.py
# CHECK-TEST2: ValueError: Recursive substitution of

# RUN: %{lit} %{inputs}/shtest-recursive-substitution/does-not-substitute-no-limit --show-all | FileCheck --check-prefix=CHECK-TEST3 %s
# CHECK-TEST3: PASS: does-not-substitute-no-limit :: test.py
# CHECK-TEST3: $ "echo" "%rec4"
# CHECK-TEST3: echo %rec4

# RUN: not %{lit} %{inputs}/shtest-recursive-substitution/not-an-integer --show-all 2>&1 | FileCheck --check-prefix=CHECK-TEST4 %s
# CHECK-TEST4: recursiveExpansionLimit must be either None or an integer
Expand All @@ -24,4 +24,4 @@

# RUN: %{lit} %{inputs}/shtest-recursive-substitution/escaping --show-all | FileCheck --check-prefix=CHECK-TEST7 %s
# CHECK-TEST7: PASS: escaping :: test.py
# CHECK-TEST7: $ "echo" "%s" "%s" "%%s"
# CHECK-TEST7: echo %s %s %%s
61 changes: 23 additions & 38 deletions llvm/utils/lit/tests/shtest-run-at-line.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# Check that -vv makes the line number of the failing RUN command clear.
# (-v is actually sufficient in the case of the internal shell.)
# Check that -a/-v/-vv makes the line number of the failing RUN command clear.

# RUN: not %{lit} -vv %{inputs}/shtest-run-at-line > %t.out
# RUN: FileCheck --input-file %t.out %s
#
# RUN: not %{lit} -a %{inputs}/shtest-run-at-line | FileCheck %s
# RUN: not %{lit} -v %{inputs}/shtest-run-at-line | FileCheck %s
# RUN: not %{lit} -vv %{inputs}/shtest-run-at-line | FileCheck %s
# END.


Expand All @@ -15,56 +14,42 @@

# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/basic.txt

# CHECK: Script:
# CHECK: RUN: at line 4{{.*}} true
# CHECK-NEXT: RUN: at line 5{{.*}} false
# CHECK-NEXT: RUN: at line 6{{.*}} true

# CHECK: RUN: at line 4
# CHECK: RUN: at line 5
# CHECK-NOT: RUN

# CHECK-LABEL: FAIL: shtest-run-at-line :: external-shell/line-continuation.txt

# CHECK: Script:
# CHECK: RUN: at line 4{{.*}} echo 'foo bar' | FileCheck
# CHECK-NEXT: RUN: at line 6{{.*}} echo 'foo baz' | FileCheck
# CHECK-NEXT: RUN: at line 9{{.*}} echo 'foo bar' | FileCheck

# CHECK: RUN: at line 4
# CHECK: RUN: at line 6
# CHECK-NOT: RUN


# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/basic.txt

# CHECK: Script:
# CHECK: : 'RUN: at line 1'; true
# CHECK-NEXT: : 'RUN: at line 2'; false
# CHECK-NEXT: : 'RUN: at line 3'; true

# CHECK: Command Output (stdout)
# CHECK: $ ":" "RUN: at line 1"
# CHECK-NEXT: $ "true"
# CHECK-NEXT: $ ":" "RUN: at line 2"
# CHECK-NEXT: $ "false"
# CHECK-NEXT: --
# CHECK-NEXT: # RUN: at line 1
# CHECK-NEXT: true
# CHECK-NEXT: # executed command: true
# CHECK-NEXT: # RUN: at line 2
# CHECK-NEXT: false
# CHECK-NEXT: # executed command: false
# CHECK-NOT: RUN

# CHECK-LABEL: FAIL: shtest-run-at-line :: internal-shell/line-continuation.txt

# CHECK: Script:
# CHECK: : 'RUN: at line 1'; : first line continued to second line
# CHECK-NEXT: : 'RUN: at line 3'; echo 'foo bar' | FileCheck
# CHECK-NEXT: : 'RUN: at line 5'; echo 'foo baz' | FileCheck
# CHECK-NEXT: : 'RUN: at line 8'; echo 'foo bar' | FileCheck

# CHECK: Command Output (stdout)
# CHECK: $ ":" "RUN: at line 1"
# CHECK-NEXT: $ ":" "first" "line" "continued" "to" "second" "line"
# CHECK-NEXT: $ ":" "RUN: at line 3"
# CHECK-NEXT: $ "echo" "foo bar"
# CHECK-NEXT: $ "FileCheck" "{{.*}}"
# CHECK-NEXT: $ ":" "RUN: at line 5"
# CHECK-NEXT: $ "echo" "foo baz"
# CHECK-NEXT: $ "FileCheck" "{{.*}}"
# CHECK-NEXT: --
# CHECK-NEXT: # RUN: at line 1
# CHECK-NEXT: : first line continued to second line
# CHECK-NEXT: # executed command: : first line continued to second line
# CHECK-NEXT: # RUN: at line 3
# CHECK-NEXT: echo 'foo bar' | FileCheck {{.*}}
# CHECK-NEXT: # executed command: echo 'foo bar'
# CHECK-NEXT: # executed command: FileCheck {{.*}}
# CHECK-NEXT: # RUN: at line 5
# CHECK-NEXT: echo 'foo baz' | FileCheck {{.*}}
# CHECK-NEXT: # executed command: echo 'foo baz'
# CHECK-NEXT: # executed command: FileCheck {{.*}}
# CHECK-NOT: RUN
856 changes: 453 additions & 403 deletions llvm/utils/lit/tests/shtest-shell.py

Large diffs are not rendered by default.