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 litConfig.fatal('unable to load config from %r ' % path)
82 litConfig.note('... config not found - %r' %path)
84 config.finish(litConfig)
87 def __init__(self, parent, name, suffixes, test_format,
88 environment, substitutions, unsupported, on_clone,
89 test_exec_root, test_source_root, excludes,
90 available_features, pipefail):
93 self.suffixes = set(suffixes)
94 self.test_format = test_format
95 self.environment = dict(environment)
96 self.substitutions = list(substitutions)
97 self.unsupported = unsupported
98 self.on_clone = on_clone
99 self.test_exec_root = test_exec_root
100 self.test_source_root = test_source_root
101 self.excludes = set(excludes)
102 self.available_features = set(available_features)
103 self.pipefail = pipefail
105 def clone(self, path):
106 # FIXME: Chain implementations?
108 # FIXME: Allow extra parameters?
109 cfg = TestingConfig(self, self.name, self.suffixes, self.test_format,
110 self.environment, self.substitutions,
111 self.unsupported, self.on_clone,
112 self.test_exec_root, self.test_source_root,
113 self.excludes, self.available_features,
116 cfg.on_clone(self, cfg, path)
119 def finish(self, litConfig):
120 """finish() - Finish this config object, after loading is complete."""
122 self.name = str(self.name)
123 self.suffixes = set(self.suffixes)
124 self.environment = dict(self.environment)
125 self.substitutions = list(self.substitutions)
126 if self.test_exec_root is not None:
127 # FIXME: This should really only be suite in test suite config
128 # files. Should we distinguish them?
129 self.test_exec_root = str(self.test_exec_root)
130 if self.test_source_root is not None:
131 # FIXME: This should really only be suite in test suite config
132 # files. Should we distinguish them?
133 self.test_source_root = str(self.test_source_root)
134 self.excludes = set(self.excludes)
138 """root attribute - The root configuration for the test suite."""
139 if self.parent is None:
142 return self.parent.root