[lit] Allow config files to pass arbitrary values to child configs.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 3 Sep 2013 23:32:55 +0000 (23:32 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 3 Sep 2013 23:32:55 +0000 (23:32 +0000)
 - This aligns with how existing test suites end up wanting to use the local
   config files, conceptually it makes sense to consider them to be inherited.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189885 91177308-0d34-0410-b5e6-96231b3b80d8

utils/lit/lit/TestingConfig.py
utils/lit/lit/discovery.py
utils/lit/tests/Inputs/discovery/lit.cfg
utils/lit/tests/Inputs/discovery/subdir/lit.local.cfg

index 3f198c69d61d666a2b4c08f039a46ebed02b849e..d5415396906427eb68fcf7d0c57bf21276884ed0 100644 (file)
@@ -114,17 +114,6 @@ class TestingConfig:
         self.available_features = set(available_features)
         self.pipefail = pipefail
 
-    def clone(self):
-        # FIXME: Chain implementations?
-        #
-        # FIXME: Allow extra parameters?
-        return TestingConfig(self, self.name, self.suffixes, self.test_format,
-                             self.environment, self.substitutions,
-                             self.unsupported,
-                             self.test_exec_root, self.test_source_root,
-                             self.excludes, self.available_features,
-                             self.pipefail)
-
     def finish(self, litConfig):
         """finish() - Finish this config object, after loading is complete."""
 
index 263e54694caf6f962b8224238332b3472ea47f39..c3c0f283b55821e1341451dc16f76df462c6881a 100644 (file)
@@ -2,6 +2,7 @@
 Test discovery functions.
 """
 
+import copy
 import os
 import sys
 
@@ -90,7 +91,7 @@ def getLocalConfig(ts, path_in_suite, litConfig, cache):
 
         # Otherwise, copy the current config and load the local configuration
         # file into it.
-        config = parent.clone()
+        config = copy.copy(parent)
         if litConfig.debug:
             litConfig.note('loading local config %r' % cfgpath)
         config.load_from_path(cfgpath, litConfig)
index 1c5436be534e7b2debd81c11bafe820e66a15ee3..c48ca0bc036517549de01231ee2172b035fc5647 100644 (file)
@@ -9,3 +9,6 @@ config.test_format = lit.formats.ShTest()
 #
 #config.test_source_root = None
 #config.test_exec_root = None
+
+# Check that arbitrary config values are copied (tested by subdir/lit.local.cfg).
+config.an_extra_variable = False
index 5ae6b3cd017d9f131a2215da20d735e3e2c454eb..631cb602b0d9b7500b52ea00f68ed389bdbdd70b 100644 (file)
@@ -1 +1,4 @@
 config.suffixes = ['.py']
+
+# Check that the arbitrary config values in our parent was inherited.
+assert hasattr(config, 'an_extra_variable')