import os
import sys
-PY2 = sys.version_info[0] < 3
+OldPy = sys.version_info[0] == 2 and sys.version_info[1] < 7
class TestingConfig:
""""
'TMP' : os.environ.get('TMP',''),
})
+ # The option to preserve TEMP, TMP, and TMPDIR.
+ # This is intended to check how many temporary files would be generated
+ # (and be not cleaned up) in automated builders.
+ if 'LIT_PRESERVES_TMP' in os.environ:
+ environment.update({
+ 'TEMP' : os.environ.get('TEMP',''),
+ 'TMP' : os.environ.get('TMP',''),
+ 'TMPDIR' : os.environ.get('TMPDIR',''),
+ })
+
# Set the default available features based on the LitConfig.
available_features = []
if litConfig.useValgrind:
"""
# Load the config script data.
- f = open(path)
- try:
- data = f.read()
- except:
- litConfig.fatal('unable to load config file: %r' % (path,))
- f.close()
+ data = None
+ if not OldPy:
+ 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'] = self
- cfg_globals['lit'] = litConfig
cfg_globals['lit_config'] = litConfig
cfg_globals['__file__'] = path
try:
- if PY2:
- exec("exec data in cfg_globals")
+ if OldPy:
+ execfile(path, cfg_globals)
else:
- exec(data, cfg_globals)
+ exec(compile(data, path, 'exec'), cfg_globals, None)
if litConfig.debug:
litConfig.note('... loaded config %r' % path)
except SystemExit:
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."""