4 PY2 = sys.version_info[0] < 3
8 TestingConfig - Information on the tests inside a suite.
12 def frompath(path, config, litConfig, mustExist=True):
14 frompath(path, config, litConfig, mustExist) -> TestingConfig
16 Load the configuration module at the provided path into the given config
17 object (or create a new one if None is provided) and return the config.
21 # Set the environment based on the command line arguments.
23 'LIBRARY_PATH' : os.environ.get('LIBRARY_PATH',''),
24 'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH',''),
25 'PATH' : os.pathsep.join(litConfig.path +
26 [os.environ.get('PATH','')]),
27 'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
28 'TERM' : os.environ.get('TERM',''),
29 'LLVM_DISABLE_CRASH_REPORT' : '1',
32 if sys.platform == 'win32':
34 'INCLUDE' : os.environ.get('INCLUDE',''),
35 'PATHEXT' : os.environ.get('PATHEXT',''),
36 'PYTHONUNBUFFERED' : '1',
37 'TEMP' : os.environ.get('TEMP',''),
38 'TMP' : os.environ.get('TMP',''),
41 # Set the default available features based on the LitConfig.
42 available_features = []
43 if litConfig.useValgrind:
44 available_features.append('valgrind')
45 if litConfig.valgrindLeakCheck:
46 available_features.append('vg_leak')
48 config = TestingConfig(None,
52 environment = environment,
55 test_exec_root = None,
56 test_source_root = None,
58 available_features = available_features,
61 if os.path.exists(path):
62 # FIXME: Improve detection and error reporting of errors in the
65 cfg_globals = dict(globals())
66 cfg_globals['config'] = config
67 cfg_globals['lit'] = litConfig
68 cfg_globals['__file__'] = path
72 exec("exec data in cfg_globals")
74 exec(data, cfg_globals)
76 litConfig.note('... loaded config %r' % path)
79 # We allow normal system exit inside a config file to just
80 # return control without error.
86 'unable to parse config file %r, traceback: %s' % (
87 path, traceback.format_exc()))
91 litConfig.fatal('unable to load config from %r ' % path)
93 litConfig.note('... config not found - %r' %path)
95 config.finish(litConfig)
98 def __init__(self, parent, name, suffixes, test_format,
99 environment, substitutions, unsupported,
100 test_exec_root, test_source_root, excludes,
101 available_features, pipefail):
103 self.name = str(name)
104 self.suffixes = set(suffixes)
105 self.test_format = test_format
106 self.environment = dict(environment)
107 self.substitutions = list(substitutions)
108 self.unsupported = unsupported
109 self.test_exec_root = test_exec_root
110 self.test_source_root = test_source_root
111 self.excludes = set(excludes)
112 self.available_features = set(available_features)
113 self.pipefail = pipefail
116 # FIXME: Chain implementations?
118 # FIXME: Allow extra parameters?
119 return TestingConfig(self, self.name, self.suffixes, self.test_format,
120 self.environment, self.substitutions,
122 self.test_exec_root, self.test_source_root,
123 self.excludes, self.available_features,
126 def finish(self, litConfig):
127 """finish() - Finish this config object, after loading is complete."""
129 self.name = str(self.name)
130 self.suffixes = set(self.suffixes)
131 self.environment = dict(self.environment)
132 self.substitutions = list(self.substitutions)
133 if self.test_exec_root is not None:
134 # FIXME: This should really only be suite in test suite config
135 # files. Should we distinguish them?
136 self.test_exec_root = str(self.test_exec_root)
137 if self.test_source_root is not None:
138 # FIXME: This should really only be suite in test suite config
139 # files. Should we distinguish them?
140 self.test_source_root = str(self.test_source_root)
141 self.excludes = set(self.excludes)
145 """root attribute - The root configuration for the test suite."""
146 if self.parent is None:
149 return self.parent.root