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, 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.valgrindArgs = list(valgrindArgs)
29
self.useTclAsSh = bool(useTclAsSh)
30
self.noExecute = noExecute
32
self.isWindows = bool(isWindows)
33
self.params = dict(params)
39
def load_config(self, config, path):
40
"""load_config(config, path) - Load a config object from an alternate
42
from TestingConfig import TestingConfig
43
return TestingConfig.frompath(path, config.parent, self,
47
def getBashPath(self):
48
"""getBashPath - Get the path to 'bash'"""
51
if self.bashPath is not None:
54
self.bashPath = Util.which('bash', os.pathsep.join(self.path))
55
if self.bashPath is None:
56
# Check some known paths.
57
for path in ('/bin/bash', '/usr/bin/bash'):
58
if os.path.exists(path):
62
if self.bashPath is None:
63
self.warning("Unable to find 'bash', running Tcl tests internally.")
68
def _write_message(self, kind, message):
69
import inspect, os, sys
71
# Get the file/line where this message was generated.
72
f = inspect.currentframe()
73
# Step out of _write_message, and then out of wrapper.
75
file,line,_,_,_ = inspect.getframeinfo(f)
76
location = '%s:%d' % (os.path.basename(file), line)
78
print >>sys.stderr, '%s: %s: %s: %s' % (self.progname, location,
81
def note(self, message):
82
self._write_message('note', message)
84
def warning(self, message):
85
self._write_message('warning', message)
88
def error(self, message):
89
self._write_message('error', message)
92
def fatal(self, message):
94
self._write_message('fatal', message)