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',
29 val = os.environ.get(var, '')
30 # Check for empty string as some variables such as LD_PRELOAD cannot be empty
31 # ('') for OS's such as OpenBSD.
33 environment[var] = val
35 if sys.platform == 'win32':
37 'INCLUDE' : os.environ.get('INCLUDE',''),
38 'PATHEXT' : os.environ.get('PATHEXT',''),
39 'PYTHONUNBUFFERED' : '1',
40 'TEMP' : os.environ.get('TEMP',''),
41 'TMP' : os.environ.get('TMP',''),
44 # The option to preserve TEMP, TMP, and TMPDIR.
45 # This is intended to check how many temporary files would be generated
46 # (and be not cleaned up) in automated builders.
47 if 'LIT_PRESERVES_TMP' in os.environ:
49 'TEMP' : os.environ.get('TEMP',''),
50 'TMP' : os.environ.get('TMP',''),
51 'TMPDIR' : os.environ.get('TMPDIR',''),
54 # Set the default available features based on the LitConfig.
55 available_features = []
56 if litConfig.useValgrind:
57 available_features.append('valgrind')
58 if litConfig.valgrindLeakCheck:
59 available_features.append('vg_leak')
61 return TestingConfig(None,
65 environment = environment,
68 test_exec_root = None,
69 test_source_root = None,
71 available_features = available_features,
74 def load_from_path(self, path, litConfig):
76 load_from_path(path, litConfig)
78 Load the configuration module at the provided path into the given config
82 # Load the config script data.
89 litConfig.fatal('unable to load config file: %r' % (path,))
92 # Execute the config script to initialize the object.
93 cfg_globals = dict(globals())
94 cfg_globals['config'] = self
95 cfg_globals['lit_config'] = litConfig
96 cfg_globals['__file__'] = path
99 execfile(path, cfg_globals)
101 exec(compile(data, path, 'exec'), cfg_globals, None)
103 litConfig.note('... loaded config %r' % path)
105 e = sys.exc_info()[1]
106 # We allow normal system exit inside a config file to just
107 # return control without error.
113 'unable to parse config file %r, traceback: %s' % (
114 path, traceback.format_exc()))
116 self.finish(litConfig)
118 def __init__(self, parent, name, suffixes, test_format,
119 environment, substitutions, unsupported,
120 test_exec_root, test_source_root, excludes,
121 available_features, pipefail):
123 self.name = str(name)
124 self.suffixes = set(suffixes)
125 self.test_format = test_format
126 self.environment = dict(environment)
127 self.substitutions = list(substitutions)
128 self.unsupported = unsupported
129 self.test_exec_root = test_exec_root
130 self.test_source_root = test_source_root
131 self.excludes = set(excludes)
132 self.available_features = set(available_features)
133 self.pipefail = pipefail
135 def finish(self, litConfig):
136 """finish() - Finish this config object, after loading is complete."""
138 self.name = str(self.name)
139 self.suffixes = set(self.suffixes)
140 self.environment = dict(self.environment)
141 self.substitutions = list(self.substitutions)
142 if self.test_exec_root is not None:
143 # FIXME: This should really only be suite in test suite config
144 # files. Should we distinguish them?
145 self.test_exec_root = str(self.test_exec_root)
146 if self.test_source_root is not None:
147 # FIXME: This should really only be suite in test suite config
148 # files. Should we distinguish them?
149 self.test_source_root = str(self.test_source_root)
150 self.excludes = set(self.excludes)
154 """root attribute - The root configuration for the test suite."""
155 if self.parent is None:
158 return self.parent.root