summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-04-12 19:09:09 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-04-12 19:09:09 +0000
commit406ef447074421f91c01c41f0e26fdef937e627c (patch)
treeb5e67ee6b043ccdf16af5422404c5849d1d824ee /utils
parentf2c2b2009016b44b49f41a35c750f1555f68935b (diff)
downloadllvm-406ef447074421f91c01c41f0e26fdef937e627c.tar.gz
llvm-406ef447074421f91c01c41f0e26fdef937e627c.tar.bz2
llvm-406ef447074421f91c01c41f0e26fdef937e627c.tar.xz
lit: Fix infinite recursion when an out-of-tree test root is located inside the source test root.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179402 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/lit/lit/discovery.py29
-rw-r--r--utils/lit/tests/Inputs/exec-discovery-in-tree/lit.cfg7
-rw-r--r--utils/lit/tests/Inputs/exec-discovery-in-tree/obj/lit.site.cfg4
-rw-r--r--utils/lit/tests/Inputs/exec-discovery-in-tree/test-one.txt1
-rw-r--r--utils/lit/tests/discovery.py15
5 files changed, 47 insertions, 9 deletions
diff --git a/utils/lit/lit/discovery.py b/utils/lit/lit/discovery.py
index b87de74c8b..64a9510f95 100644
--- a/utils/lit/lit/discovery.py
+++ b/utils/lit/lit/discovery.py
@@ -147,20 +147,31 @@ def getTestsInSuite(ts, path_in_suite, litConfig,
# Check for nested test suites, first in the execpath in case there is a
# site configuration and then in the source path.
- file_execpath = ts.getExecPath(path_in_suite + (filename,))
+ subpath = path_in_suite + (filename,)
+ file_execpath = ts.getExecPath(subpath)
if dirContainsTestSuite(file_execpath, litConfig):
- sub_ts, subiter = getTests(file_execpath, litConfig,
- testSuiteCache, localConfigCache)
+ sub_ts, subpath_in_suite = getTestSuite(file_execpath, litConfig,
+ testSuiteCache)
elif dirContainsTestSuite(file_sourcepath, litConfig):
- sub_ts, subiter = getTests(file_sourcepath, litConfig,
- testSuiteCache, localConfigCache)
+ sub_ts, subpath_in_suite = getTestSuite(file_sourcepath, litConfig,
+ testSuiteCache)
else:
- # Otherwise, continue loading from inside this test suite.
- subiter = getTestsInSuite(ts, path_in_suite + (filename,),
- litConfig, testSuiteCache,
- localConfigCache)
sub_ts = None
+ # If the this directory recursively maps back to the current test suite,
+ # disregard it (this can happen if the exec root is located inside the
+ # current test suite, for example).
+ if sub_ts is ts:
+ continue
+
+ # Otherwise, load from the nested test suite, if present.
+ if sub_ts is not None:
+ subiter = getTestsInSuite(sub_ts, subpath_in_suite, litConfig,
+ testSuiteCache, localConfigCache)
+ else:
+ subiter = getTestsInSuite(ts, subpath, litConfig, testSuiteCache,
+ localConfigCache)
+
N = 0
for res in subiter:
N += 1
diff --git a/utils/lit/tests/Inputs/exec-discovery-in-tree/lit.cfg b/utils/lit/tests/Inputs/exec-discovery-in-tree/lit.cfg
new file mode 100644
index 0000000000..342b2fdd3c
--- /dev/null
+++ b/utils/lit/tests/Inputs/exec-discovery-in-tree/lit.cfg
@@ -0,0 +1,7 @@
+# Verify that the site configuration was loaded.
+if config.test_source_root is None or config.test_exec_root is None:
+ lit.fatal("No site specific configuration")
+
+config.name = 'exec-discovery-in-tree-suite'
+config.suffixes = ['.txt']
+config.test_format = lit.formats.ShTest()
diff --git a/utils/lit/tests/Inputs/exec-discovery-in-tree/obj/lit.site.cfg b/utils/lit/tests/Inputs/exec-discovery-in-tree/obj/lit.site.cfg
new file mode 100644
index 0000000000..de9a3d0c6d
--- /dev/null
+++ b/utils/lit/tests/Inputs/exec-discovery-in-tree/obj/lit.site.cfg
@@ -0,0 +1,4 @@
+import os
+config.test_exec_root = os.path.dirname(__file__)
+config.test_source_root = os.path.dirname(config.test_exec_root)
+lit.load_config(config, os.path.join(config.test_source_root, "lit.cfg")) \ No newline at end of file
diff --git a/utils/lit/tests/Inputs/exec-discovery-in-tree/test-one.txt b/utils/lit/tests/Inputs/exec-discovery-in-tree/test-one.txt
new file mode 100644
index 0000000000..b80b60b7a2
--- /dev/null
+++ b/utils/lit/tests/Inputs/exec-discovery-in-tree/test-one.txt
@@ -0,0 +1 @@
+# RUN: true
diff --git a/utils/lit/tests/discovery.py b/utils/lit/tests/discovery.py
index 88a72729af..56d9dd07e8 100644
--- a/utils/lit/tests/discovery.py
+++ b/utils/lit/tests/discovery.py
@@ -79,3 +79,18 @@
#
# CHECK-ASEXEC-EXACT-TEST: -- Testing: 1 tests, 1 threads --
# CHECK-ASEXEC-EXACT-TEST: PASS: top-level-suite :: subdir/test-three
+
+
+# Check that we don't recurse infinitely when loading an site specific test
+# suite located inside the test source root.
+#
+# RUN: %{lit} \
+# RUN: %{inputs}/exec-discovery-in-tree/obj/ \
+# RUN: -j 1 --no-execute --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: -- Testing: 1 tests, 1 threads --
+# CHECK-ASEXEC-INTREE-NEXT: PASS: exec-discovery-in-tree-suite :: test-one