[llvm] r174019 - [lit] Move unittest adaptor code into discovery module.
Daniel Dunbar
daniel at zuster.org
Wed Jan 30 17:23:39 PST 2013
Author: ddunbar
Date: Wed Jan 30 19:23:39 2013
New Revision: 174019
URL: http://llvm.org/viewvc/llvm-project?rev=174019&view=rev
Log:
[lit] Move unittest adaptor code into discovery module.
- Also, add a test for it.
Added:
llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/
llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/lit.cfg
llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-one.txt
llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-two.txt
llvm/trunk/utils/lit/tests/unittest-adaptor.py
Modified:
llvm/trunk/utils/lit/lit/discovery.py
llvm/trunk/utils/lit/lit/main.py
Modified: llvm/trunk/utils/lit/lit/discovery.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/discovery.py?rev=174019&r1=174018&r2=174019&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/discovery.py (original)
+++ llvm/trunk/utils/lit/lit/discovery.py Wed Jan 30 19:23:39 2013
@@ -6,7 +6,7 @@ import os
import sys
from lit.TestingConfig import TestingConfig
-from lit import Test
+from lit import LitConfig, Test
def dirContainsTestSuite(path, lit_config):
cfgpath = os.path.join(path, lit_config.site_config_name)
@@ -208,3 +208,27 @@ def find_tests_for_inputs(lit_config, in
sys.exit(2)
return tests
+
+def load_test_suite(inputs):
+ import platform
+ import unittest
+ from lit.LitTestCase import LitTestCase
+
+ # Create the global config object.
+ litConfig = LitConfig.LitConfig(progname = 'lit',
+ path = [],
+ quiet = False,
+ useValgrind = False,
+ valgrindLeakCheck = False,
+ valgrindArgs = [],
+ noExecute = False,
+ ignoreStdErr = False,
+ debug = False,
+ isWindows = (platform.system()=='Windows'),
+ params = {})
+
+ tests = find_tests_for_inputs(litConfig, inputs)
+
+ # Return a unittest test suite which just runs the tests in order.
+ return unittest.TestSuite([LitTestCase(test, litConfig) for test in tests])
+
Modified: llvm/trunk/utils/lit/lit/main.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/lit/main.py?rev=174019&r1=174018&r2=174019&view=diff
==============================================================================
--- llvm/trunk/utils/lit/lit/main.py (original)
+++ llvm/trunk/utils/lit/lit/main.py Wed Jan 30 19:23:39 2013
@@ -148,28 +148,6 @@ def runTests(numThreads, litConfig, prov
except KeyboardInterrupt:
sys.exit(2)
-def load_test_suite(inputs):
- import unittest
-
- # Create the global config object.
- litConfig = LitConfig.LitConfig(progname = 'lit',
- path = [],
- quiet = False,
- useValgrind = False,
- valgrindLeakCheck = False,
- valgrindArgs = [],
- noExecute = False,
- ignoreStdErr = False,
- debug = False,
- isWindows = (platform.system()=='Windows'),
- params = {})
-
- tests = lit.discovery.find_tests_for_inputs(litConfig, inputs)
-
- # Return a unittest test suite which just runs the tests in order.
- from LitTestCase import LitTestCase
- return unittest.TestSuite([LitTestCase(test, litConfig) for test in tests])
-
def main(builtinParameters = {}):
# Bump the GIL check interval, its more important to get any one thread to a
# blocking operation (hopefully exec) than to try and unblock other threads.
Added: llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/lit.cfg
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/lit.cfg?rev=174019&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/lit.cfg (added)
+++ llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/lit.cfg Wed Jan 30 19:23:39 2013
@@ -0,0 +1,5 @@
+config.name = 'unittest-adaptor'
+config.suffixes = ['.txt']
+config.test_format = lit.formats.ShTest()
+config.test_source_root = None
+config.test_exec_root = None
Added: llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-one.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-one.txt?rev=174019&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-one.txt (added)
+++ llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-one.txt Wed Jan 30 19:23:39 2013
@@ -0,0 +1 @@
+# RUN: true
Added: llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-two.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-two.txt?rev=174019&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-two.txt (added)
+++ llvm/trunk/utils/lit/tests/Inputs/unittest-adaptor/test-two.txt Wed Jan 30 19:23:39 2013
@@ -0,0 +1 @@
+# RUN: false
Added: llvm/trunk/utils/lit/tests/unittest-adaptor.py
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/lit/tests/unittest-adaptor.py?rev=174019&view=auto
==============================================================================
--- llvm/trunk/utils/lit/tests/unittest-adaptor.py (added)
+++ llvm/trunk/utils/lit/tests/unittest-adaptor.py Wed Jan 30 19:23:39 2013
@@ -0,0 +1,18 @@
+# Check the lit adaption to run under unittest.
+#
+# RUN: python %s %{inputs}/unittest-adaptor 2> %t.err
+# RUN: FileCheck < %t.err %s
+#
+# CHECK: unittest-adaptor :: test-one.txt ... ok
+# CHECK: unittest-adaptor :: test-two.txt ... FAIL
+
+import unittest
+import sys
+
+import lit
+import lit.discovery
+
+input_path = sys.argv[1]
+unittest_suite = lit.discovery.load_test_suite([input_path])
+runner = unittest.TextTestRunner(verbosity=2)
+runner.run(unittest_suite)
More information about the llvm-commits
mailing list