summaryrefslogtreecommitdiff
path: root/utils/lit/tests
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-12-18 20:10:56 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-12-18 20:10:56 +0000
commit044eb2f6afba375a914ac9d8024f8f5142bb912e (patch)
tree1475247dc9f9fe5be155ebd4c9069c75aadf8c20 /utils/lit/tests
parenteb70dddbd77e120e5d490bd8fbe7ff3f8fa81c6b (diff)
Notes
Diffstat (limited to 'utils/lit/tests')
-rw-r--r--utils/lit/tests/Inputs/config-map-discovery/driver.py16
-rw-r--r--utils/lit/tests/Inputs/config-map-discovery/invalid-test.txt0
-rw-r--r--utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg9
-rw-r--r--utils/lit/tests/Inputs/config-map-discovery/main-config/lit.cfg1
-rw-r--r--utils/lit/tests/Inputs/config-map-discovery/tests/test1.txt0
-rw-r--r--utils/lit/tests/Inputs/config-map-discovery/tests/test2.txt0
-rw-r--r--[-rwxr-xr-x]utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest.py (renamed from utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest)0
-rw-r--r--[-rwxr-xr-x]utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest.py (renamed from utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest)0
-rw-r--r--[-rwxr-xr-x]utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py (renamed from utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest)0
-rw-r--r--utils/lit/tests/Inputs/max-failures/lit.cfg6
-rw-r--r--utils/lit/tests/Inputs/py-config-discovery/lit.site.cfg.py5
-rw-r--r--utils/lit/tests/Inputs/shtest-env/env-u.txt23
-rw-r--r--utils/lit/tests/Inputs/shtest-env/env.txt15
-rw-r--r--utils/lit/tests/Inputs/shtest-env/lit.cfg9
-rw-r--r--utils/lit/tests/Inputs/shtest-env/mixed.txt18
-rw-r--r--utils/lit/tests/Inputs/shtest-env/print_environment.py8
-rw-r--r--utils/lit/tests/Inputs/shtest-env/shtest-env.py3
-rw-r--r--utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt2
-rw-r--r--utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.py6
-rwxr-xr-xutils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh3
-rw-r--r--utils/lit/tests/Inputs/shtest-format/lit.cfg1
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/check_path.py28
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/diff-error-1.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/diff-error-2.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/diff-error-3.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/diff-error-4.txt5
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/diff-error-5.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/diff-error-6.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/lit.cfg1
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/mkdir-error-0.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/mkdir-error-1.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/mkdir-error-2.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/redirects.txt6
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/rm-error-0.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/rm-error-1.txt3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/rm-error-2.txt4
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/rm-error-3.txt4
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/valid-shell.txt87
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/write-to-stderr.py7
-rwxr-xr-xutils/lit/tests/Inputs/shtest-shell/write-to-stderr.sh3
-rw-r--r--utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.py10
-rwxr-xr-xutils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.sh4
-rw-r--r--utils/lit/tests/discovery.py95
-rw-r--r--utils/lit/tests/googletest-format.py13
-rw-r--r--utils/lit/tests/googletest-timeout.py6
-rw-r--r--utils/lit/tests/googletest-upstream-format.py10
-rw-r--r--utils/lit/tests/lit.cfg23
-rw-r--r--utils/lit/tests/lit.site.cfg.in20
-rw-r--r--utils/lit/tests/max-failures.py2
-rw-r--r--utils/lit/tests/selecting.py1
-rw-r--r--utils/lit/tests/shtest-format.py2
-rw-r--r--utils/lit/tests/shtest-output-printing.py2
-rw-r--r--utils/lit/tests/shtest-shell.py121
-rw-r--r--utils/lit/tests/shtest-timeout.py3
-rw-r--r--utils/lit/tests/unit/TestRunner.py1
56 files changed, 558 insertions, 58 deletions
diff --git a/utils/lit/tests/Inputs/config-map-discovery/driver.py b/utils/lit/tests/Inputs/config-map-discovery/driver.py
new file mode 100644
index 000000000000..db9141b9b1bf
--- /dev/null
+++ b/utils/lit/tests/Inputs/config-map-discovery/driver.py
@@ -0,0 +1,16 @@
+import lit.util
+import os
+import sys
+
+main_config = sys.argv[1]
+main_config = os.path.realpath(main_config)
+main_config = os.path.normcase(main_config)
+
+config_map = {main_config : sys.argv[2]}
+builtin_parameters = {'config_map' : config_map}
+
+if __name__=='__main__':
+ from lit.main import main
+ main_config_dir = os.path.dirname(main_config)
+ sys.argv = [sys.argv[0]] + sys.argv[3:] + [main_config_dir]
+ main(builtin_parameters)
diff --git a/utils/lit/tests/Inputs/config-map-discovery/invalid-test.txt b/utils/lit/tests/Inputs/config-map-discovery/invalid-test.txt
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/utils/lit/tests/Inputs/config-map-discovery/invalid-test.txt
diff --git a/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg b/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
new file mode 100644
index 000000000000..c7b303f50a05
--- /dev/null
+++ b/utils/lit/tests/Inputs/config-map-discovery/lit.alt.cfg
@@ -0,0 +1,9 @@
+import lit.formats
+import lit.util
+config.name = 'config-map'
+config.suffixes = ['.txt']
+config.test_format = lit.formats.ShTest()
+
+import os
+config.test_exec_root = os.path.realpath(os.path.dirname(__file__))
+config.test_source_root = os.path.join(config.test_exec_root, "tests")
diff --git a/utils/lit/tests/Inputs/config-map-discovery/main-config/lit.cfg b/utils/lit/tests/Inputs/config-map-discovery/main-config/lit.cfg
new file mode 100644
index 000000000000..380a05beb4a8
--- /dev/null
+++ b/utils/lit/tests/Inputs/config-map-discovery/main-config/lit.cfg
@@ -0,0 +1 @@
+print("ERROR: lit.cfg invoked!") \ No newline at end of file
diff --git a/utils/lit/tests/Inputs/config-map-discovery/tests/test1.txt b/utils/lit/tests/Inputs/config-map-discovery/tests/test1.txt
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/utils/lit/tests/Inputs/config-map-discovery/tests/test1.txt
diff --git a/utils/lit/tests/Inputs/config-map-discovery/tests/test2.txt b/utils/lit/tests/Inputs/config-map-discovery/tests/test2.txt
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/utils/lit/tests/Inputs/config-map-discovery/tests/test2.txt
diff --git a/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest b/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest.py
index dd49f025b1f2..dd49f025b1f2 100755..100644
--- a/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest
+++ b/utils/lit/tests/Inputs/googletest-format/DummySubDir/OneTest.py
diff --git a/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest b/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest.py
index f3a90ff4cd67..f3a90ff4cd67 100755..100644
--- a/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest
+++ b/utils/lit/tests/Inputs/googletest-timeout/DummySubDir/OneTest.py
diff --git a/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest b/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py
index d7bc5968f261..d7bc5968f261 100755..100644
--- a/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest
+++ b/utils/lit/tests/Inputs/googletest-upstream-format/DummySubDir/OneTest.py
diff --git a/utils/lit/tests/Inputs/max-failures/lit.cfg b/utils/lit/tests/Inputs/max-failures/lit.cfg
index 50d07566e1cc..605bd7233670 100644
--- a/utils/lit/tests/Inputs/max-failures/lit.cfg
+++ b/utils/lit/tests/Inputs/max-failures/lit.cfg
@@ -1,6 +1,2 @@
-import lit.formats
-config.name = 'shtest-shell'
-config.suffixes = ['.txt']
-config.test_format = lit.formats.ShTest()
+lit_config.load_config(config, os.path.dirname(__file__) + "/../shtest-shell/lit.cfg")
config.test_source_root = os.path.dirname(__file__) + '/../shtest-shell'
-config.test_exec_root = None
diff --git a/utils/lit/tests/Inputs/py-config-discovery/lit.site.cfg.py b/utils/lit/tests/Inputs/py-config-discovery/lit.site.cfg.py
new file mode 100644
index 000000000000..ac273c797c5f
--- /dev/null
+++ b/utils/lit/tests/Inputs/py-config-discovery/lit.site.cfg.py
@@ -0,0 +1,5 @@
+# Load the discovery suite, but with a separate exec root.
+import os
+config.test_exec_root = os.path.dirname(__file__)
+config.test_source_root = os.path.join(os.path.dirname(config.test_exec_root), "discovery")
+lit_config.load_config(config, os.path.join(config.test_source_root, "lit.cfg"))
diff --git a/utils/lit/tests/Inputs/shtest-env/env-u.txt b/utils/lit/tests/Inputs/shtest-env/env-u.txt
new file mode 100644
index 000000000000..9cdf9d08850f
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-env/env-u.txt
@@ -0,0 +1,23 @@
+# Check and make sure preset environment variable were set in lit.cfg
+#
+# RUN: %{python} print_environment.py \
+# RUN: | FileCheck --check-prefix=CHECK-ENV-PRESET %s
+#
+# Check single unset of environment variable
+#
+# RUN: env -u FOO %{python} print_environment.py \
+# RUN: | FileCheck --check-prefix=CHECK-ENV-UNSET-1 %s
+#
+# Check multiple unsets of environment variables
+#
+# RUN: env -u FOO -u BAR %{python} print_environment.py \
+# RUN: | FileCheck --check-prefix=CHECK-ENV-UNSET-MULTIPLE %s
+
+# CHECK-ENV-PRESET: BAR = 2
+# CHECK-ENV-PRESET: FOO = 1
+
+# CHECK-ENV-UNSET-1: BAR = 2
+# CHECK-ENV-UNSET-1-NOT: FOO
+
+# CHECK-ENV-UNSET-MULTIPLE-NOT: BAR
+# CHECK-ENV-UNSET-MULTIPLE-NOT: FOO
diff --git a/utils/lit/tests/Inputs/shtest-env/env.txt b/utils/lit/tests/Inputs/shtest-env/env.txt
new file mode 100644
index 000000000000..aa697b0c4081
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-env/env.txt
@@ -0,0 +1,15 @@
+# Check for simple one environment variable setting
+#
+# RUN: env A_FOO=999 %{python} print_environment.py \
+# RUN: | FileCheck --check-prefix=CHECK-ENV-1 %s
+#
+# Check for multiple environment variable settings
+#
+# RUN: env A_FOO=1 B_BAR=2 C_OOF=3 %{python} print_environment.py \
+# RUN: | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
+
+# CHECK-ENV-1: A_FOO = 999
+
+# CHECK-ENV-MULTIPLE: A_FOO = 1
+# CHECK-ENV-MULTIPLE: B_BAR = 2
+# CHECK-ENV-MULTIPLE: C_OOF = 3
diff --git a/utils/lit/tests/Inputs/shtest-env/lit.cfg b/utils/lit/tests/Inputs/shtest-env/lit.cfg
new file mode 100644
index 000000000000..23ef60a4b21e
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-env/lit.cfg
@@ -0,0 +1,9 @@
+import lit.formats
+config.name = 'shtest-env'
+config.suffixes = ['.txt']
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
+config.environment['FOO'] = '1'
+config.environment['BAR'] = '2'
+config.substitutions.append(('%{python}', sys.executable))
diff --git a/utils/lit/tests/Inputs/shtest-env/mixed.txt b/utils/lit/tests/Inputs/shtest-env/mixed.txt
new file mode 100644
index 000000000000..be32d458843b
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-env/mixed.txt
@@ -0,0 +1,18 @@
+# Check for setting and removing one environment variable
+#
+# RUN: env A_FOO=999 -u FOO %{python} print_environment.py \
+# RUN: | FileCheck --check-prefix=CHECK-ENV-1 %s
+#
+# Check for setting/unsetting multiple environment variables
+#
+# RUN: env A_FOO=1 -u FOO B_BAR=2 -u BAR C_OOF=3 %{python} print_environment.py \
+# RUN: | FileCheck --check-prefix=CHECK-ENV-MULTIPLE %s
+
+# CHECK-ENV-1: A_FOO = 999
+# CHECK-ENV-1-NOT: FOO
+
+# CHECK-ENV-MULTIPLE: A_FOO = 1
+# CHECK-ENV-MULTIPLE-NOT: BAR
+# CHECK-ENV-MULTIPLE: B_BAR = 2
+# CHECK-ENV-MULTIPLE: C_OOF = 3
+# CHECK-ENV-MULTIPLE-NOT: FOO
diff --git a/utils/lit/tests/Inputs/shtest-env/print_environment.py b/utils/lit/tests/Inputs/shtest-env/print_environment.py
new file mode 100644
index 000000000000..1add4079d58f
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-env/print_environment.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+
+import os
+
+sorted_environment = sorted(os.environ.items())
+
+for name,value in sorted_environment:
+ print name,'=',value
diff --git a/utils/lit/tests/Inputs/shtest-env/shtest-env.py b/utils/lit/tests/Inputs/shtest-env/shtest-env.py
new file mode 100644
index 000000000000..fc5f973e676f
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-env/shtest-env.py
@@ -0,0 +1,3 @@
+# Check the env command
+#
+# RUN: %{lit} -a -v %{inputs}/shtest-env
diff --git a/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt b/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt
index f6157e66c97c..ce38831e32ed 100644
--- a/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt
+++ b/utils/lit/tests/Inputs/shtest-format/external_shell/fail_with_bad_encoding.txt
@@ -1,5 +1,5 @@
# Run a command that fails with error on stdout.
#
-# RUN: %S/write-bad-encoding.sh
+# RUN: "%{python}" %S/write-bad-encoding.py
# RUN: false
diff --git a/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.py b/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.py
new file mode 100644
index 000000000000..a5a2bc9da8af
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.py
@@ -0,0 +1,6 @@
+#!/usr/bin/env python
+
+import sys
+
+getattr(sys.stdout, "buffer", sys.stdout).write(b"a line with bad encoding: \xc2.")
+sys.stdout.flush()
diff --git a/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh b/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh
deleted file mode 100755
index 6b622cb232e2..000000000000
--- a/utils/lit/tests/Inputs/shtest-format/external_shell/write-bad-encoding.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-echo "a line with bad encoding: Â."
diff --git a/utils/lit/tests/Inputs/shtest-format/lit.cfg b/utils/lit/tests/Inputs/shtest-format/lit.cfg
index 9b47985a3d86..0d6488848b4f 100644
--- a/utils/lit/tests/Inputs/shtest-format/lit.cfg
+++ b/utils/lit/tests/Inputs/shtest-format/lit.cfg
@@ -6,3 +6,4 @@ config.test_source_root = None
config.test_exec_root = None
config.target_triple = 'x86_64-unknown-unknown'
config.available_features.add('a-present-feature')
+config.substitutions.append(('%{python}', sys.executable))
diff --git a/utils/lit/tests/Inputs/shtest-shell/check_path.py b/utils/lit/tests/Inputs/shtest-shell/check_path.py
new file mode 100644
index 000000000000..c1d279700de4
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/check_path.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python
+
+import os
+import sys
+
+
+def check_path(argv):
+ if len(argv) < 3:
+ print("Wrong number of args")
+ return 1
+
+ type = argv[1]
+ paths = argv[2:]
+ exit_code = 0
+
+ if type == 'dir':
+ for idx, dir in enumerate(paths):
+ print(os.path.isdir(dir))
+ elif type == 'file':
+ for idx, file in enumerate(paths):
+ print(os.path.isfile(file))
+ else:
+ print("Unrecognised type {}".format(type))
+ exit_code = 1
+ return exit_code
+
+if __name__ == '__main__':
+ sys.exit (check_path (sys.argv))
diff --git a/utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt b/utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt
new file mode 100644
index 000000000000..81888cf81974
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/diff-error-0.txt
@@ -0,0 +1,3 @@
+# Check error on a unsupported diff (cannot be part of a pipeline).
+#
+# RUN: diff diff-error-0.txt diff-error-0.txt | echo Output
diff --git a/utils/lit/tests/Inputs/shtest-shell/diff-error-1.txt b/utils/lit/tests/Inputs/shtest-shell/diff-error-1.txt
new file mode 100644
index 000000000000..9836e0ea9d45
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/diff-error-1.txt
@@ -0,0 +1,3 @@
+# Check error on a unsupported diff (not support the -B option).
+#
+# RUN: diff -B temp1.txt temp2.txt
diff --git a/utils/lit/tests/Inputs/shtest-shell/diff-error-2.txt b/utils/lit/tests/Inputs/shtest-shell/diff-error-2.txt
new file mode 100644
index 000000000000..9c0da6aa6f69
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/diff-error-2.txt
@@ -0,0 +1,3 @@
+# Check error on an internal shell error (missing tofile)
+#
+# RUN: diff temp.txt
diff --git a/utils/lit/tests/Inputs/shtest-shell/diff-error-3.txt b/utils/lit/tests/Inputs/shtest-shell/diff-error-3.txt
new file mode 100644
index 000000000000..31128193c019
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/diff-error-3.txt
@@ -0,0 +1,3 @@
+# Check error on an internal shell error (unable to find compared files)
+#
+# RUN: diff temp.txt temp1.txt
diff --git a/utils/lit/tests/Inputs/shtest-shell/diff-error-4.txt b/utils/lit/tests/Inputs/shtest-shell/diff-error-4.txt
new file mode 100644
index 000000000000..8569e33e284a
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/diff-error-4.txt
@@ -0,0 +1,5 @@
+# Check exit code error (file's contents are different)
+#
+# RUN: echo "hello-first" > %t
+# RUN: echo "hello-second" > %t1
+# RUN: diff %t %t1
diff --git a/utils/lit/tests/Inputs/shtest-shell/diff-error-5.txt b/utils/lit/tests/Inputs/shtest-shell/diff-error-5.txt
new file mode 100644
index 000000000000..6d8d2e5c334d
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/diff-error-5.txt
@@ -0,0 +1,3 @@
+# Check error on an internal shell error (missing operand)
+#
+# RUN: diff -u
diff --git a/utils/lit/tests/Inputs/shtest-shell/diff-error-6.txt b/utils/lit/tests/Inputs/shtest-shell/diff-error-6.txt
new file mode 100644
index 000000000000..cc13d13c6475
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/diff-error-6.txt
@@ -0,0 +1,3 @@
+# Check error on an internal shell error (extra operand)
+#
+# RUN: diff -u a.txt b.txt c.txt
diff --git a/utils/lit/tests/Inputs/shtest-shell/lit.cfg b/utils/lit/tests/Inputs/shtest-shell/lit.cfg
index 7f31129ad114..761dc6748855 100644
--- a/utils/lit/tests/Inputs/shtest-shell/lit.cfg
+++ b/utils/lit/tests/Inputs/shtest-shell/lit.cfg
@@ -4,3 +4,4 @@ config.suffixes = ['.txt']
config.test_format = lit.formats.ShTest()
config.test_source_root = None
config.test_exec_root = None
+config.substitutions.append(('%{python}', sys.executable))
diff --git a/utils/lit/tests/Inputs/shtest-shell/mkdir-error-0.txt b/utils/lit/tests/Inputs/shtest-shell/mkdir-error-0.txt
new file mode 100644
index 000000000000..c29d42110670
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/mkdir-error-0.txt
@@ -0,0 +1,3 @@
+# Check error on a unsupported mkdir (cannot be part of a pipeline).
+#
+# RUN: mkdir -p temp | rm -rf temp
diff --git a/utils/lit/tests/Inputs/shtest-shell/mkdir-error-1.txt b/utils/lit/tests/Inputs/shtest-shell/mkdir-error-1.txt
new file mode 100644
index 000000000000..8931f3d54eb4
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/mkdir-error-1.txt
@@ -0,0 +1,3 @@
+# Check error on a unsupported mkdir (only does not support -m option).
+#
+# RUN: mkdir -p -m 777 temp
diff --git a/utils/lit/tests/Inputs/shtest-shell/mkdir-error-2.txt b/utils/lit/tests/Inputs/shtest-shell/mkdir-error-2.txt
new file mode 100644
index 000000000000..401dbecf14b2
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/mkdir-error-2.txt
@@ -0,0 +1,3 @@
+# Check error on a unsupported mkdir (missing operand).
+#
+# RUN: mkdir -p
diff --git a/utils/lit/tests/Inputs/shtest-shell/redirects.txt b/utils/lit/tests/Inputs/shtest-shell/redirects.txt
index 6be88b67ce1b..f90c2b7868b7 100644
--- a/utils/lit/tests/Inputs/shtest-shell/redirects.txt
+++ b/utils/lit/tests/Inputs/shtest-shell/redirects.txt
@@ -17,13 +17,13 @@
# Check stderr redirect (2> and 2>>).
#
# RUN: echo "not-present" > %t.stderr-write
-# RUN: %S/write-to-stderr.sh 2> %t.stderr-write
+# RUN: "%{python}" %S/write-to-stderr.py 2> %t.stderr-write
# RUN: FileCheck --check-prefix=STDERR-WRITE < %t.stderr-write %s
#
# STDERR-WRITE-NOT: not-present
# STDERR-WRITE: a line on stderr
#
-# RUN: %S/write-to-stderr.sh 2>> %t.stderr-write
+# RUN: "%{python}" %S/write-to-stderr.py 2>> %t.stderr-write
# RUN: FileCheck --check-prefix=STDERR-APPEND < %t.stderr-write %s
#
# STDERR-APPEND: a line on stderr
@@ -33,7 +33,7 @@
# Check combined redirect (&>).
#
# RUN: echo "not-present" > %t.combined
-# RUN: %S/write-to-stdout-and-stderr.sh &> %t.combined
+# RUN: "%{python}" %S/write-to-stdout-and-stderr.py &> %t.combined
# RUN: FileCheck --check-prefix=COMBINED-WRITE < %t.combined %s
#
# COMBINED-WRITE-NOT: not-present
diff --git a/utils/lit/tests/Inputs/shtest-shell/rm-error-0.txt b/utils/lit/tests/Inputs/shtest-shell/rm-error-0.txt
new file mode 100644
index 000000000000..52966a813c4a
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/rm-error-0.txt
@@ -0,0 +1,3 @@
+# Check error on a unsupported rm. (cannot be part of a pipeline)
+#
+# RUN: rm -rf temp | echo "hello"
diff --git a/utils/lit/tests/Inputs/shtest-shell/rm-error-1.txt b/utils/lit/tests/Inputs/shtest-shell/rm-error-1.txt
new file mode 100644
index 000000000000..5065ea744207
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/rm-error-1.txt
@@ -0,0 +1,3 @@
+# Check error on a unsupported rm (only does not support -v option).
+#
+# RUN: rm -f -v temp
diff --git a/utils/lit/tests/Inputs/shtest-shell/rm-error-2.txt b/utils/lit/tests/Inputs/shtest-shell/rm-error-2.txt
new file mode 100644
index 000000000000..71bfe0427b15
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/rm-error-2.txt
@@ -0,0 +1,4 @@
+# Check error on a unsupported rm (only supports -f option and in combination with -r).
+#
+#### RUN: rm -r hello
+# RUN: rm hello
diff --git a/utils/lit/tests/Inputs/shtest-shell/rm-error-3.txt b/utils/lit/tests/Inputs/shtest-shell/rm-error-3.txt
new file mode 100644
index 000000000000..1bab79aad082
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/rm-error-3.txt
@@ -0,0 +1,4 @@
+# Check error on a unsupported rm (can't remove test since it is a directory).
+#
+# RUN: mkdir -p test
+# RUN: rm -f test
diff --git a/utils/lit/tests/Inputs/shtest-shell/valid-shell.txt b/utils/lit/tests/Inputs/shtest-shell/valid-shell.txt
new file mode 100644
index 000000000000..d5cbf863e735
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/valid-shell.txt
@@ -0,0 +1,87 @@
+# Check rm file operations.
+# Check force remove commands success whether the file does or doesn't exist.
+#
+# RUN: rm -f %t.write
+# RUN: "%{python}" %S/check_path.py file %t.write > %t.out
+# RUN: FileCheck --check-prefix=REMOVE-FILE < %t.out %s
+# RUN: echo "create a temp file" > %t.write
+# RUN: "%{python}" %S/check_path.py file %t.write > %t.out
+# RUN: FileCheck --check-prefix=FILE-EXIST < %t.out %s
+# RUN: rm -f %t.write
+# RUN: "%{python}" %S/check_path.py file %t.write > %t.out
+# RUN: FileCheck --check-prefix=REMOVE-FILE < %t.out %s
+#
+# REMOVE-FILE: False
+# FILE-EXIST: True
+#
+# Check mkdir and rm folder operations.
+# Check force remove commands success whether the directory does or doesn't exist.
+#
+# Check the mkdir command with -p option.
+# RUN: rm -f -r %T/test
+# RUN: "%{python}" %S/check_path.py dir %T/test > %t.out
+# RUN: FileCheck --check-prefix=REMOVE-PARENT-DIR < %t.out %s
+# RUN: mkdir -p %T/test
+# RUN: "%{python}" %S/check_path.py dir %T/test > %t.out
+# RUN: FileCheck --check-prefix=MAKE-PARENT-DIR < %t.out %s
+# RUN: rm -f %T/test || true
+# RUN: rm -f -r %T/test
+# RUN: "%{python}" %S/check_path.py dir %T/test > %t.out
+# RUN: FileCheck --check-prefix=REMOVE-PARENT-DIR < %t.out %s
+#
+# MAKE-PARENT-DIR: True
+# REMOVE-PARENT-DIR: False
+#
+# Check the mkdir command without -p option.
+#
+# RUN: rm -rf %T/test1
+# RUN: mkdir %T/test1
+# RUN: "%{python}" %S/check_path.py dir %T/test1 > %t.out
+# RUN: FileCheck --check-prefix=MAKE-DIR < %t.out %s
+# RUN: cd %T/test1 && mkdir foo
+# RUN: "%{python}" %S/check_path.py dir %T/test1 > %t.out
+# RUN: FileCheck --check-prefix=MAKE-DIR < %t.out %s
+# RUN: cd %T && rm -rf %T/test1
+# RUN: "%{python}" %S/check_path.py dir %T/test1 > %t.out
+# RUN: FileCheck --check-prefix=REMOVE-DIR < %t.out %s
+#
+# MAKE-DIR: True
+# REMOVE-DIR: False
+#
+# Check creating and removing multiple folders and rm * operation.
+#
+# RUN: rm -rf %T/test
+# RUN: mkdir -p %T/test/test1 %T/test/test2
+# RUN: "%{python}" %S/check_path.py dir %T/test %T/test/test1 %T/test/test2 > %t.out
+# RUN: FileCheck --check-prefix=DIRS-EXIST < %t.out %s
+# RUN: mkdir %T/test || true
+# RUN: echo "create a temp file" > %T/test/temp.write
+# RUN: echo "create a temp1 file" > %T/test/test1/temp1.write
+# RUN: echo "create a temp2 file" > %T/test/test2/temp2.write
+# RUN: "%{python}" %S/check_path.py file %T/test/temp.write %T/test/test1/temp1.write %T/test/test2/temp2.write> %t.out
+# RUN: FileCheck --check-prefix=FILES-EXIST < %t.out %s
+# RUN: rm -r -f %T/*
+# RUN: "%{python}" %S/check_path.py dir %T/test > %t.out
+# RUN: FileCheck --check-prefix=REMOVE-ALL < %t.out %s
+#
+# DIRS-EXIST: True
+# DIRS-EXIST-NEXT: True
+# DIRS-EXIST-NEXT: True
+# FILES-EXIST: True
+# FILES-EXIST-NEXT: True
+# FILES-EXIST-NEXT: True
+# REMOVE-ALL: False
+#
+# Check diff operations.
+#
+# RUN: echo "hello" > %t.stdout
+# RUN: echo "hello" > %t1.stdout
+# RUN: diff %t.stdout %t1.stdout
+# RUN: diff -u %t.stdout %t1.stdout
+# RUN: echo "hello-2" > %t1.stdout
+# RUN: diff %t.stdout %t1.stdout || true
+#
+# RUN: mkdir -p %T/dir1 %T/dir2
+# RUN: cd %T/dir1 && echo "hello" > temp1.txt
+# RUN: cd %T/dir2 && echo "hello" > temp2.txt
+# RUN: diff temp2.txt ../dir1/temp1.txt
diff --git a/utils/lit/tests/Inputs/shtest-shell/write-to-stderr.py b/utils/lit/tests/Inputs/shtest-shell/write-to-stderr.py
new file mode 100644
index 000000000000..9463251d823a
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/write-to-stderr.py
@@ -0,0 +1,7 @@
+#!/usr/bin/env python
+
+import sys
+
+
+sys.stderr.write("a line on stderr\n")
+sys.stderr.flush()
diff --git a/utils/lit/tests/Inputs/shtest-shell/write-to-stderr.sh b/utils/lit/tests/Inputs/shtest-shell/write-to-stderr.sh
deleted file mode 100755
index ead3fd3ce377..000000000000
--- a/utils/lit/tests/Inputs/shtest-shell/write-to-stderr.sh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-echo "a line on stderr" 1>&2
diff --git a/utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.py b/utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.py
new file mode 100644
index 000000000000..357089d4899b
--- /dev/null
+++ b/utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.py
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+
+import sys
+
+
+sys.stdout.write("a line on stdout\n")
+sys.stdout.flush()
+
+sys.stderr.write("a line on stderr\n")
+sys.stderr.flush()
diff --git a/utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.sh b/utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.sh
deleted file mode 100755
index f20de5d9042d..000000000000
--- a/utils/lit/tests/Inputs/shtest-shell/write-to-stdout-and-stderr.sh
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-
-echo "a line on stdout"
-echo "a line on stderr" 1>&2
diff --git a/utils/lit/tests/discovery.py b/utils/lit/tests/discovery.py
index 55e54088b587..dbabeb39f19f 100644
--- a/utils/lit/tests/discovery.py
+++ b/utils/lit/tests/discovery.py
@@ -6,17 +6,17 @@
# RUN: FileCheck --check-prefix=CHECK-BASIC-OUT < %t.out %s
# RUN: FileCheck --check-prefix=CHECK-BASIC-ERR < %t.err %s
#
-# CHECK-BASIC-ERR: loading suite config '{{.*}}/discovery/lit.cfg'
-# CHECK-BASIC-ERR-DAG: loading suite config '{{.*}}/discovery/subsuite/lit.cfg'
-# CHECK-BASIC-ERR-DAG: loading local config '{{.*}}/discovery/subdir/lit.local.cfg'
+# CHECK-BASIC-ERR: loading suite config '{{.*(/|\\\\)discovery(/|\\\\)lit.cfg}}'
+# CHECK-BASIC-ERR-DAG: loading suite config '{{.*(/|\\\\)discovery(/|\\\\)subsuite(/|\\\\)lit.cfg}}'
+# CHECK-BASIC-ERR-DAG: loading local config '{{.*(/|\\\\)discovery(/|\\\\)subdir(/|\\\\)lit.local.cfg}}'
#
# CHECK-BASIC-OUT: -- Test Suites --
# CHECK-BASIC-OUT: sub-suite - 2 tests
-# CHECK-BASIC-OUT: Source Root: {{.*/discovery/subsuite$}}
-# CHECK-BASIC-OUT: Exec Root : {{.*/discovery/subsuite$}}
+# CHECK-BASIC-OUT: Source Root: {{.*[/\\]discovery[/\\]subsuite$}}
+# CHECK-BASIC-OUT: Exec Root : {{.*[/\\]discovery[/\\]subsuite$}}
# CHECK-BASIC-OUT: top-level-suite - 3 tests
-# CHECK-BASIC-OUT: Source Root: {{.*/discovery$}}
-# CHECK-BASIC-OUT: Exec Root : {{.*/discovery$}}
+# CHECK-BASIC-OUT: Source Root: {{.*[/\\]discovery$}}
+# CHECK-BASIC-OUT: Exec Root : {{.*[/\\]discovery$}}
#
# CHECK-BASIC-OUT: -- Available Tests --
# CHECK-BASIC-OUT: sub-suite :: test-one
@@ -25,6 +25,28 @@
# CHECK-BASIC-OUT: top-level-suite :: test-one
# CHECK-BASIC-OUT: top-level-suite :: test-two
+# Check discovery when providing the special builtin 'config_map'
+# RUN: %{python} %{inputs}/config-map-discovery/driver.py \
+# RUN: %{inputs}/config-map-discovery/main-config/lit.cfg \
+# RUN: %{inputs}/config-map-discovery/lit.alt.cfg \
+# RUN: --single-process --debug --show-tests --show-suites > %t.out 2> %t.err
+# RUN: FileCheck --check-prefix=CHECK-CONFIG-MAP-OUT < %t.out %s
+# RUN: FileCheck --check-prefix=CHECK-CONFIG-MAP-ERR < %t.err %s
+
+# CHECK-CONFIG-MAP-OUT-NOT: ERROR: lit.cfg invoked
+# CHECK-CONFIG-MAP-OUT: -- Test Suites --
+# CHECK-CONFIG-MAP-OUT: config-map - 2 tests
+# CHECK-CONFIG-MAP-OUT: Source Root: {{.*[/\\]config-map-discovery[/\\]tests}}
+# CHECK-CONFIG-MAP-OUT: Exec Root : {{.*[/\\]tests[/\\]Inputs[/\\]config-map-discovery}}
+# CHECK-CONFIG-MAP-OUT: -- Available Tests --
+# CHECK-CONFIG-MAP-OUT-NOT: invalid-test.txt
+# CHECK-CONFIG-MAP-OUT: config-map :: test1.txt
+# CHECK-CONFIG-MAP-OUT: config-map :: test2.txt
+
+# CHECK-CONFIG-MAP-ERR: loading suite config '{{.*}}lit.alt.cfg'
+# CHECK-CONFIG-MAP-ERR: loaded config '{{.*}}lit.alt.cfg'
+# CHECK-CONFIG-MAP-ERR: resolved input '{{.*(/|\\\\)config-map-discovery(/|\\\\)main-config}}' to 'config-map'::()
+
# Check discovery when exact test names are given.
#
@@ -38,6 +60,34 @@
# CHECK-EXACT-TEST: sub-suite :: test-one
# CHECK-EXACT-TEST: top-level-suite :: subdir/test-three
+# Check discovery when config files end in .py
+# RUN: %{lit} %{inputs}/py-config-discovery \
+# RUN: -j 1 --debug --show-tests --show-suites \
+# RUN: -v > %t.out 2> %t.err
+# RUN: FileCheck --check-prefix=CHECK-PYCONFIG-OUT < %t.out %s
+# RUN: FileCheck --check-prefix=CHECK-PYCONFIG-ERR < %t.err %s
+#
+# CHECK-PYCONFIG-ERR: loading suite config '{{.*(/|\\\\)py-config-discovery(/|\\\\)lit.site.cfg.py}}'
+# CHECK-PYCONFIG-ERR: load_config from '{{.*(/|\\\\)discovery(/|\\\\)lit.cfg}}'
+# CHECK-PYCONFIG-ERR: loaded config '{{.*(/|\\\\)discovery(/|\\\\)lit.cfg}}'
+# CHECK-PYCONFIG-ERR: loaded config '{{.*(/|\\\\)py-config-discovery(/|\\\\)lit.site.cfg.py}}'
+# CHECK-PYCONFIG-ERR-DAG: loading suite config '{{.*(/|\\\\)discovery(/|\\\\)subsuite(/|\\\\)lit.cfg}}'
+# CHECK-PYCONFIG-ERR-DAG: loading local config '{{.*(/|\\\\)discovery(/|\\\\)subdir(/|\\\\)lit.local.cfg}}'
+#
+# CHECK-PYCONFIG-OUT: -- Test Suites --
+# CHECK-PYCONFIG-OUT: sub-suite - 2 tests
+# CHECK-PYCONFIG-OUT: Source Root: {{.*[/\\]discovery[/\\]subsuite$}}
+# CHECK-PYCONFIG-OUT: Exec Root : {{.*[/\\]discovery[/\\]subsuite$}}
+# CHECK-PYCONFIG-OUT: top-level-suite - 3 tests
+# CHECK-PYCONFIG-OUT: Source Root: {{.*[/\\]discovery$}}
+# CHECK-PYCONFIG-OUT: Exec Root : {{.*[/\\]py-config-discovery$}}
+#
+# CHECK-PYCONFIG-OUT: -- Available Tests --
+# CHECK-PYCONFIG-OUT: sub-suite :: test-one
+# CHECK-PYCONFIG-OUT: sub-suite :: test-two
+# CHECK-PYCONFIG-OUT: top-level-suite :: subdir/test-three
+# CHECK-PYCONFIG-OUT: top-level-suite :: test-one
+# CHECK-PYCONFIG-OUT: top-level-suite :: test-two
# Check discovery when using an exec path.
#
@@ -47,20 +97,20 @@
# RUN: FileCheck --check-prefix=CHECK-ASEXEC-OUT < %t.out %s
# RUN: FileCheck --check-prefix=CHECK-ASEXEC-ERR < %t.err %s
#
-# CHECK-ASEXEC-ERR: loading suite config '{{.*}}/exec-discovery/lit.site.cfg'
-# CHECK-ASEXEC-ERR: load_config from '{{.*}}/discovery/lit.cfg'
-# CHECK-ASEXEC-ERR: loaded config '{{.*}}/discovery/lit.cfg'
-# CHECK-ASEXEC-ERR: loaded config '{{.*}}/exec-discovery/lit.site.cfg'
-# CHECK-ASEXEC-ERR-DAG: loading suite config '{{.*}}/discovery/subsuite/lit.cfg'
-# CHECK-ASEXEC-ERR-DAG: loading local config '{{.*}}/discovery/subdir/lit.local.cfg'
+# CHECK-ASEXEC-ERR: loading suite config '{{.*(/|\\\\)exec-discovery(/|\\\\)lit.site.cfg}}'
+# CHECK-ASEXEC-ERR: load_config from '{{.*(/|\\\\)discovery(/|\\\\)lit.cfg}}'
+# CHECK-ASEXEC-ERR: loaded config '{{.*(/|\\\\)discovery(/|\\\\)lit.cfg}}'
+# CHECK-ASEXEC-ERR: loaded config '{{.*(/|\\\\)exec-discovery(/|\\\\)lit.site.cfg}}'
+# CHECK-ASEXEC-ERR-DAG: loading suite config '{{.*(/|\\\\)discovery(/|\\\\)subsuite(/|\\\\)lit.cfg}}'
+# CHECK-ASEXEC-ERR-DAG: loading local config '{{.*(/|\\\\)discovery(/|\\\\)subdir(/|\\\\)lit.local.cfg}}'
#
# CHECK-ASEXEC-OUT: -- Test Suites --
# CHECK-ASEXEC-OUT: sub-suite - 2 tests
-# CHECK-ASEXEC-OUT: Source Root: {{.*/discovery/subsuite$}}
-# CHECK-ASEXEC-OUT: Exec Root : {{.*/discovery/subsuite$}}
+# CHECK-ASEXEC-OUT: Source Root: {{.*[/\\]discovery[/\\]subsuite$}}
+# CHECK-ASEXEC-OUT: Exec Root : {{.*[/\\]discovery[/\\]subsuite$}}
# CHECK-ASEXEC-OUT: top-level-suite - 3 tests
-# CHECK-ASEXEC-OUT: Source Root: {{.*/discovery$}}
-# CHECK-ASEXEC-OUT: Exec Root : {{.*/exec-discovery$}}
+# CHECK-ASEXEC-OUT: Source Root: {{.*[/\\]discovery$}}
+# CHECK-ASEXEC-OUT: Exec Root : {{.*[/\\]exec-discovery$}}
#
# CHECK-ASEXEC-OUT: -- Available Tests --
# CHECK-ASEXEC-OUT: sub-suite :: test-one
@@ -90,8 +140,15 @@
# RUN: -j 1 --show-tests --show-suites -v > %t.out
# RUN: FileCheck --check-prefix=CHECK-ASEXEC-INTREE < %t.out %s
#
+# Try it again after cd'ing into the test suite using a short relative path.
+#
+# RUN: cd %{inputs}/exec-discovery-in-tree/obj/
+# RUN: %{lit} . \
+# RUN: -j 1 --show-tests --show-suites -v > %t.out
+# RUN: FileCheck --check-prefix=CHECK-ASEXEC-INTREE < %t.out %s
+#
# CHECK-ASEXEC-INTREE: exec-discovery-in-tree-suite - 1 tests
-# CHECK-ASEXEC-INTREE-NEXT: Source Root: {{.*/exec-discovery-in-tree$}}
-# CHECK-ASEXEC-INTREE-NEXT: Exec Root : {{.*/exec-discovery-in-tree/obj$}}
+# CHECK-ASEXEC-INTREE-NEXT: Source Root: {{.*[/\\]exec-discovery-in-tree$}}
+# CHECK-ASEXEC-INTREE-NEXT: Exec Root : {{.*[/\\]exec-discovery-in-tree[/\\]obj$}}
# CHECK-ASEXEC-INTREE-NEXT: -- Available Tests --
# CHECK-ASEXEC-INTREE-NEXT: exec-discovery-in-tree-suite :: test-one
diff --git a/utils/lit/tests/googletest-format.py b/utils/lit/tests/googletest-format.py
index a62fd1b3ccaf..094c6cfc514c 100644
--- a/utils/lit/tests/googletest-format.py
+++ b/utils/lit/tests/googletest-format.py
@@ -1,19 +1,22 @@
# Check the various features of the GoogleTest format.
#
# RUN: not %{lit} -j 1 -v %{inputs}/googletest-format > %t.out
+# FIXME: Temporarily dump test output so we can debug failing tests on
+# buildbots.
+# RUN: cat %t.out
# RUN: FileCheck < %t.out %s
#
# END.
# CHECK: -- Testing:
-# CHECK: PASS: googletest-format :: DummySubDir/OneTest/FirstTest.subTestA
-# CHECK: FAIL: googletest-format :: DummySubDir/OneTest/FirstTest.subTestB
-# CHECK-NEXT: *** TEST 'googletest-format :: DummySubDir/OneTest/FirstTest.subTestB' FAILED ***
+# CHECK: PASS: googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestA
+# CHECK: FAIL: googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB
+# CHECK-NEXT: *** TEST 'googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB' FAILED ***
# CHECK-NEXT: I am subTest B, I FAIL
# CHECK-NEXT: And I have two lines of output
# CHECK: ***
-# CHECK: PASS: googletest-format :: DummySubDir/OneTest/ParameterizedTest/0.subTest
-# CHECK: PASS: googletest-format :: DummySubDir/OneTest/ParameterizedTest/1.subTest
+# CHECK: PASS: googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/ParameterizedTest/0.subTest
+# CHECK: PASS: googletest-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/ParameterizedTest/1.subTest
# CHECK: Failing Tests (1)
# CHECK: Expected Passes : 3
# CHECK: Unexpected Failures: 1
diff --git a/utils/lit/tests/googletest-timeout.py b/utils/lit/tests/googletest-timeout.py
index 46acf32b3a61..8b7d10fc1f03 100644
--- a/utils/lit/tests/googletest-timeout.py
+++ b/utils/lit/tests/googletest-timeout.py
@@ -13,9 +13,9 @@
# RUN: FileCheck < %t.cfgset.out %s
# CHECK: -- Testing:
-# CHECK: PASS: googletest-timeout :: DummySubDir/OneTest/FirstTest.subTestA
-# CHECK: TIMEOUT: googletest-timeout :: DummySubDir/OneTest/FirstTest.subTestB
-# CHECK: TIMEOUT: googletest-timeout :: DummySubDir/OneTest/FirstTest.subTestC
+# CHECK: PASS: googletest-timeout :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestA
+# CHECK: TIMEOUT: googletest-timeout :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB
+# CHECK: TIMEOUT: googletest-timeout :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestC
# CHECK: Expected Passes : 1
# CHECK: Individual Timeouts: 2
diff --git a/utils/lit/tests/googletest-upstream-format.py b/utils/lit/tests/googletest-upstream-format.py
index 1fc7c7c4a5ad..938740d80e7b 100644
--- a/utils/lit/tests/googletest-upstream-format.py
+++ b/utils/lit/tests/googletest-upstream-format.py
@@ -6,15 +6,15 @@
# END.
# CHECK: -- Testing:
-# CHECK: PASS: googletest-upstream-format :: DummySubDir/OneTest/FirstTest.subTestA
-# CHECK: FAIL: googletest-upstream-format :: DummySubDir/OneTest/FirstTest.subTestB
-# CHECK-NEXT: *** TEST 'googletest-upstream-format :: DummySubDir/OneTest/FirstTest.subTestB' FAILED ***
+# CHECK: PASS: googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestA
+# CHECK: FAIL: googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB
+# CHECK-NEXT: *** TEST 'googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/FirstTest.subTestB' FAILED ***
# CHECK-NEXT: Running main() from gtest_main.cc
# CHECK-NEXT: I am subTest B, I FAIL
# CHECK-NEXT: And I have two lines of output
# CHECK: ***
-# CHECK: PASS: googletest-upstream-format :: DummySubDir/OneTest/ParameterizedTest/0.subTest
-# CHECK: PASS: googletest-upstream-format :: DummySubDir/OneTest/ParameterizedTest/1.subTest
+# CHECK: PASS: googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/ParameterizedTest/0.subTest
+# CHECK: PASS: googletest-upstream-format :: {{[Dd]ummy[Ss]ub[Dd]ir}}/OneTest.py/ParameterizedTest/1.subTest
# CHECK: Failing Tests (1)
# CHECK: Expected Passes : 3
# CHECK: Unexpected Failures: 1
diff --git a/utils/lit/tests/lit.cfg b/utils/lit/tests/lit.cfg
index 4b38241d5a7d..75d1b5eac857 100644
--- a/utils/lit/tests/lit.cfg
+++ b/utils/lit/tests/lit.cfg
@@ -26,12 +26,20 @@ config.test_exec_root = config.test_source_root
config.target_triple = '(unused)'
src_root = os.path.join(config.test_source_root, '..')
-config.environment['PYTHONPATH'] = src_root
+llvm_src_root = getattr(config, 'llvm_src_root', None)
+if llvm_src_root != None:
+ # ``src_root`` may be in LLVM's binary build directory which does not contain
+ # ``lit.py``, so use `llvm_src_root` instead.
+ lit_path = os.path.join(llvm_src_root, 'utils', 'lit')
+else:
+ lit_path = src_root
+
+config.environment['PYTHONPATH'] = lit_path # Required because some tests import the lit module
config.substitutions.append(('%{src_root}', src_root))
config.substitutions.append(('%{inputs}', os.path.join(
src_root, 'tests', 'Inputs')))
config.substitutions.append(('%{lit}', "%%{python} %s" % (
- os.path.join(src_root, 'lit.py'),)))
+ os.path.join(lit_path, 'lit.py'),)))
config.substitutions.append(('%{python}', sys.executable))
# Enable coverage.py reporting, assuming the coverage module has been installed
@@ -52,3 +60,14 @@ try:
except ImportError:
lit_config.warning('Could not import psutil. Some tests will be skipped and'
' the --timeout command line argument will not work.')
+
+if sys.platform.startswith('win') or sys.platform.startswith('cygwin'):
+ config.available_features.add('windows')
+
+# Add llvm and lit tools directories if this config is being loaded indirectly.
+path = config.environment['PATH']
+for attribute in ('llvm_tools_dir', 'lit_tools_dir'):
+ directory = getattr(config, attribute, None)
+ if directory:
+ path = os.path.pathsep.join((directory, path))
+config.environment['PATH'] = path
diff --git a/utils/lit/tests/lit.site.cfg.in b/utils/lit/tests/lit.site.cfg.in
new file mode 100644
index 000000000000..693364c7c973
--- /dev/null
+++ b/utils/lit/tests/lit.site.cfg.in
@@ -0,0 +1,20 @@
+@LIT_SITE_CFG_IN_HEADER@
+
+import sys
+
+config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@"
+config.llvm_src_root = "@LLVM_SOURCE_DIR@"
+config.llvm_obj_root = "@LLVM_BINARY_DIR@"
+config.llvm_tools_dir = "@LLVM_TOOLS_DIR@"
+
+# Support substitution of the tools_dir with user parameters.
+# This is used when we can't determine the tool dir at configuration time.
+try:
+ config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params
+except KeyError:
+ e = sys.exc_info()[1]
+ key, = e.args
+ lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key))
+
+# Let the main config do the real work.
+lit_config.load_config(config, "@LLVM_BINARY_DIR@/utils/lit/tests/lit.cfg")
diff --git a/utils/lit/tests/max-failures.py b/utils/lit/tests/max-failures.py
index bc58e9a4e47f..c86d7b7fbdce 100644
--- a/utils/lit/tests/max-failures.py
+++ b/utils/lit/tests/max-failures.py
@@ -8,7 +8,7 @@
#
# END.
-# CHECK: Failing Tests (3)
+# CHECK: Failing Tests (17)
# CHECK: Failing Tests (1)
# CHECK: Failing Tests (2)
# CHECK: error: Setting --max-failures to 0 does not have any effect.
diff --git a/utils/lit/tests/selecting.py b/utils/lit/tests/selecting.py
index 4a0d08b860b8..25ac299d865d 100644
--- a/utils/lit/tests/selecting.py
+++ b/utils/lit/tests/selecting.py
@@ -1,7 +1,6 @@
# RUN: %{lit} %{inputs}/discovery | FileCheck --check-prefix=CHECK-BASIC %s
# CHECK-BASIC: Testing: 5 tests
-
# Check that regex-filtering works
#
# RUN: %{lit} --filter 'o[a-z]e' %{inputs}/discovery | FileCheck --check-prefix=CHECK-FILTER %s
diff --git a/utils/lit/tests/shtest-format.py b/utils/lit/tests/shtest-format.py
index 37e3e1c12629..94d74e3a9200 100644
--- a/utils/lit/tests/shtest-format.py
+++ b/utils/lit/tests/shtest-format.py
@@ -16,7 +16,7 @@
# CHECK-NEXT: line 2: failed test output on stdout
# CHECK: Command Output (stderr):
# CHECK-NEXT: --
-# CHECK-NEXT: cat: does-not-exist: No such file or directory
+# CHECK-NEXT: cat{{(\.exe)?}}: does-not-exist: No such file or directory
# CHECK: --
# CHECK: FAIL: shtest-format :: external_shell/fail_with_bad_encoding.txt
diff --git a/utils/lit/tests/shtest-output-printing.py b/utils/lit/tests/shtest-output-printing.py
index 24580b37f1f5..2a85cf975c9a 100644
--- a/utils/lit/tests/shtest-output-printing.py
+++ b/utils/lit/tests/shtest-output-printing.py
@@ -22,7 +22,7 @@
# CHECK-NEXT: hi
#
# CHECK: $ "wc" "missing-file"
-# CHECK-NEXT: # redirected output from '{{.*}}/basic.txt.tmp.out':
+# CHECK-NEXT: # redirected output from '{{.*(/|\\\\)}}basic.txt.tmp.out':
# CHECK-NEXT: 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
diff --git a/utils/lit/tests/shtest-shell.py b/utils/lit/tests/shtest-shell.py
index 18b80cd7d087..723842fce040 100644
--- a/utils/lit/tests/shtest-shell.py
+++ b/utils/lit/tests/shtest-shell.py
@@ -1,12 +1,76 @@
# Check the internal shell handling component of the ShTest format.
#
# RUN: not %{lit} -j 1 -v %{inputs}/shtest-shell > %t.out
+# FIXME: Temporarily dump test output so we can debug failing tests on
+# buildbots.
+# RUN: cat %t.out
# RUN: FileCheck --input-file %t.out %s
#
# END.
# CHECK: -- Testing:
+
+# CHECK: FAIL: shtest-shell :: diff-error-0.txt
+# CHECK: *** TEST 'shtest-shell :: diff-error-0.txt' FAILED ***
+# CHECK: $ "diff" "diff-error-0.txt" "diff-error-0.txt"
+# CHECK: # command stderr:
+# CHECK: Unsupported: 'diff' cannot be part of a pipeline
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: diff-error-1.txt
+# CHECK: *** TEST 'shtest-shell :: diff-error-1.txt' FAILED ***
+# CHECK: $ "diff" "-B" "temp1.txt" "temp2.txt"
+# CHECK: # command stderr:
+# CHECK: Unsupported: 'diff': option -B not recognized
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: diff-error-2.txt
+# CHECK: *** TEST 'shtest-shell :: diff-error-2.txt' FAILED ***
+# CHECK: $ "diff" "temp.txt"
+# CHECK: # command stderr:
+# CHECK: Error: missing or extra operand
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: diff-error-3.txt
+# CHECK: *** TEST 'shtest-shell :: diff-error-3.txt' FAILED ***
+# CHECK: $ "diff" "temp.txt" "temp1.txt"
+# CHECK: # command stderr:
+# CHECK: Error: 'diff' command failed
+# CHECK: error: command failed with exit status: 1
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: diff-error-4.txt
+# CHECK: *** TEST 'shtest-shell :: diff-error-4.txt' FAILED ***
+# CHECK: Exit Code: 1
+# CHECK: # command output:
+# CHECK: diff-error-4.txt.tmp
+# CHECK: diff-error-4.txt.tmp1
+# CHECK: *** 1 ****
+# CHECK: ! hello-first
+# CHECK: --- 1 ----
+# CHECK: ! hello-second
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: diff-error-5.txt
+# CHECK: *** TEST 'shtest-shell :: diff-error-5.txt' FAILED ***
+# CHECK: $ "diff"
+# CHECK: # command stderr:
+# CHECK: Error: missing or extra operand
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: diff-error-6.txt
+# CHECK: *** TEST 'shtest-shell :: diff-error-6.txt' FAILED ***
+# CHECK: $ "diff"
+# CHECK: # command stderr:
+# CHECK: Error: missing or extra operand
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
# CHECK: FAIL: shtest-shell :: error-0.txt
# CHECK: *** TEST 'shtest-shell :: error-0.txt' FAILED ***
# CHECK: $ "not-a-real-command"
@@ -27,7 +91,62 @@
# CHECK: Unsupported redirect:
# CHECK: ***
+# CHECK: FAIL: shtest-shell :: mkdir-error-0.txt
+# CHECK: *** TEST 'shtest-shell :: mkdir-error-0.txt' FAILED ***
+# CHECK: $ "mkdir" "-p" "temp"
+# CHECK: # command stderr:
+# CHECK: Unsupported: 'mkdir' cannot be part of a pipeline
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: mkdir-error-1.txt
+# CHECK: *** TEST 'shtest-shell :: mkdir-error-1.txt' FAILED ***
+# CHECK: $ "mkdir" "-p" "-m" "777" "temp"
+# CHECK: # command stderr:
+# CHECK: Unsupported: 'mkdir': option -m not recognized
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: mkdir-error-2.txt
+# CHECK: *** TEST 'shtest-shell :: mkdir-error-2.txt' FAILED ***
+# CHECK: $ "mkdir" "-p"
+# CHECK: # command stderr:
+# CHECK: Error: 'mkdir' is missing an operand
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
# CHECK: PASS: shtest-shell :: redirects.txt
+
+# CHECK: FAIL: shtest-shell :: rm-error-0.txt
+# CHECK: *** TEST 'shtest-shell :: rm-error-0.txt' FAILED ***
+# CHECK: $ "rm" "-rf" "temp"
+# CHECK: # command stderr:
+# CHECK: Unsupported: 'rm' cannot be part of a pipeline
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: rm-error-1.txt
+# CHECK: *** TEST 'shtest-shell :: rm-error-1.txt' FAILED ***
+# CHECK: $ "rm" "-f" "-v" "temp"
+# CHECK: # command stderr:
+# CHECK: Unsupported: 'rm': option -v not recognized
+# CHECK: error: command failed with exit status: 127
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: rm-error-2.txt
+# CHECK: *** TEST 'shtest-shell :: rm-error-2.txt' FAILED ***
+# CHECK: $ "rm" "-r" "hello"
+# CHECK: # command stderr:
+# CHECK: Error: 'rm' command failed
+# CHECK: error: command failed with exit status: 1
+# CHECK: ***
+
+# CHECK: FAIL: shtest-shell :: rm-error-3.txt
+# CHECK: *** TEST 'shtest-shell :: rm-error-3.txt' FAILED ***
+# CHECK: Exit Code: 1
+# CHECK: ***
+
# CHECK: PASS: shtest-shell :: sequencing-0.txt
# CHECK: XFAIL: shtest-shell :: sequencing-1.txt
-# CHECK: Failing Tests (3)
+# CHECK: PASS: shtest-shell :: valid-shell.txt
+# CHECK: Failing Tests (17)
diff --git a/utils/lit/tests/shtest-timeout.py b/utils/lit/tests/shtest-timeout.py
index 87f431de2500..879850065908 100644
--- a/utils/lit/tests/shtest-timeout.py
+++ b/utils/lit/tests/shtest-timeout.py
@@ -1,5 +1,8 @@
# REQUIRES: python-psutil
+# PR33944
+# XFAIL: windows
+
# Test per test timeout using external shell
# RUN: not %{lit} \
# RUN: %{inputs}/shtest-timeout/infinite_loop.py \
diff --git a/utils/lit/tests/unit/TestRunner.py b/utils/lit/tests/unit/TestRunner.py
index 79cc10f7e14d..874bf275d4ea 100644
--- a/utils/lit/tests/unit/TestRunner.py
+++ b/utils/lit/tests/unit/TestRunner.py
@@ -28,6 +28,7 @@ class TestIntegratedTestKeywordParser(unittest.TestCase):
quiet=False,
useValgrind=False,
valgrindLeakCheck=False,
+ singleProcess=False,
valgrindArgs=[],
noExecute=False,
debug=False,