4 OldPy = sys.version_info[0] == 2 and sys.version_info[1] < 7
8 TestingConfig - Information on the tests inside a suite.
12 def fromdefaults(litConfig):
14 fromdefaults(litConfig) -> TestingConfig
16 Create a TestingConfig object with default values.
18 # Set the environment based on the command line arguments.
20 'PATH' : os.pathsep.join(litConfig.path +
21 [os.environ.get('PATH','')]),
22 'LLVM_DISABLE_CRASH_REPORT' : '1',
25 pass_vars = ['LIBRARY_PATH', 'LD_LIBRARY_PATH', 'SYSTEMROOT', 'TERM',
26 'LD_PRELOAD', 'ASAN_OPTIONS', 'UBSAN_OPTIONS']
28 environment[var] = os.environ.get(var, '')
30 if sys.platform == 'win32':
32 'INCLUDE' : os.environ.get('INCLUDE',''),
33 'PATHEXT' : os.environ.get('PATHEXT',''),
34 'PYTHONUNBUFFERED' : '1',
35 'TEMP' : os.environ.get('TEMP',''),
36 'TMP' : os.environ.get('TMP',''),
39 # The option to preserve TEMP, TMP, and TMPDIR.
40 # This is intended to check how many temporary files would be generated
41 # (and be not cleaned up) in automated builders.
42 if 'LIT_PRESERVES_TMP' in os.environ:
44 'TEMP' : os.environ.get('TEMP',''),
45 'TMP' : os.environ.get('TMP',''),
46 'TMPDIR' : os.environ.get('TMPDIR',''),
49 # Set the default available features based on the LitConfig.
50 available_features = []
51 if litConfig.useValgrind:
52 available_features.append('valgrind')
53 if litConfig.valgrindLeakCheck:
54 available_features.append('vg_leak')
56 return TestingConfig(None,
60 environment = environment,
63 test_exec_root = None,
64 test_source_root = None,
66 available_features = available_features,
69 def load_from_path(self, path, litConfig):
71 load_from_path(path, litConfig)
73 Load the configuration module at the provided path into the given config
77 # Load the config script data.
84 litConfig.fatal('unable to load config file: %r' % (path,))
87 # Execute the config script to initialize the object.
88 cfg_globals = dict(globals())
89 cfg_globals['config'] = self
90 cfg_globals['lit_config'] = litConfig
91 cfg_globals['__file__'] = path
94 execfile(path, cfg_globals)
96 exec(compile(data, path, 'exec'), cfg_globals, None)
98 litConfig.note('... loaded config %r' % path)
100 e = sys.exc_info()[1]
101 # We allow normal system exit inside a config file to just
102 # return control without error.
108 'unable to parse config file %r, traceback: %s' % (
109 path, traceback.format_exc()))
111 self.finish(litConfig)
113 def __init__(self, parent, name, suffixes, test_format,
114 environment, substitutions, unsupported,
115 test_exec_root, test_source_root, excludes,
116 available_features, pipefail):
118 self.name = str(name)
119 self.suffixes = set(suffixes)
120 self.test_format = test_format
121 self.environment = dict(environment)
122 self.substitutions = list(substitutions)
123 self.unsupported = unsupported
124 self.test_exec_root = test_exec_root
125 self.test_source_root = test_source_root
126 self.excludes = set(excludes)
127 self.available_features = set(available_features)
128 self.pipefail = pipefail
130 def finish(self, litConfig):
131 """finish() - Finish this config object, after loading is complete."""
133 self.name = str(self.name)
134 self.suffixes = set(self.suffixes)
135 self.environment = dict(self.environment)
136 self.substitutions = list(self.substitutions)
137 if self.test_exec_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_exec_root = str(self.test_exec_root)
141 if self.test_source_root is not None:
142 # FIXME: This should really only be suite in test suite config
143 # files. Should we distinguish them?
144 self.test_source_root = str(self.test_source_root)
145 self.excludes = set(self.excludes)
149 """root attribute - The root configuration for the test suite."""
150 if self.parent is None:
153 return self.parent.root