4 PY2 = sys.version_info[0] < 3
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 'LIBRARY_PATH' : os.environ.get('LIBRARY_PATH',''),
21 'LD_LIBRARY_PATH' : os.environ.get('LD_LIBRARY_PATH',''),
22 'PATH' : os.pathsep.join(litConfig.path +
23 [os.environ.get('PATH','')]),
24 'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
25 'TERM' : os.environ.get('TERM',''),
26 'LLVM_DISABLE_CRASH_REPORT' : '1',
29 if sys.platform == 'win32':
31 'INCLUDE' : os.environ.get('INCLUDE',''),
32 'PATHEXT' : os.environ.get('PATHEXT',''),
33 'PYTHONUNBUFFERED' : '1',
34 'TEMP' : os.environ.get('TEMP',''),
35 'TMP' : os.environ.get('TMP',''),
38 # Set the default available features based on the LitConfig.
39 available_features = []
40 if litConfig.useValgrind:
41 available_features.append('valgrind')
42 if litConfig.valgrindLeakCheck:
43 available_features.append('vg_leak')
45 return TestingConfig(None,
49 environment = environment,
52 test_exec_root = None,
53 test_source_root = None,
55 available_features = available_features,
58 def load_from_path(self, path, litConfig):
60 load_from_path(path, litConfig)
62 Load the configuration module at the provided path into the given config
66 # Load the config script data.
71 litConfig.fatal('unable to load config file: %r' % (path,))
74 # Execute the config script to initialize the object.
75 cfg_globals = dict(globals())
76 cfg_globals['config'] = self
77 cfg_globals['lit'] = litConfig
78 cfg_globals['lit_config'] = litConfig
79 cfg_globals['__file__'] = path
82 exec("exec data in cfg_globals")
84 exec(data, cfg_globals)
86 litConfig.note('... loaded config %r' % path)
89 # We allow normal system exit inside a config file to just
90 # return control without error.
96 'unable to parse config file %r, traceback: %s' % (
97 path, traceback.format_exc()))
99 self.finish(litConfig)
101 def __init__(self, parent, name, suffixes, test_format,
102 environment, substitutions, unsupported,
103 test_exec_root, test_source_root, excludes,
104 available_features, pipefail):
106 self.name = str(name)
107 self.suffixes = set(suffixes)
108 self.test_format = test_format
109 self.environment = dict(environment)
110 self.substitutions = list(substitutions)
111 self.unsupported = unsupported
112 self.test_exec_root = test_exec_root
113 self.test_source_root = test_source_root
114 self.excludes = set(excludes)
115 self.available_features = set(available_features)
116 self.pipefail = pipefail
119 # FIXME: Chain implementations?
121 # FIXME: Allow extra parameters?
122 return TestingConfig(self, self.name, self.suffixes, self.test_format,
123 self.environment, self.substitutions,
125 self.test_exec_root, self.test_source_root,
126 self.excludes, self.available_features,
129 def finish(self, litConfig):
130 """finish() - Finish this config object, after loading is complete."""
132 self.name = str(self.name)
133 self.suffixes = set(self.suffixes)
134 self.environment = dict(self.environment)
135 self.substitutions = list(self.substitutions)
136 if self.test_exec_root is not None:
137 # FIXME: This should really only be suite in test suite config
138 # files. Should we distinguish them?
139 self.test_exec_root = str(self.test_exec_root)
140 if self.test_source_root is not None:
141 # FIXME: This should really only be suite in test suite config
142 # files. Should we distinguish them?
143 self.test_source_root = str(self.test_source_root)
144 self.excludes = set(self.excludes)
148 """root attribute - The root configuration for the test suite."""
149 if self.parent is None:
152 return self.parent.root