llvm.org GIT mirror llvm / 2cb3057
[lit] Remove LitTestCase From the docs: `class LitTestCase(unittest.TestCase)` LitTestCase is an adaptor for providing a 'unittest' compatible interface to 'lit' tests so that we can run lit tests with standard python test runners. It does not seem to be used anywhere. Differential Revision: https://reviews.llvm.org/D58264 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@354188 91177308-0d34-0410-b5e6-96231b3b80d8 Julian Lettner 6 months ago
7 changed file(s) with 0 addition(s) and 87 deletion(s). Raw diff Collapse all Expand all
+0
-34
utils/lit/lit/LitTestCase.py less more
None from __future__ import absolute_import
1 import unittest
2
3 import lit.Test
4
5 """
6 TestCase adaptor for providing a 'unittest' compatible interface to 'lit' tests.
7 """
8
9 class UnresolvedError(RuntimeError):
10 pass
11
12 class LitTestCase(unittest.TestCase):
13 def __init__(self, test, run):
14 unittest.TestCase.__init__(self)
15 self._test = test
16 self._run = run
17
18 def id(self):
19 return self._test.getFullName()
20
21 def shortDescription(self):
22 return self._test.getFullName()
23
24 def runTest(self):
25 # Run the test.
26 self._run.execute_test(self._test)
27
28 # Adapt the result to unittest.
29 result = self._test.result
30 if result.code is lit.Test.UNRESOLVED:
31 raise UnresolvedError(result.output)
32 elif result.code.isFailure:
33 self.fail(result.output)
248248 sys.exit(2)
249249
250250 return tests
251
252 def load_test_suite(inputs):
253 import platform
254 import unittest
255 from lit.LitTestCase import LitTestCase
256
257 # Create the global config object.
258 litConfig = LitConfig.LitConfig(progname = 'lit',
259 path = [],
260 quiet = False,
261 useValgrind = False,
262 valgrindLeakCheck = False,
263 valgrindArgs = [],
264 noExecute = False,
265 debug = False,
266 isWindows = (platform.system()=='Windows'),
267 params = {})
268
269 # Perform test discovery.
270 run = lit.run.Run(litConfig, find_tests_for_inputs(litConfig, inputs))
271
272 # Return a unittest test suite which just runs the tests in order.
273 return unittest.TestSuite([LitTestCase(test, run)
274 for test in run.tests])
3030 self.parallelism_semaphores = \
3131 {k: multiprocessing.BoundedSemaphore(v) for k, v in
3232 self.lit_config.parallelism_groups.items()}
33
34 def execute_test(self, test):
35 return lit.worker._execute_test(test, self.lit_config)
3633
3734 def execute_tests_in_pool(self, jobs, max_time):
3835 # We need to issue many wait calls, so compute the final deadline and
+0
-6
utils/lit/tests/Inputs/unittest-adaptor/lit.cfg less more
None import lit.formats
1 config.name = 'unittest-adaptor'
2 config.suffixes = ['.txt']
3 config.test_format = lit.formats.ShTest()
4 config.test_source_root = None
5 config.test_exec_root = None
+0
-1
utils/lit/tests/Inputs/unittest-adaptor/test-one.txt less more
None # RUN: true
+0
-1
utils/lit/tests/Inputs/unittest-adaptor/test-two.txt less more
None # RUN: false
+0
-18
utils/lit/tests/unittest-adaptor.py less more
None # Check the lit adaption to run under unittest.
1 #
2 # RUN: %{python} %s %{inputs}/unittest-adaptor 2> %t.err
3 # RUN: FileCheck < %t.err %s
4 #
5 # CHECK-DAG: unittest-adaptor :: test-two.txt ... FAIL
6 # CHECK-DAG: unittest-adaptor :: test-one.txt ... ok
7
8 import unittest
9 import sys
10
11 import lit
12 import lit.discovery
13
14 input_path = sys.argv[1]
15 unittest_suite = lit.discovery.load_test_suite([input_path])
16 runner = unittest.TextTestRunner(verbosity=2)
17 runner.run(unittest_suite)