llvm-project/llvm/utils/lit/lit/LitTestCase.py
Louis Dionne 49b209d5cc [lit] Remove the --no-indirectly-run-check option
This option had originally been added in D83069 to allow disabling the
check that something is going to get run at all when a specific test name
is used on the command-line. Since we now use getTestsForPath() (from D151664)
to get the tests to run for a specific path, we don't need a specific check
for this anymore -- Lit will produce the same complaint it would produce if
you provided a directory with no tests.

If one needs to run a specific test on the command-line and the Lit
configuration would normally not include that test, the configuration
should be set up as a "standalone" configuration or it should be fixed
to allow for that test to be found (i.e. probably fix the allowed test
suffixes).

Differential Revision: https://reviews.llvm.org/D153967
2023-07-17 17:59:15 -04:00

66 lines
1.6 KiB
Python

import unittest
import lit.discovery
import lit.LitConfig
import lit.worker
"""
TestCase adaptor for providing a Python 'unittest' compatible interface to 'lit'
tests.
"""
class UnresolvedError(RuntimeError):
pass
class LitTestCase(unittest.TestCase):
def __init__(self, test, lit_config):
unittest.TestCase.__init__(self)
self._test = test
self._lit_config = lit_config
def id(self):
return self._test.getFullName()
def shortDescription(self):
return self._test.getFullName()
def runTest(self):
# Run the test.
result = lit.worker._execute(self._test, self._lit_config)
# Adapt the result to unittest.
if result.code is lit.Test.UNRESOLVED:
raise UnresolvedError(result.output)
elif result.code.isFailure:
self.fail(result.output)
def load_test_suite(inputs):
import platform
windows = platform.system() == "Windows"
# Create the global config object.
lit_config = lit.LitConfig.LitConfig(
progname="lit",
path=[],
quiet=False,
useValgrind=False,
valgrindLeakCheck=False,
valgrindArgs=[],
noExecute=False,
debug=False,
isWindows=windows,
order="smart",
params={},
)
# Perform test discovery.
tests = lit.discovery.find_tests_for_inputs(lit_config, inputs)
test_adaptors = [LitTestCase(t, lit_config) for t in tests]
# Return a unittest test suite which just runs the tests in order.
return unittest.TestSuite(test_adaptors)