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 built-in formats.
12 import LitFormats as formats
14 # Provide access to built-in utility functions.
17 def __init__(self, progname, path, quiet,
18 useValgrind, valgrindLeakCheck, valgrindArgs,
20 noExecute, debug, isWindows,
22 # The name of the test runner.
23 self.progname = progname
24 # The items to add to the PATH environment variable.
25 self.path = list(map(str, path))
26 self.quiet = bool(quiet)
27 self.useValgrind = bool(useValgrind)
28 self.valgrindLeakCheck = bool(valgrindLeakCheck)
29 self.valgrindUserArgs = list(valgrindArgs)
30 self.useTclAsSh = bool(useTclAsSh)
31 self.noExecute = noExecute
33 self.isWindows = bool(isWindows)
34 self.params = dict(params)
40 self.valgrindArgs = []
41 self.valgrindTriple = ""
43 self.valgrindTriple = "-vg"
44 self.valgrindArgs = ['valgrind', '-q', '--run-libc-freeres=no',
45 '--tool=memcheck', '--trace-children=yes',
46 '--error-exitcode=123']
47 if self.valgrindLeakCheck:
48 self.valgrindTriple += "_leak"
49 self.valgrindArgs.append('--leak-check=full')
51 # The default is 'summary'.
52 self.valgrindArgs.append('--leak-check=no')
53 self.valgrindArgs.extend(self.valgrindUserArgs)
56 def load_config(self, config, path):
57 """load_config(config, path) - Load a config object from an alternate
59 from TestingConfig import TestingConfig
60 return TestingConfig.frompath(path, config.parent, self,
64 def getBashPath(self):
65 """getBashPath - Get the path to 'bash'"""
68 if self.bashPath is not None:
71 self.bashPath = Util.which('bash', os.pathsep.join(self.path))
72 if self.bashPath is None:
73 # Check some known paths.
74 for path in ('/bin/bash', '/usr/bin/bash'):
75 if os.path.exists(path):
79 if self.bashPath is None:
80 self.warning("Unable to find 'bash', running Tcl tests internally.")
85 def _write_message(self, kind, message):
86 import inspect, os, sys
88 # Get the file/line where this message was generated.
89 f = inspect.currentframe()
90 # Step out of _write_message, and then out of wrapper.
92 file,line,_,_,_ = inspect.getframeinfo(f)
93 location = '%s:%d' % (os.path.basename(file), line)
95 print >>sys.stderr, '%s: %s: %s: %s' % (self.progname, location,
98 def note(self, message):
99 self._write_message('note', message)
101 def warning(self, message):
102 self._write_message('warning', message)
103 self.numWarnings += 1
105 def error(self, message):
106 self._write_message('error', message)
109 def fatal(self, message):
111 self._write_message('fatal', message)