summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2013-08-07 03:23:12 +0000
committerDaniel Dunbar <daniel@zuster.org>2013-08-07 03:23:12 +0000
commitb35a1733607b07f36c3617932b67debb375a15c5 (patch)
treee54197f70c9498ddbcbe9636e1fbd915eb7a27d5 /utils
parent304a0b03980996669ce2afc09b2bfe21381c5fdf (diff)
downloadllvm-b35a1733607b07f36c3617932b67debb375a15c5.tar.gz
llvm-b35a1733607b07f36c3617932b67debb375a15c5.tar.bz2
llvm-b35a1733607b07f36c3617932b67debb375a15c5.tar.xz
[lit] Use modern absolute/relative import style.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187860 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/lit/lit/LitConfig.py29
-rw-r--r--utils/lit/lit/ShUtil.py15
-rw-r--r--utils/lit/lit/TestFormats.py41
-rw-r--r--utils/lit/lit/TestRunner.py8
-rw-r--r--utils/lit/lit/__init__.py3
-rwxr-xr-xutils/lit/lit/main.py64
6 files changed, 84 insertions, 76 deletions
diff --git a/utils/lit/lit/LitConfig.py b/utils/lit/lit/LitConfig.py
index 8eac818a6b..991879f260 100644
--- a/utils/lit/lit/LitConfig.py
+++ b/utils/lit/lit/LitConfig.py
@@ -1,3 +1,11 @@
+from __future__ import absolute_import
+import os
+
+import lit.Test
+import lit.TestFormats
+import lit.TestingConfig
+import lit.Util
+
class LitConfig:
"""LitConfig - Configuration data for a 'lit' test runner instance, shared
across all tests.
@@ -9,13 +17,13 @@ class LitConfig:
"""
# Provide access to Test module.
- import Test
+ Test = lit.Test
# Provide access to built-in formats.
- import TestFormats as formats
+ formats = lit.TestFormats
# Provide access to built-in utility functions.
- import Util as util
+ util = lit.Util
def __init__(self, progname, path, quiet,
useValgrind, valgrindLeakCheck, valgrindArgs,
@@ -58,21 +66,19 @@ class LitConfig:
def load_config(self, config, path):
"""load_config(config, path) - Load a config object from an alternate
path."""
- from TestingConfig import TestingConfig
if self.debug:
self.note('load_config from %r' % path)
- return TestingConfig.frompath(path, config.parent, self,
- mustExist = True,
- config = config)
+ return lit.TestingConfig.TestingConfig.frompath(
+ path, config.parent, self, mustExist = True, config = config)
def getBashPath(self):
"""getBashPath - Get the path to 'bash'"""
- import os, Util
+ import os
if self.bashPath is not None:
return self.bashPath
- self.bashPath = Util.which('bash', os.pathsep.join(self.path))
+ self.bashPath = lit.Util.which('bash', os.pathsep.join(self.path))
if self.bashPath is None:
# Check some known paths.
for path in ('/bin/bash', '/usr/bin/bash', '/usr/local/bin/bash'):
@@ -87,12 +93,11 @@ class LitConfig:
return self.bashPath
def getToolsPath(self, dir, paths, tools):
- import os, Util
if dir is not None and os.path.isabs(dir) and os.path.isdir(dir):
- if not Util.checkToolsPath(dir, tools):
+ if not lit.Util.checkToolsPath(dir, tools):
return None
else:
- dir = Util.whichTools(tools, paths)
+ dir = lit.Util.whichTools(tools, paths)
# bash
self.bashPath = Util.which('bash', dir)
diff --git a/utils/lit/lit/ShUtil.py b/utils/lit/lit/ShUtil.py
index a7892a43ab..fb0689b859 100644
--- a/utils/lit/lit/ShUtil.py
+++ b/utils/lit/lit/ShUtil.py
@@ -1,7 +1,8 @@
+from __future__ import absolute_import
import itertools
-import Util
-from ShCommands import Command, Pipeline, Seq
+import lit.Util
+from lit.ShCommands import Command, Pipeline, Seq
class ShLexer:
def __init__(self, data, win32Escapes = False):
@@ -74,8 +75,8 @@ class ShLexer:
# Outside of a string, '\\' escapes everything.
self.eat()
if self.pos == self.end:
- Util.warning("escape at end of quoted argument in: %r" %
- self.data)
+ lit.Util.warning(
+ "escape at end of quoted argument in: %r" % self.data)
return str
str += self.eat()
else:
@@ -92,8 +93,8 @@ class ShLexer:
# Inside a '"' quoted string, '\\' only escapes the quote
# character and backslash, otherwise it is preserved.
if self.pos == self.end:
- Util.warning("escape at end of quoted argument in: %r" %
- self.data)
+ lit.Util.warning(
+ "escape at end of quoted argument in: %r" % self.data)
return str
c = self.eat()
if c == '"': #
@@ -104,7 +105,7 @@ class ShLexer:
str += '\\' + c
else:
str += c
- Util.warning("missing quote character in %r" % self.data)
+ lit.Util.warning("missing quote character in %r" % self.data)
return str
def lex_arg_checked(self, c):
diff --git a/utils/lit/lit/TestFormats.py b/utils/lit/lit/TestFormats.py
index 7e4fafcf1a..a9707cccb3 100644
--- a/utils/lit/lit/TestFormats.py
+++ b/utils/lit/lit/TestFormats.py
@@ -1,9 +1,10 @@
+from __future__ import absolute_import
import os
import sys
-import Test
-import TestRunner
-import Util
+import lit.Test
+import lit.TestRunner
+import lit.Util
kIsWindows = sys.platform in ['win32', 'cygwin']
@@ -27,8 +28,8 @@ class GoogleTest(object):
localConfig: TestingConfig instance"""
try:
- lines = Util.capture([path, '--gtest_list_tests'],
- env=localConfig.environment)
+ lines = lit.Util.capture([path, '--gtest_list_tests'],
+ env=localConfig.environment)
if kIsWindows:
lines = lines.replace('\r', '')
lines = lines.split('\n')
@@ -63,7 +64,7 @@ class GoogleTest(object):
# Discover the tests in this executable.
for testname in self.getGTestTests(execpath, litConfig, localConfig):
testPath = path_in_suite + (basename, testname)
- yield Test.Test(testSuite, testPath, localConfig)
+ yield lit.Test.Test(testSuite, testPath, localConfig)
def getTestsInDirectory(self, testSuite, path_in_suite,
litConfig, localConfig):
@@ -99,13 +100,13 @@ class GoogleTest(object):
if litConfig.useValgrind:
cmd = litConfig.valgrindArgs + cmd
- out, err, exitCode = TestRunner.executeCommand(
+ out, err, exitCode = lit.TestRunner.executeCommand(
cmd, env=test.config.environment)
if not exitCode:
- return Test.PASS,''
+ return lit.Test.PASS,''
- return Test.FAIL, out + err
+ return lit.Test.FAIL, out + err
###
@@ -123,16 +124,16 @@ class FileBasedTest(object):
if not os.path.isdir(filepath):
base,ext = os.path.splitext(filename)
if ext in localConfig.suffixes:
- yield Test.Test(testSuite, path_in_suite + (filename,),
- localConfig)
+ yield lit.Test.Test(testSuite, path_in_suite + (filename,),
+ localConfig)
class ShTest(FileBasedTest):
def __init__(self, execute_external = False):
self.execute_external = execute_external
def execute(self, test, litConfig):
- return TestRunner.executeShTest(test, litConfig,
- self.execute_external)
+ return lit.TestRunner.executeShTest(test, litConfig,
+ self.execute_external)
###
@@ -180,9 +181,9 @@ class OneCommandPerFileTest:
suffix = path[len(dir):]
if suffix.startswith(os.sep):
suffix = suffix[1:]
- test = Test.Test(testSuite,
- path_in_suite + tuple(suffix.split(os.sep)),
- localConfig)
+ test = lit.Test.Test(
+ testSuite, path_in_suite + tuple(suffix.split(os.sep)),
+ localConfig)
# FIXME: Hack?
test.source_path = path
yield test
@@ -192,7 +193,7 @@ class OneCommandPerFileTest:
def execute(self, test, litConfig):
if test.config.unsupported:
- return (Test.UNSUPPORTED, 'Test is unsupported')
+ return (lit.Test.UNSUPPORTED, 'Test is unsupported')
cmd = list(self.command)
@@ -208,11 +209,11 @@ class OneCommandPerFileTest:
else:
cmd.append(test.getSourcePath())
- out, err, exitCode = TestRunner.executeCommand(cmd)
+ out, err, exitCode = lit.TestRunner.executeCommand(cmd)
diags = out + err
if not exitCode and not diags.strip():
- return Test.PASS,''
+ return lit.Test.PASS,''
# Try to include some useful information.
report = """Command: %s\n""" % ' '.join(["'%s'" % a
@@ -222,4 +223,4 @@ class OneCommandPerFileTest:
report += "--\n%s--\n""" % open(tmp.name).read()
report += """Output:\n--\n%s--""" % diags
- return Test.FAIL, report
+ return lit.Test.FAIL, report
diff --git a/utils/lit/lit/TestRunner.py b/utils/lit/lit/TestRunner.py
index d8bc7e5911..4898f51bd5 100644
--- a/utils/lit/lit/TestRunner.py
+++ b/utils/lit/lit/TestRunner.py
@@ -1,14 +1,14 @@
+from __future__ import absolute_import
import os, signal, subprocess, sys
import StringIO
-import ShUtil
-import Test
-import Util
-
import platform
import tempfile
import re
+import lit.ShUtil as ShUtil
+import lit.Test as Test
+import lit.Util as Util
class InternalShellError(Exception):
def __init__(self, command, message):
diff --git a/utils/lit/lit/__init__.py b/utils/lit/lit/__init__.py
index 3e61bbd770..b9f573d931 100644
--- a/utils/lit/lit/__init__.py
+++ b/utils/lit/lit/__init__.py
@@ -1,6 +1,7 @@
"""'lit' Testing Tool"""
-from main import main
+from __future__ import absolute_import
+from .main import main
__author__ = 'Daniel Dunbar'
__email__ = 'daniel@zuster.org'
diff --git a/utils/lit/lit/main.py b/utils/lit/lit/main.py
index 84ed016f0c..423c9d0e92 100755
--- a/utils/lit/lit/main.py
+++ b/utils/lit/lit/main.py
@@ -6,14 +6,13 @@ lit - LLVM Integrated Tester.
See lit.pod for more information.
"""
+from __future__ import absolute_import
import math, os, platform, random, re, sys, time, threading, traceback
-import ProgressBar
-import TestRunner
-import Util
-
-import LitConfig
-import Test
+import lit.ProgressBar
+import lit.LitConfig
+import lit.Test
+import lit.Util
import lit.discovery
@@ -129,7 +128,7 @@ class Tester(threading.Thread):
except:
if self.litConfig.debug:
raise
- result = Test.UNRESOLVED
+ result = lit.Test.UNRESOLVED
output = 'Exception during script execution:\n'
output += traceback.format_exc()
output += '\n'
@@ -257,7 +256,7 @@ def main(builtinParameters = {}):
# I haven't seen this bug occur with 2.5.2 and later, so only enable multiple
# threads by default there.
if sys.hexversion >= 0x2050200:
- opts.numThreads = Util.detectCPUs()
+ opts.numThreads = lit.Util.detectCPUs()
else:
opts.numThreads = 1
@@ -273,16 +272,17 @@ def main(builtinParameters = {}):
userParams[name] = val
# Create the global config object.
- litConfig = LitConfig.LitConfig(progname = os.path.basename(sys.argv[0]),
- path = opts.path,
- quiet = opts.quiet,
- useValgrind = opts.useValgrind,
- valgrindLeakCheck = opts.valgrindLeakCheck,
- valgrindArgs = opts.valgrindArgs,
- debug = opts.debug,
- isWindows = (platform.system()=='Windows'),
- params = userParams,
- config_prefix = opts.configPrefix)
+ litConfig = lit.LitConfig.LitConfig(
+ progname = os.path.basename(sys.argv[0]),
+ path = opts.path,
+ quiet = opts.quiet,
+ useValgrind = opts.useValgrind,
+ valgrindLeakCheck = opts.valgrindLeakCheck,
+ valgrindArgs = opts.valgrindArgs,
+ debug = opts.debug,
+ isWindows = (platform.system()=='Windows'),
+ params = userParams,
+ config_prefix = opts.configPrefix)
tests = lit.discovery.find_tests_for_inputs(litConfig, inputs)
@@ -353,11 +353,11 @@ def main(builtinParameters = {}):
if not opts.quiet:
if opts.succinct and opts.useProgressBar:
try:
- tc = ProgressBar.TerminalController()
- progressBar = ProgressBar.ProgressBar(tc, header)
+ tc = lit.ProgressBar.TerminalController()
+ progressBar = lit.ProgressBar.ProgressBar(tc, header)
except ValueError:
print(header)
- progressBar = ProgressBar.SimpleProgressBar('Testing: ')
+ progressBar = lit.ProgressBar.SimpleProgressBar('Testing: ')
else:
print(header)
@@ -384,7 +384,7 @@ def main(builtinParameters = {}):
# Update results for any tests which weren't run.
for t in tests:
if t.result is None:
- t.setResult(Test.UNRESOLVED, '', 0.0)
+ t.setResult(lit.Test.UNRESOLVED, '', 0.0)
# List test results organized by kind.
hasFailures = False
@@ -397,8 +397,8 @@ def main(builtinParameters = {}):
hasFailures = True
# FIXME: Show unresolved and (optionally) unsupported tests.
- for title,code in (('Unexpected Passing Tests', Test.XPASS),
- ('Failing Tests', Test.FAIL)):
+ for title,code in (('Unexpected Passing Tests', lit.Test.XPASS),
+ ('Failing Tests', lit.Test.FAIL)):
elts = byCode.get(code)
if not elts:
continue
@@ -418,14 +418,14 @@ def main(builtinParameters = {}):
byTime = list(times.items())
byTime.sort(key = lambda item: item[1])
if byTime:
- Util.printHistogram(byTime, title='Tests')
-
- for name,code in (('Expected Passes ', Test.PASS),
- ('Expected Failures ', Test.XFAIL),
- ('Unsupported Tests ', Test.UNSUPPORTED),
- ('Unresolved Tests ', Test.UNRESOLVED),
- ('Unexpected Passes ', Test.XPASS),
- ('Unexpected Failures', Test.FAIL),):
+ lit.Util.printHistogram(byTime, title='Tests')
+
+ for name,code in (('Expected Passes ', lit.Test.PASS),
+ ('Expected Failures ', lit.Test.XFAIL),
+ ('Unsupported Tests ', lit.Test.UNSUPPORTED),
+ ('Unresolved Tests ', lit.Test.UNRESOLVED),
+ ('Unexpected Passes ', lit.Test.XPASS),
+ ('Unexpected Failures', lit.Test.FAIL),):
if opts.quiet and not code.isFailure:
continue
N = len(byCode.get(code,[]))