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, ignoreStdErr, 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
35 self.ignoreStdErr = ignoreStdErr
37 self.isWindows = bool(isWindows)
38 self.params = dict(params)
44 self.valgrindArgs = []
46 self.valgrindArgs = ['valgrind', '-q', '--run-libc-freeres=no',
47 '--tool=memcheck', '--trace-children=yes',
48 '--error-exitcode=123']
49 if self.valgrindLeakCheck:
50 self.valgrindArgs.append('--leak-check=full')
52 # The default is 'summary'.
53 self.valgrindArgs.append('--leak-check=no')
54 self.valgrindArgs.extend(self.valgrindUserArgs)
57 def load_config(self, config, path):
58 """load_config(config, path) - Load a config object from an alternate
60 from TestingConfig import TestingConfig
62 self.note('load_config from %r' % path)
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 getToolsPath(self, dir, paths, tools):
90 if dir is not None and os.path.isabs(dir) and os.path.isdir(dir):
91 if not Util.checkToolsPath(dir, tools):
94 dir = Util.whichTools(tools, paths)
97 self.bashPath = Util.which('bash', dir)
98 if self.bashPath is None:
99 self.note("Unable to find 'bash.exe'.")
104 def _write_message(self, kind, message):
105 import inspect, os, sys
107 # Get the file/line where this message was generated.
108 f = inspect.currentframe()
109 # Step out of _write_message, and then out of wrapper.
111 file,line,_,_,_ = inspect.getframeinfo(f)
112 location = '%s:%d' % (os.path.basename(file), line)
114 print >>sys.stderr, '%s: %s: %s: %s' % (self.progname, location,
117 def note(self, message):
118 self._write_message('note', message)
120 def warning(self, message):
121 self._write_message('warning', message)
122 self.numWarnings += 1
124 def error(self, message):
125 self._write_message('error', message)
128 def fatal(self, message):
130 self._write_message('fatal', message)