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')
50 self.valgrindArgs.extend(self.valgrindUserArgs)
53 def load_config(self, config, path):
54 """load_config(config, path) - Load a config object from an alternate
56 from TestingConfig import TestingConfig
57 return TestingConfig.frompath(path, config.parent, self,
61 def getBashPath(self):
62 """getBashPath - Get the path to 'bash'"""
65 if self.bashPath is not None:
68 self.bashPath = Util.which('bash', os.pathsep.join(self.path))
69 if self.bashPath is None:
70 # Check some known paths.
71 for path in ('/bin/bash', '/usr/bin/bash'):
72 if os.path.exists(path):
76 if self.bashPath is None:
77 self.warning("Unable to find 'bash', running Tcl tests internally.")
82 def _write_message(self, kind, message):
83 import inspect, os, sys
85 # Get the file/line where this message was generated.
86 f = inspect.currentframe()
87 # Step out of _write_message, and then out of wrapper.
89 file,line,_,_,_ = inspect.getframeinfo(f)
90 location = '%s:%d' % (os.path.basename(file), line)
92 print >>sys.stderr, '%s: %s: %s: %s' % (self.progname, location,
95 def note(self, message):
96 self._write_message('note', message)
98 def warning(self, message):
99 self._write_message('warning', message)
100 self.numWarnings += 1
102 def error(self, message):
103 self._write_message('error', message)
106 def fatal(self, message):
108 self._write_message('fatal', message)