[lit] Remove redundancy from names and comments
[llvm-core.git] / utils / lit / lit / LitTestCase.py
blobd8a3fc37c892677db79d751eb297c4b7cfba0694
1 import unittest
3 import lit.worker
4 import lit.LitConfig
6 """
7 TestCase adaptor for providing a Python 'unittest' compatible interface to 'lit'
8 tests.
9 """
12 class UnresolvedError(RuntimeError):
13 pass
16 class LitTestCase(unittest.TestCase):
17 def __init__(self, test, lit_config):
18 unittest.TestCase.__init__(self)
19 self._test = test
20 self._lit_config = lit_config
22 def id(self):
23 return self._test.getFullName()
25 def shortDescription(self):
26 return self._test.getFullName()
28 def runTest(self):
29 # Run the test.
30 result = lit.worker._execute(self._test, self._lit_config)
32 # Adapt the result to unittest.
33 if result.code is lit.Test.UNRESOLVED:
34 raise UnresolvedError(result.output)
35 elif result.code.isFailure:
36 self.fail(result.output)
39 def load_test_suite(inputs):
40 import platform
41 windows = platform.system() == 'Windows'
43 # Create the global config object.
44 lit_config = lit.LitConfig.LitConfig(
45 progname='lit',
46 path=[],
47 quiet=False,
48 useValgrind=False,
49 valgrindLeakCheck=False,
50 valgrindArgs=[],
51 noExecute=False,
52 debug=False,
53 isWindows=windows,
54 params={})
56 # Perform test discovery.
57 tests = lit.discovery.find_tests_for_inputs(lit_config, inputs)
58 test_adaptors = [LitTestCase(t, lit_config) for t in tests]
60 # Return a unittest test suite which just runs the tests in order.
61 return unittest.TestSuite(test_adaptors)