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 environment[var] = os.environ.get(var, '')
31 if sys.platform == 'win32':
33 'INCLUDE' : os.environ.get('INCLUDE',''),
34 'PATHEXT' : os.environ.get('PATHEXT',''),
35 'PYTHONUNBUFFERED' : '1',
36 'TEMP' : os.environ.get('TEMP',''),
37 'TMP' : os.environ.get('TMP',''),
40 # The option to preserve TEMP, TMP, and TMPDIR.
41 # This is intended to check how many temporary files would be generated
42 # (and be not cleaned up) in automated builders.
43 if 'LIT_PRESERVES_TMP' in os.environ:
45 'TEMP' : os.environ.get('TEMP',''),
46 'TMP' : os.environ.get('TMP',''),
47 'TMPDIR' : os.environ.get('TMPDIR',''),
50 # Set the default available features based on the LitConfig.
51 available_features = []
52 if litConfig.useValgrind:
53 available_features.append('valgrind')
54 if litConfig.valgrindLeakCheck:
55 available_features.append('vg_leak')
57 return TestingConfig(None,
61 environment = environment,
64 test_exec_root = None,
65 test_source_root = None,
67 available_features = available_features,
70 def load_from_path(self, path, litConfig):
72 load_from_path(path, litConfig)
74 Load the configuration module at the provided path into the given config
78 # Load the config script data.
85 litConfig.fatal('unable to load config file: %r' % (path,))
88 # Execute the config script to initialize the object.
89 cfg_globals = dict(globals())
90 cfg_globals['config'] = self
91 cfg_globals['lit_config'] = litConfig
92 cfg_globals['__file__'] = path
95 execfile(path, cfg_globals)
97 exec(compile(data, path, 'exec'), cfg_globals, None)
99 litConfig.note('... loaded config %r' % path)
101 e = sys.exc_info()[1]
102 # We allow normal system exit inside a config file to just
103 # return control without error.
109 'unable to parse config file %r, traceback: %s' % (
110 path, traceback.format_exc()))
112 self.finish(litConfig)
114 def __init__(self, parent, name, suffixes, test_format,
115 environment, substitutions, unsupported,
116 test_exec_root, test_source_root, excludes,
117 available_features, pipefail):
119 self.name = str(name)
120 self.suffixes = set(suffixes)
121 self.test_format = test_format
122 self.environment = dict(environment)
123 self.substitutions = list(substitutions)
124 self.unsupported = unsupported
125 self.test_exec_root = test_exec_root
126 self.test_source_root = test_source_root
127 self.excludes = set(excludes)
128 self.available_features = set(available_features)
129 self.pipefail = pipefail
131 def finish(self, litConfig):
132 """finish() - Finish this config object, after loading is complete."""
134 self.name = str(self.name)
135 self.suffixes = set(self.suffixes)
136 self.environment = dict(self.environment)
137 self.substitutions = list(self.substitutions)
138 if self.test_exec_root is not None:
139 # FIXME: This should really only be suite in test suite config
140 # files. Should we distinguish them?
141 self.test_exec_root = str(self.test_exec_root)
142 if self.test_source_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_source_root = str(self.test_source_root)
146 self.excludes = set(self.excludes)
150 """root attribute - The root configuration for the test suite."""
151 if self.parent is None:
154 return self.parent.root