[lit] Only create config copies when a local config file is present.
authorDaniel Dunbar <daniel@zuster.org>
Fri, 9 Aug 2013 00:08:56 +0000 (00:08 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Fri, 9 Aug 2013 00:08:56 +0000 (00:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188033 91177308-0d34-0410-b5e6-96231b3b80d8

utils/lit/lit/TestingConfig.py
utils/lit/lit/discovery.py

index 6df84b6815a60c76b7547f6545350d25e5a6e86d..ec15f38fc949e6d0c52fde826fc0b46e4df35f32 100644 (file)
@@ -9,7 +9,7 @@ class TestingConfig:
     """
 
     @staticmethod
-    def frompath(path, config, litConfig, mustExist):
+    def frompath(path, config, litConfig, mustExist=True):
         """
         frompath(path, config, litConfig, mustExist) -> TestingConfig
 
@@ -112,7 +112,7 @@ class TestingConfig:
         self.available_features = set(available_features)
         self.pipefail = pipefail
 
-    def clone(self, path):
+    def clone(self):
         # FIXME: Chain implementations?
         #
         # FIXME: Allow extra parameters?
index 35b29c62d5576eaa549b25dd518450e2031630cb..afcee58fba7a3f461677f938f758aae29a146e87 100644 (file)
@@ -78,13 +78,20 @@ def getLocalConfig(ts, path_in_suite, litConfig, cache):
         else:
             parent = search(path_in_suite[:-1])
 
-        # Load the local configuration.
+        # 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)
+
+        # If not, just reuse the parent config.
+        if not os.path.exists(cfgpath):
+            return parent
+
+        # Otherwise, copy the current config and load the local configuration
+        # file into it.
+        config = parent.clone()
         if litConfig.debug:
             litConfig.note('loading local config %r' % cfgpath)
-        return TestingConfig.frompath(cfgpath, parent.clone(cfgpath), litConfig,
-                                      mustExist = False)
+        return TestingConfig.frompath(cfgpath, config, litConfig)
 
     def search(path_in_suite):
         key = (ts, path_in_suite)