4 PY2 = sys.version_info[0] < 3
8 TestingConfig - Information on the tests inside a suite.
12 def frompath(path, parent, litConfig, mustExist, config = None):
14 # Set the environment based on the command line arguments.
16 'LIBRARY_PATH' : os.environ.get('LIBRARY_PATH',''),
17 'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH',''),
18 'PATH' : os.pathsep.join(litConfig.path +
19 [os.environ.get('PATH','')]),
20 'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
21 'TERM' : os.environ.get('TERM',''),
22 'LLVM_DISABLE_CRASH_REPORT' : '1',
25 if sys.platform == 'win32':
27 'INCLUDE' : os.environ.get('INCLUDE',''),
28 'PATHEXT' : os.environ.get('PATHEXT',''),
29 'PYTHONUNBUFFERED' : '1',
30 'TEMP' : os.environ.get('TEMP',''),
31 'TMP' : os.environ.get('TMP',''),
34 # Set the default available features based on the LitConfig.
35 available_features = []
36 if litConfig.useValgrind:
37 available_features.append('valgrind')
38 if litConfig.valgrindLeakCheck:
39 available_features.append('vg_leak')
41 config = TestingConfig(parent,
45 environment = environment,
49 test_exec_root = None,
50 test_source_root = None,
52 available_features = available_features,
55 if os.path.exists(path):
56 # FIXME: Improve detection and error reporting of errors in the
59 cfg_globals = dict(globals())
60 cfg_globals['config'] = config
61 cfg_globals['lit'] = litConfig
62 cfg_globals['__file__'] = path
66 exec("exec data in cfg_globals")
68 exec(data, cfg_globals)
70 litConfig.note('... loaded config %r' % path)
73 # We allow normal system exit inside a config file to just
74 # return control without error.
80 'unable to parse config file %r, traceback: %s' % (
81 path, traceback.format_exc()))
85 litConfig.fatal('unable to load config from %r ' % path)
87 litConfig.note('... config not found - %r' %path)
89 config.finish(litConfig)
92 def __init__(self, parent, name, suffixes, test_format,
93 environment, substitutions, unsupported, on_clone,
94 test_exec_root, test_source_root, excludes,
95 available_features, pipefail):
98 self.suffixes = set(suffixes)
99 self.test_format = test_format
100 self.environment = dict(environment)
101 self.substitutions = list(substitutions)
102 self.unsupported = unsupported
103 self.on_clone = on_clone
104 self.test_exec_root = test_exec_root
105 self.test_source_root = test_source_root
106 self.excludes = set(excludes)
107 self.available_features = set(available_features)
108 self.pipefail = pipefail
110 def clone(self, path):
111 # FIXME: Chain implementations?
113 # FIXME: Allow extra parameters?
114 cfg = TestingConfig(self, self.name, self.suffixes, self.test_format,
115 self.environment, self.substitutions,
116 self.unsupported, self.on_clone,
117 self.test_exec_root, self.test_source_root,
118 self.excludes, self.available_features,
121 cfg.on_clone(self, cfg, path)
124 def finish(self, litConfig):
125 """finish() - Finish this config object, after loading is complete."""
127 self.name = str(self.name)
128 self.suffixes = set(self.suffixes)
129 self.environment = dict(self.environment)
130 self.substitutions = list(self.substitutions)
131 if self.test_exec_root is not None:
132 # FIXME: This should really only be suite in test suite config
133 # files. Should we distinguish them?
134 self.test_exec_root = str(self.test_exec_root)
135 if self.test_source_root is not None:
136 # FIXME: This should really only be suite in test suite config
137 # files. Should we distinguish them?
138 self.test_source_root = str(self.test_source_root)
139 self.excludes = set(self.excludes)
143 """root attribute - The root configuration for the test suite."""
144 if self.parent is None:
147 return self.parent.root