6 TestingConfig - Information on the tests inside a suite.
10 def frompath(path, parent, litConfig, mustExist, config = None):
12 # Set the environment based on the command line arguments.
14 'LIBRARY_PATH' : os.environ.get('LIBRARY_PATH',''),
15 'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH',''),
16 'PATH' : os.pathsep.join(litConfig.path +
17 [os.environ.get('PATH','')]),
18 'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
19 'TERM' : os.environ.get('TERM',''),
20 'LLVM_DISABLE_CRASH_REPORT' : '1',
23 if sys.platform == 'win32':
25 'INCLUDE' : os.environ.get('INCLUDE',''),
26 'PATHEXT' : os.environ.get('PATHEXT',''),
27 'PYTHONUNBUFFERED' : '1',
28 'TEMP' : os.environ.get('TEMP',''),
29 'TMP' : os.environ.get('TMP',''),
32 # Set the default available features based on the LitConfig.
33 available_features = []
34 if litConfig.useValgrind:
35 available_features.append('valgrind')
36 if litConfig.valgrindLeakCheck:
37 available_features.append('valgrind-leaks')
39 config = TestingConfig(parent,
43 environment = environment,
47 test_exec_root = None,
48 test_source_root = None,
50 available_features = available_features)
52 if os.path.exists(path):
53 # FIXME: Improve detection and error reporting of errors in the
56 cfg_globals = dict(globals())
57 cfg_globals['config'] = config
58 cfg_globals['lit'] = litConfig
59 cfg_globals['__file__'] = path
63 litConfig.note('... loaded config %r' % path)
64 except SystemExit,status:
65 # We allow normal system exit inside a config file to just
66 # return control without error.
72 litConfig.fatal('unable to load config from %r ' % path)
74 litConfig.note('... config not found - %r' %path)
76 config.finish(litConfig)
79 def __init__(self, parent, name, suffixes, test_format,
80 environment, substitutions, unsupported, on_clone,
81 test_exec_root, test_source_root, excludes,
85 self.suffixes = set(suffixes)
86 self.test_format = test_format
87 self.environment = dict(environment)
88 self.substitutions = list(substitutions)
89 self.unsupported = unsupported
90 self.on_clone = on_clone
91 self.test_exec_root = test_exec_root
92 self.test_source_root = test_source_root
93 self.excludes = set(excludes)
94 self.available_features = set(available_features)
96 def clone(self, path):
97 # FIXME: Chain implementations?
99 # FIXME: Allow extra parameters?
100 cfg = TestingConfig(self, self.name, self.suffixes, self.test_format,
101 self.environment, self.substitutions,
102 self.unsupported, self.on_clone,
103 self.test_exec_root, self.test_source_root,
104 self.excludes, self.available_features)
106 cfg.on_clone(self, cfg, path)
109 def finish(self, litConfig):
110 """finish() - Finish this config object, after loading is complete."""
112 self.name = str(self.name)
113 self.suffixes = set(self.suffixes)
114 self.environment = dict(self.environment)
115 self.substitutions = list(self.substitutions)
116 if self.test_exec_root is not None:
117 # FIXME: This should really only be suite in test suite config
118 # files. Should we distinguish them?
119 self.test_exec_root = str(self.test_exec_root)
120 if self.test_source_root is not None:
121 # FIXME: This should really only be suite in test suite config
122 # files. Should we distinguish them?
123 self.test_source_root = str(self.test_source_root)
124 self.excludes = set(self.excludes)
128 """root attribute - The root configuration for the test suite."""
129 if self.parent is None:
132 return self.parent.root