4 PY2 = sys.version_info[0] < 3
8 TestingConfig - Information on the tests inside a suite.
12 def frompath(path, config, litConfig):
14 frompath(path, config, litConfig, mustExist) -> TestingConfig
16 Load the configuration module at the provided path into the given config
17 object (or create a new one if None is provided) and return the config.
21 # Set the environment based on the command line arguments.
23 'LIBRARY_PATH' : os.environ.get('LIBRARY_PATH',''),
24 'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH',''),
25 'PATH' : os.pathsep.join(litConfig.path +
26 [os.environ.get('PATH','')]),
27 'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
28 'TERM' : os.environ.get('TERM',''),
29 'LLVM_DISABLE_CRASH_REPORT' : '1',
32 if sys.platform == 'win32':
34 'INCLUDE' : os.environ.get('INCLUDE',''),
35 'PATHEXT' : os.environ.get('PATHEXT',''),
36 'PYTHONUNBUFFERED' : '1',
37 'TEMP' : os.environ.get('TEMP',''),
38 'TMP' : os.environ.get('TMP',''),
41 # Set the default available features based on the LitConfig.
42 available_features = []
43 if litConfig.useValgrind:
44 available_features.append('valgrind')
45 if litConfig.valgrindLeakCheck:
46 available_features.append('vg_leak')
48 config = TestingConfig(None,
52 environment = environment,
55 test_exec_root = None,
56 test_source_root = None,
58 available_features = available_features,
61 # Load the config script data.
66 litConfig.fatal('unable to load config file: %r' % (path,))
69 # Execute the config script to initialize the object.
70 cfg_globals = dict(globals())
71 cfg_globals['config'] = config
72 cfg_globals['lit'] = litConfig
73 cfg_globals['__file__'] = path
76 exec("exec data in cfg_globals")
78 exec(data, cfg_globals)
80 litConfig.note('... loaded config %r' % path)
83 # We allow normal system exit inside a config file to just
84 # return control without error.
90 'unable to parse config file %r, traceback: %s' % (
91 path, traceback.format_exc()))
93 config.finish(litConfig)
96 def __init__(self, parent, name, suffixes, test_format,
97 environment, substitutions, unsupported,
98 test_exec_root, test_source_root, excludes,
99 available_features, pipefail):
101 self.name = str(name)
102 self.suffixes = set(suffixes)
103 self.test_format = test_format
104 self.environment = dict(environment)
105 self.substitutions = list(substitutions)
106 self.unsupported = unsupported
107 self.test_exec_root = test_exec_root
108 self.test_source_root = test_source_root
109 self.excludes = set(excludes)
110 self.available_features = set(available_features)
111 self.pipefail = pipefail
114 # FIXME: Chain implementations?
116 # FIXME: Allow extra parameters?
117 return TestingConfig(self, self.name, self.suffixes, self.test_format,
118 self.environment, self.substitutions,
120 self.test_exec_root, self.test_source_root,
121 self.excludes, self.available_features,
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