2 """LitConfig - Configuration data for a 'lit' test runner instance, shared
5 The LitConfig object is also used to communicate with client configuration
6 files, it is always passed in as the global variable 'lit' so that
7 configuration files can access common functionality and internal components
11 # Provide access to Test module.
14 # Provide access to built-in formats.
15 import LitFormats as formats
17 # Provide access to built-in utility functions.
20 def __init__(self, progname, path, quiet,
21 useValgrind, valgrindLeakCheck, valgrindArgs,
23 noExecute, debug, isWindows,
25 # The name of the test runner.
26 self.progname = progname
27 # The items to add to the PATH environment variable.
28 self.path = list(map(str, path))
29 self.quiet = bool(quiet)
30 self.useValgrind = bool(useValgrind)
31 self.valgrindLeakCheck = bool(valgrindLeakCheck)
32 self.valgrindUserArgs = list(valgrindArgs)
33 self.useTclAsSh = bool(useTclAsSh)
34 self.noExecute = noExecute
36 self.isWindows = bool(isWindows)
37 self.params = dict(params)
43 self.valgrindArgs = []
44 self.valgrindTriple = ""
46 self.valgrindTriple = "-vg"
47 self.valgrindArgs = ['valgrind', '-q', '--run-libc-freeres=no',
48 '--tool=memcheck', '--trace-children=yes',
49 '--error-exitcode=123']
50 if self.valgrindLeakCheck:
51 self.valgrindTriple += "_leak"
52 self.valgrindArgs.append('--leak-check=full')
54 # The default is 'summary'.
55 self.valgrindArgs.append('--leak-check=no')
56 self.valgrindArgs.extend(self.valgrindUserArgs)
59 def load_config(self, config, path):
60 """load_config(config, path) - Load a config object from an alternate
62 from TestingConfig import TestingConfig
63 return TestingConfig.frompath(path, config.parent, self,
67 def getBashPath(self):
68 """getBashPath - Get the path to 'bash'"""
71 if self.bashPath is not None:
74 self.bashPath = Util.which('bash', os.pathsep.join(self.path))
75 if self.bashPath is None:
76 # Check some known paths.
77 for path in ('/bin/bash', '/usr/bin/bash', '/usr/local/bin/bash'):
78 if os.path.exists(path):
82 if self.bashPath is None:
83 self.warning("Unable to find 'bash', running Tcl tests internally.")
88 def _write_message(self, kind, message):
89 import inspect, os, sys
91 # Get the file/line where this message was generated.
92 f = inspect.currentframe()
93 # Step out of _write_message, and then out of wrapper.
95 file,line,_,_,_ = inspect.getframeinfo(f)
96 location = '%s:%d' % (os.path.basename(file), line)
98 print >>sys.stderr, '%s: %s: %s: %s' % (self.progname, location,
101 def note(self, message):
102 self._write_message('note', message)
104 def warning(self, message):
105 self._write_message('warning', message)
106 self.numWarnings += 1
108 def error(self, message):
109 self._write_message('error', message)
112 def fatal(self, message):
114 self._write_message('fatal', message)