summaryrefslogtreecommitdiffstats
path: root/llvm/utils/lit/LitConfig.py
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-09-08 05:31:18 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-09-08 05:31:18 +0000
commita213a427aa19260bb8145ea59f485ea01653c0bb (patch)
tree723a0ecb29b8da189bd16362f99bdadf3809a8f0 /llvm/utils/lit/LitConfig.py
parentba7cdde020fc6e83d982d6f1743bcd1adf1a0f00 (diff)
downloadbcm5719-llvm-a213a427aa19260bb8145ea59f485ea01653c0bb.tar.gz
bcm5719-llvm-a213a427aa19260bb8145ea59f485ea01653c0bb.zip
Add 'lit' testing tool.
- make install && man $(llvm-config --prefix)/share/man/man1/lit.1 for more information. llvm-svn: 81190
Diffstat (limited to 'llvm/utils/lit/LitConfig.py')
-rw-r--r--llvm/utils/lit/LitConfig.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/llvm/utils/lit/LitConfig.py b/llvm/utils/lit/LitConfig.py
new file mode 100644
index 00000000000..4fb0ccc0935
--- /dev/null
+++ b/llvm/utils/lit/LitConfig.py
@@ -0,0 +1,71 @@
+class LitConfig:
+ """LitConfig - Configuration data for a 'lit' test runner instance, shared
+ across all tests.
+
+ The LitConfig object is also used to communicate with client configuration
+ files, it is always passed in as the global variable 'lit' so that
+ configuration files can access common functionality and internal components
+ easily.
+ """
+
+ # Provide access to built-in formats.
+ import LitFormats as formats
+
+ # Provide access to built-in utility functions.
+ import Util as util
+
+ def __init__(self, progname, path, quiet,
+ useValgrind, valgrindArgs,
+ useTclAsSh,
+ noExecute, debug, isWindows):
+ # The name of the test runner.
+ self.progname = progname
+ # The items to add to the PATH environment variable.
+ self.path = list(map(str, path))
+ self.quiet = bool(quiet)
+ self.useValgrind = bool(useValgrind)
+ self.valgrindArgs = list(valgrindArgs)
+ self.useTclAsSh = bool(useTclAsSh)
+ self.noExecute = noExecute
+ self.debug = debug
+ self.isWindows = bool(isWindows)
+
+ self.numErrors = 0
+ self.numWarnings = 0
+
+ def load_config(self, config, path):
+ """load_config(config, path) - Load a config object from an alternate
+ path."""
+ from TestingConfig import TestingConfig
+ return TestingConfig.frompath(path, config.parent, self,
+ mustExist = True,
+ config = config)
+
+ def _write_message(self, kind, message):
+ import inspect, os, sys
+
+ # Get the file/line where this message was generated.
+ f = inspect.currentframe()
+ # Step out of _write_message, and then out of wrapper.
+ f = f.f_back.f_back
+ file,line,_,_,_ = inspect.getframeinfo(f)
+ location = '%s:%d' % (os.path.basename(file), line)
+
+ print >>sys.stderr, '%s: %s: %s: %s' % (self.progname, location,
+ kind, message)
+
+ def note(self, message):
+ self._write_message('note', message)
+
+ def warning(self, message):
+ self._write_message('warning', message)
+ self.numWarnings += 1
+
+ def error(self, message):
+ self._write_message('error', message)
+ self.numErrors += 1
+
+ def fatal(self, message):
+ import sys
+ self._write_message('fatal', message)
+ sys.exit(2)
OpenPOWER on IntegriCloud