1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

[lit] Split TestingConfig.frompath() into separate ctor and load methods.

llvm-svn: 188038
This commit is contained in:
Daniel Dunbar 2013-08-09 00:36:58 +00:00
parent afc3dc05ad
commit 038271ce61
3 changed files with 58 additions and 51 deletions

View File

@ -72,7 +72,8 @@ class LitConfig:
path."""
if self.debug:
self.note('load_config from %r' % path)
return lit.TestingConfig.TestingConfig.frompath(path, config, self)
config.load_from_path(path, self)
return config
def getBashPath(self):
"""getBashPath - Get the path to 'bash'"""

View File

@ -9,55 +9,60 @@ class TestingConfig:
"""
@staticmethod
def frompath(path, config, litConfig):
def fromdefaults(litConfig):
"""
frompath(path, config, litConfig, mustExist) -> TestingConfig
fromdefaults(litConfig -> TestingConfig
Create a TestingConfig object with default values.
"""
# Set the environment based on the command line arguments.
environment = {
'LIBRARY_PATH' : os.environ.get('LIBRARY_PATH',''),
'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH',''),
'PATH' : os.pathsep.join(litConfig.path +
[os.environ.get('PATH','')]),
'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
'TERM' : os.environ.get('TERM',''),
'LLVM_DISABLE_CRASH_REPORT' : '1',
}
if sys.platform == 'win32':
environment.update({
'INCLUDE' : os.environ.get('INCLUDE',''),
'PATHEXT' : os.environ.get('PATHEXT',''),
'PYTHONUNBUFFERED' : '1',
'TEMP' : os.environ.get('TEMP',''),
'TMP' : os.environ.get('TMP',''),
})
# Set the default available features based on the LitConfig.
available_features = []
if litConfig.useValgrind:
available_features.append('valgrind')
if litConfig.valgrindLeakCheck:
available_features.append('vg_leak')
return TestingConfig(None,
name = '<unnamed>',
suffixes = set(),
test_format = None,
environment = environment,
substitutions = [],
unsupported = False,
test_exec_root = None,
test_source_root = None,
excludes = [],
available_features = available_features,
pipefail = True)
def load_from_path(self, path, litConfig):
"""
load_from_path(path, litConfig)
Load the configuration module at the provided path into the given config
object (or create a new one if None is provided) and return the config.
object.
"""
if config is None:
# Set the environment based on the command line arguments.
environment = {
'LIBRARY_PATH' : os.environ.get('LIBRARY_PATH',''),
'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH',''),
'PATH' : os.pathsep.join(litConfig.path +
[os.environ.get('PATH','')]),
'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
'TERM' : os.environ.get('TERM',''),
'LLVM_DISABLE_CRASH_REPORT' : '1',
}
if sys.platform == 'win32':
environment.update({
'INCLUDE' : os.environ.get('INCLUDE',''),
'PATHEXT' : os.environ.get('PATHEXT',''),
'PYTHONUNBUFFERED' : '1',
'TEMP' : os.environ.get('TEMP',''),
'TMP' : os.environ.get('TMP',''),
})
# Set the default available features based on the LitConfig.
available_features = []
if litConfig.useValgrind:
available_features.append('valgrind')
if litConfig.valgrindLeakCheck:
available_features.append('vg_leak')
config = TestingConfig(None,
name = '<unnamed>',
suffixes = set(),
test_format = None,
environment = environment,
substitutions = [],
unsupported = False,
test_exec_root = None,
test_source_root = None,
excludes = [],
available_features = available_features,
pipefail = True)
# Load the config script data.
f = open(path)
try:
@ -68,7 +73,7 @@ class TestingConfig:
# Execute the config script to initialize the object.
cfg_globals = dict(globals())
cfg_globals['config'] = config
cfg_globals['config'] = self
cfg_globals['lit'] = litConfig
cfg_globals['__file__'] = path
try:
@ -90,8 +95,7 @@ class TestingConfig:
'unable to parse config file %r, traceback: %s' % (
path, traceback.format_exc()))
config.finish(litConfig)
return config
self.finish(litConfig)
def __init__(self, parent, name, suffixes, test_format,
environment, substitutions, unsupported,

View File

@ -38,11 +38,12 @@ def getTestSuite(item, litConfig, cache):
ts, relative = search(parent)
return (ts, relative + (base,))
# We found a config file, load it.
# We found a test suite, create a new config for it and load it.
if litConfig.debug:
litConfig.note('loading suite config %r' % cfgpath)
cfg = TestingConfig.frompath(cfgpath, None, litConfig)
cfg = TestingConfig.fromdefaults(litConfig)
cfg.load_from_path(cfgpath, 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), ()
@ -91,7 +92,8 @@ def getLocalConfig(ts, path_in_suite, litConfig, cache):
config = parent.clone()
if litConfig.debug:
litConfig.note('loading local config %r' % cfgpath)
return TestingConfig.frompath(cfgpath, config, litConfig)
config.load_from_path(cfgpath, litConfig)
return config
def search(path_in_suite):
key = (ts, path_in_suite)