add some missing quotes in debug output
[llvm/avr.git] / utils / lit / TestingConfig.py
blobbfe23b282cd8447f5861cfb18f233700e26aafe9
1 import os
3 class TestingConfig:
4 """"
5 TestingConfig - Information on the tests inside a suite.
6 """
8 @staticmethod
9 def frompath(path, parent, litConfig, mustExist, config = None):
10 if config is None:
11 # Set the environment based on the command line arguments.
12 environment = {
13 'PATH' : os.pathsep.join(litConfig.path +
14 [os.environ.get('PATH','')]),
15 'SYSTEMROOT' : os.environ.get('SYSTEMROOT',''),
18 config = TestingConfig(parent,
19 name = '<unnamed>',
20 suffixes = set(),
21 test_format = None,
22 environment = environment,
23 substitutions = [],
24 unsupported = False,
25 on_clone = None,
26 test_exec_root = None,
27 test_source_root = None,
28 excludes = [])
30 if os.path.exists(path):
31 # FIXME: Improve detection and error reporting of errors in the
32 # config file.
33 f = open(path)
34 cfg_globals = dict(globals())
35 cfg_globals['config'] = config
36 cfg_globals['lit'] = litConfig
37 cfg_globals['__file__'] = path
38 try:
39 exec f in cfg_globals
40 except SystemExit,status:
41 # We allow normal system exit inside a config file to just
42 # return control without error.
43 if status.args:
44 raise
45 f.close()
46 elif mustExist:
47 litConfig.fatal('unable to load config from %r ' % path)
49 config.finish(litConfig)
50 return config
52 def __init__(self, parent, name, suffixes, test_format,
53 environment, substitutions, unsupported, on_clone,
54 test_exec_root, test_source_root, excludes):
55 self.parent = parent
56 self.name = str(name)
57 self.suffixes = set(suffixes)
58 self.test_format = test_format
59 self.environment = dict(environment)
60 self.substitutions = list(substitutions)
61 self.unsupported = unsupported
62 self.on_clone = on_clone
63 self.test_exec_root = test_exec_root
64 self.test_source_root = test_source_root
65 self.excludes = set(excludes)
67 def clone(self, path):
68 # FIXME: Chain implementations?
70 # FIXME: Allow extra parameters?
71 cfg = TestingConfig(self, self.name, self.suffixes, self.test_format,
72 self.environment, self.substitutions,
73 self.unsupported, self.on_clone,
74 self.test_exec_root, self.test_source_root,
75 self.excludes)
76 if cfg.on_clone:
77 cfg.on_clone(self, cfg, path)
78 return cfg
80 def finish(self, litConfig):
81 """finish() - Finish this config object, after loading is complete."""
83 self.name = str(self.name)
84 self.suffixes = set(self.suffixes)
85 self.environment = dict(self.environment)
86 self.substitutions = list(self.substitutions)
87 if self.test_exec_root is not None:
88 # FIXME: This should really only be suite in test suite config
89 # files. Should we distinguish them?
90 self.test_exec_root = str(self.test_exec_root)
91 if self.test_source_root is not None:
92 # FIXME: This should really only be suite in test suite config
93 # files. Should we distinguish them?
94 self.test_source_root = str(self.test_source_root)
95 self.excludes = set(self.excludes)