summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-08-09 00:09:02 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-08-09 00:09:02 +0000
commit49e51429c1e1cf37b2cc23fdf208d9f470acf430 (patch)
tree6ad06a303e934d626ba3a908de7692e02b469e22 /utils
parent3279653eb85d2f09175f6a2deb0a12b93fed9ecf (diff)
downloadllvm-49e51429c1e1cf37b2cc23fdf208d9f470acf430.tar.gz
llvm-49e51429c1e1cf37b2cc23fdf208d9f470acf430.tar.bz2
llvm-49e51429c1e1cf37b2cc23fdf208d9f470acf430.tar.xz
[lit] Eliminate mustExist parameter from TestingConfig.frompath().
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188034 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/lit/lit/LitConfig.py3
-rw-r--r--utils/lit/lit/TestingConfig.py66
-rw-r--r--utils/lit/lit/discovery.py2
3 files changed, 34 insertions, 37 deletions
diff --git a/utils/lit/lit/LitConfig.py b/utils/lit/lit/LitConfig.py
index d493b33daa..6e669d58b5 100644
--- a/utils/lit/lit/LitConfig.py
+++ b/utils/lit/lit/LitConfig.py
@@ -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'"""
diff --git a/utils/lit/lit/TestingConfig.py b/utils/lit/lit/TestingConfig.py
index ec15f38fc9..8c619e15fc 100644
--- a/utils/lit/lit/TestingConfig.py
+++ b/utils/lit/lit/TestingConfig.py
@@ -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
diff --git a/utils/lit/lit/discovery.py b/utils/lit/lit/discovery.py
index afcee58fba..c5f48a69c9 100644
--- a/utils/lit/lit/discovery.py
+++ b/utils/lit/lit/discovery.py
@@ -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), ()