7 TestCase adaptor for providing a Python 'unittest' compatible interface to 'lit'
12 class UnresolvedError(RuntimeError):
16 class LitTestCase(unittest
.TestCase
):
17 def __init__(self
, test
, lit_config
):
18 unittest
.TestCase
.__init
__(self
)
20 self
._lit
_config
= lit_config
23 return self
._test
.getFullName()
25 def shortDescription(self
):
26 return self
._test
.getFullName()
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
):
41 windows
= platform
.system() == 'Windows'
43 # Create the global config object.
44 lit_config
= lit
.LitConfig
.LitConfig(
49 valgrindLeakCheck
=False,
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
)