[llvm] r188034 - [lit] Eliminate mustExist parameter from TestingConfig.frompath().

Daniel Dunbar daniel at zuster.org
Thu Aug 8 17:09:03 PDT 2013


Author: ddunbar
Date: Thu Aug  8 19:09:02 2013
New Revision: 188034

URL: http://llvm.org/viewvc/llvm-project?rev=188034&view=rev
Log:
[lit] Eliminate mustExist parameter from TestingConfig.frompath().

Modified:
    llvm/trunk/utils/lit/lit/LitConfig.py
    llvm/trunk/utils/lit/lit/TestingConfig.py
    llvm/trunk/utils/lit/lit/discovery.py

Modified: llvm/trunk/utils/lit/lit/LitConfig.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/LitConfig.py?rev=188034&r1=188033&r2=188034&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/LitConfig.py (original)
+++ llvm/trunk/utils/lit/lit/LitConfig.py Thu Aug  8 19:09:02 2013
@@ -72,8 +72,7 @@ class LitConfig:
         path."""
         if self.debug:
             self.note('load_config from %r' % path)
-        return lit.TestingConfig.TestingConfig.frompath(
-            path, config, self, mustExist = True)
+        return lit.TestingConfig.TestingConfig.frompath(path, config, self)
 
     def getBashPath(self):
         """getBashPath - Get the path to 'bash'"""

Modified: llvm/trunk/utils/lit/lit/TestingConfig.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/TestingConfig.py?rev=188034&r1=188033&r2=188034&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/TestingConfig.py (original)
+++ llvm/trunk/utils/lit/lit/TestingConfig.py Thu Aug  8 19:09:02 2013
@@ -9,7 +9,7 @@ class TestingConfig:
     """
 
     @staticmethod
-    def frompath(path, config, litConfig, mustExist=True):
+    def frompath(path, config, litConfig):
         """
         frompath(path, config, litConfig, mustExist) -> TestingConfig
 
@@ -58,39 +58,37 @@ class TestingConfig:
                                    available_features = available_features,
                                    pipefail = True)
 
-        if os.path.exists(path):
-            # FIXME: Improve detection and error reporting of errors in the
-            # config file.
-            f = open(path)
-            cfg_globals = dict(globals())
-            cfg_globals['config'] = config
-            cfg_globals['lit'] = litConfig
-            cfg_globals['__file__'] = path
-            try:
-                data = f.read()
-                if PY2:
-                    exec("exec data in cfg_globals")
-                else:
-                    exec(data, cfg_globals)
-                if litConfig.debug:
-                    litConfig.note('... loaded config %r' % path)
-            except SystemExit:
-                e = sys.exc_info()[1]
-                # We allow normal system exit inside a config file to just
-                # return control without error.
-                if e.args:
-                    raise
-            except:
-                import traceback
-                litConfig.fatal(
-                    'unable to parse config file %r, traceback: %s' % (
-                        path, traceback.format_exc()))
-            f.close()
-        else:
-            if mustExist:
-                litConfig.fatal('unable to load config from %r ' % path)
-            elif litConfig.debug:
-                litConfig.note('... config not found  - %r' %path)
+        # Load the config script data.
+        f = open(path)
+        try:
+            data = f.read()
+        except:
+            litConfig.fatal('unable to load config file: %r' % (path,))
+        f.close()
+
+        # Execute the config script to initialize the object.
+        cfg_globals = dict(globals())
+        cfg_globals['config'] = config
+        cfg_globals['lit'] = litConfig
+        cfg_globals['__file__'] = path
+        try:
+            if PY2:
+                exec("exec data in cfg_globals")
+            else:
+                exec(data, cfg_globals)
+            if litConfig.debug:
+                litConfig.note('... loaded config %r' % path)
+        except SystemExit:
+            e = sys.exc_info()[1]
+            # We allow normal system exit inside a config file to just
+            # return control without error.
+            if e.args:
+                raise
+        except:
+            import traceback
+            litConfig.fatal(
+                'unable to parse config file %r, traceback: %s' % (
+                    path, traceback.format_exc()))
 
         config.finish(litConfig)
         return config

Modified: llvm/trunk/utils/lit/lit/discovery.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/discovery.py?rev=188034&r1=188033&r2=188034&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/discovery.py (original)
+++ llvm/trunk/utils/lit/lit/discovery.py Thu Aug  8 19:09:02 2013
@@ -42,7 +42,7 @@ def getTestSuite(item, litConfig, cache)
         if litConfig.debug:
             litConfig.note('loading suite config %r' % cfgpath)
 
-        cfg = TestingConfig.frompath(cfgpath, None, litConfig, mustExist = True)
+        cfg = TestingConfig.frompath(cfgpath, None, litConfig)
         source_root = os.path.realpath(cfg.test_source_root or path)
         exec_root = os.path.realpath(cfg.test_exec_root or path)
         return Test.TestSuite(cfg.name, source_root, exec_root, cfg), ()





More information about the llvm-commits mailing list