diff options
Diffstat (limited to 'llvm/utils/lit')
-rw-r--r-- | llvm/utils/lit/lit/LitConfig.py | 7 | ||||
-rw-r--r-- | llvm/utils/lit/lit/discovery.py | 21 | ||||
-rw-r--r-- | llvm/utils/lit/tests/Inputs/py-config-discovery/lit.site.cfg.py | 5 | ||||
-rw-r--r-- | llvm/utils/lit/tests/discovery.py | 28 |
4 files changed, 50 insertions, 11 deletions
diff --git a/llvm/utils/lit/lit/LitConfig.py b/llvm/utils/lit/lit/LitConfig.py index fbb04dc4e6f..389e5652e9b 100644 --- a/llvm/utils/lit/lit/LitConfig.py +++ b/llvm/utils/lit/lit/LitConfig.py @@ -44,9 +44,10 @@ class LitConfig(object): # Configuration files to look for when discovering test suites. self.config_prefix = config_prefix or 'lit' - self.config_name = '%s.cfg' % (self.config_prefix,) - self.site_config_name = '%s.site.cfg' % (self.config_prefix,) - self.local_config_name = '%s.local.cfg' % (self.config_prefix,) + self.suffixes = ['cfg.py', 'cfg'] + self.config_names = ['%s.%s' % (self.config_prefix,x) for x in self.suffixes] + self.site_config_names = ['%s.site.%s' % (self.config_prefix,x) for x in self.suffixes] + self.local_config_names = ['%s.local.%s' % (self.config_prefix,x) for x in self.suffixes] self.numErrors = 0 self.numWarnings = 0 diff --git a/llvm/utils/lit/lit/discovery.py b/llvm/utils/lit/lit/discovery.py index e276829db39..66c1181017a 100644 --- a/llvm/utils/lit/lit/discovery.py +++ b/llvm/utils/lit/lit/discovery.py @@ -10,13 +10,18 @@ import lit.run from lit.TestingConfig import TestingConfig from lit import LitConfig, Test +def chooseConfigFileFromDir(dir, config_names): + for name in config_names: + p = os.path.join(dir, name) + if os.path.exists(p): + return p + return None + def dirContainsTestSuite(path, lit_config): - cfgpath = os.path.join(path, lit_config.site_config_name) - if os.path.exists(cfgpath): - return cfgpath - cfgpath = os.path.join(path, lit_config.config_name) - if os.path.exists(cfgpath): - return cfgpath + cfgpath = chooseConfigFileFromDir(path, lit_config.site_config_names) + if not cfgpath: + cfgpath = chooseConfigFileFromDir(path, lit_config.config_names) + return cfgpath def getTestSuite(item, litConfig, cache): """getTestSuite(item, litConfig, cache) -> (suite, relative_path) @@ -99,10 +104,10 @@ def getLocalConfig(ts, path_in_suite, litConfig, cache): # Check if there is a local configuration file. source_path = ts.getSourcePath(path_in_suite) - cfgpath = os.path.join(source_path, litConfig.local_config_name) + cfgpath = chooseConfigFileFromDir(source_path, litConfig.local_config_names) # If not, just reuse the parent config. - if not os.path.exists(cfgpath): + if not cfgpath: return parent # Otherwise, copy the current config and load the local configuration diff --git a/llvm/utils/lit/tests/Inputs/py-config-discovery/lit.site.cfg.py b/llvm/utils/lit/tests/Inputs/py-config-discovery/lit.site.cfg.py new file mode 100644 index 00000000000..ac273c797c5 --- /dev/null +++ b/llvm/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/llvm/utils/lit/tests/discovery.py b/llvm/utils/lit/tests/discovery.py index 7d71436b0fe..ba5247337a8 100644 --- a/llvm/utils/lit/tests/discovery.py +++ b/llvm/utils/lit/tests/discovery.py @@ -38,6 +38,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. # |