aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis Dionne <ldionne.2@gmail.com>2023-06-27 16:34:06 -0400
committerLouis Dionne <ldionne.2@gmail.com>2023-07-17 17:59:15 -0400
commit49b209d5cca3750f71e8a6fda1c5870295ef3a9c (patch)
tree8373745f795dcf27969a8ebfd8d2ba301b6a50f2
parent1cb3fbc713c4d6db2765b7d507c599b9df4a12b0 (diff)
downloadllvm-49b209d5cca3750f71e8a6fda1c5870295ef3a9c.zip
llvm-49b209d5cca3750f71e8a6fda1c5870295ef3a9c.tar.gz
llvm-49b209d5cca3750f71e8a6fda1c5870295ef3a9c.tar.bz2
[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
-rw-r--r--llvm/docs/CommandGuide/lit.rst10
-rw-r--r--llvm/utils/lit/lit/LitTestCase.py2
-rw-r--r--llvm/utils/lit/lit/cl_arguments.py8
-rw-r--r--llvm/utils/lit/lit/discovery.py47
-rw-r--r--llvm/utils/lit/lit/formats/base.py3
-rwxr-xr-xllvm/utils/lit/lit/main.py2
-rw-r--r--llvm/utils/lit/tests/discovery.py5
-rw-r--r--llvm/utils/lit/tests/unit/TestRunner.py2
8 files changed, 16 insertions, 63 deletions
diff --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst
index b3b3622..2f587c4 100644
--- a/llvm/docs/CommandGuide/lit.rst
+++ b/llvm/docs/CommandGuide/lit.rst
@@ -163,11 +163,6 @@ EXECUTION OPTIONS
Exit with status zero even if some tests fail.
-.. option:: --no-indirectly-run-check
-
- Do not error if a test would not be run if the user had specified the
- containing directory instead of naming the test directly.
-
.. _selection-options:
SELECTION OPTIONS
@@ -458,9 +453,8 @@ executed, two important global variables are predefined:
tests in the suite.
**standalone_tests** When true, mark a directory with tests expected to be run
- standalone. Test discovery is disabled for that directory and
- *--no-indirectly-run-check* is in effect. *lit.suffixes* and *lit.excludes*
- must be empty when this variable is true.
+ standalone. Test discovery is disabled for that directory. *lit.suffixes* and
+ *lit.excludes* must be empty when this variable is true.
**suffixes** For **lit** test formats which scan directories for tests, this
variable is a list of suffixes to identify test files. Used by: *ShTest*.
diff --git a/llvm/utils/lit/lit/LitTestCase.py b/llvm/utils/lit/lit/LitTestCase.py
index d44b76a..566d068 100644
--- a/llvm/utils/lit/lit/LitTestCase.py
+++ b/llvm/utils/lit/lit/LitTestCase.py
@@ -58,7 +58,7 @@ def load_test_suite(inputs):
)
# Perform test discovery.
- tests = lit.discovery.find_tests_for_inputs(lit_config, inputs, False)
+ 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.
diff --git a/llvm/utils/lit/lit/cl_arguments.py b/llvm/utils/lit/lit/cl_arguments.py
index c20bbee..5c0dde5 100644
--- a/llvm/utils/lit/lit/cl_arguments.py
+++ b/llvm/utils/lit/lit/cl_arguments.py
@@ -190,14 +190,6 @@ def parse_args():
action="store_true",
help="Exit with status zero even if some tests fail",
)
- execution_group.add_argument(
- "--no-indirectly-run-check",
- dest="indirectlyRunCheck",
- help="Do not error if a test would not be run if the user had "
- "specified the containing directory instead of naming the "
- "test directly.",
- action="store_false",
- )
selection_group = parser.add_argument_group("Test Selection")
selection_group.add_argument(
diff --git a/llvm/utils/lit/lit/discovery.py b/llvm/utils/lit/lit/discovery.py
index e421a87..161a01a 100644
--- a/llvm/utils/lit/lit/discovery.py
+++ b/llvm/utils/lit/lit/discovery.py
@@ -130,7 +130,7 @@ def getLocalConfig(ts, path_in_suite, litConfig, cache):
return search(path_in_suite)
-def getTests(path, litConfig, testSuiteCache, localConfigCache, indirectlyRunCheck):
+def getTests(path, litConfig, testSuiteCache, localConfigCache):
# Find the test suite for this input and its relative path.
ts, path_in_suite = getTestSuite(path, litConfig, testSuiteCache)
if ts is None:
@@ -146,12 +146,11 @@ def getTests(path, litConfig, testSuiteCache, localConfigCache, indirectlyRunChe
litConfig,
testSuiteCache,
localConfigCache,
- indirectlyRunCheck,
)
def getTestsInSuite(
- ts, path_in_suite, litConfig, testSuiteCache, localConfigCache, indirectlyRunCheck
+ ts, path_in_suite, litConfig, testSuiteCache, localConfigCache
):
# Check that the source path exists (errors here are reported by the
# caller).
@@ -164,41 +163,14 @@ def getTestsInSuite(
test_dir_in_suite = path_in_suite[:-1]
lc = getLocalConfig(ts, test_dir_in_suite, litConfig, localConfigCache)
- # TODO: Stop checking for indirectlyRunCheck and lc.standalone_tests here
- # once we remove --no-indirectly-run-check, which is not needed anymore
- # now that we error out when trying to run a test that wouldn't be
- # discovered in the directory.
- fallbackOnSingleTest = lc.test_format is None or not indirectlyRunCheck or lc.standalone_tests
- tests = [Test.Test(ts, path_in_suite, lc)] if fallbackOnSingleTest else \
+ # If we don't have a test format or if we are running standalone tests,
+ # always "find" the test itself. Otherwise, we might find no tests at
+ # all, which is considered an error but isn't an error with standalone
+ # tests.
+ tests = [Test.Test(ts, path_in_suite, lc)] if lc.test_format is None or lc.standalone_tests else \
lc.test_format.getTestsForPath(ts, path_in_suite, litConfig, lc)
for test in tests:
- # Issue a error if the specified test would not be run if
- # the user had specified the containing directory instead of
- # of naming the test directly. This helps to avoid writing
- # tests which are not executed. The check adds some performance
- # overhead which might be important if a large number of tests
- # are being run directly.
- # This check can be disabled by using --no-indirectly-run-check or
- # setting the standalone_tests variable in the suite's configuration.
- if (
- indirectlyRunCheck
- and lc.test_format is not None
- and not lc.standalone_tests
- ):
- found = False
- for res in lc.test_format.getTestsInDirectory(
- ts, test_dir_in_suite, litConfig, lc
- ):
- if test.getFullName() == res.getFullName():
- found = True
- break
- if not found:
- litConfig.error(
- "%r would not be run indirectly: change name or LIT config"
- "(e.g. suffixes or standalone_tests variables)" % test.getFullName()
- )
-
yield test
return
@@ -260,7 +232,6 @@ def getTestsInSuite(
litConfig,
testSuiteCache,
localConfigCache,
- indirectlyRunCheck,
)
else:
subiter = getTestsInSuite(
@@ -269,7 +240,6 @@ def getTestsInSuite(
litConfig,
testSuiteCache,
localConfigCache,
- indirectlyRunCheck,
)
N = 0
@@ -280,7 +250,7 @@ def getTestsInSuite(
litConfig.warning("test suite %r contained no tests" % sub_ts.name)
-def find_tests_for_inputs(lit_config, inputs, indirectlyRunCheck):
+def find_tests_for_inputs(lit_config, inputs):
"""
find_tests_for_inputs(lit_config, inputs) -> [Test]
@@ -315,7 +285,6 @@ def find_tests_for_inputs(lit_config, inputs, indirectlyRunCheck):
lit_config,
test_suite_cache,
local_config_cache,
- indirectlyRunCheck,
)[1]
)
if prev == len(tests):
diff --git a/llvm/utils/lit/lit/formats/base.py b/llvm/utils/lit/lit/formats/base.py
index 3db817b..27f7c7e 100644
--- a/llvm/utils/lit/lit/formats/base.py
+++ b/llvm/utils/lit/lit/formats/base.py
@@ -12,6 +12,9 @@ class TestFormat(object):
to that path. There can be zero, one or more tests. For example, some testing
formats allow expanding a single path in the test suite into multiple Lit tests
(e.g. they are generated on the fly).
+
+ Note that this method is only used when Lit needs to actually perform test
+ discovery, which is not the case for configs with standalone tests.
"""
yield lit.Test.Test(testSuite, path_in_suite, localConfig)
diff --git a/llvm/utils/lit/lit/main.py b/llvm/utils/lit/lit/main.py
index 236b2e7..cf9186d 100755
--- a/llvm/utils/lit/lit/main.py
+++ b/llvm/utils/lit/lit/main.py
@@ -44,7 +44,7 @@ def main(builtin_params={}):
)
discovered_tests = lit.discovery.find_tests_for_inputs(
- lit_config, opts.test_paths, opts.indirectlyRunCheck
+ lit_config, opts.test_paths
)
if not discovered_tests:
sys.stderr.write("error: did not discover any tests for provided path(s)\n")
diff --git a/llvm/utils/lit/tests/discovery.py b/llvm/utils/lit/tests/discovery.py
index 5bf2557..67f940f 100644
--- a/llvm/utils/lit/tests/discovery.py
+++ b/llvm/utils/lit/tests/discovery.py
@@ -144,11 +144,6 @@
# CHECK-ERROR-INPUT-CONTAINED-NO-TESTS: warning: input 'Inputs/discovery/test.not-txt' contained no tests
# CHECK-ERROR-INPUT-CONTAINED-NO-TESTS: error: did not discover any tests for provided path(s)
-# Check that no error is emitted with --no-indirectly-run-check.
-#
-# RUN: %{lit} \
-# RUN: %{inputs}/discovery/test.not-txt --no-indirectly-run-check
-
# Check that a standalone test with no suffixes set is run without any errors.
#
# RUN: %{lit} %{inputs}/standalone-tests/true.txt > %t.out
diff --git a/llvm/utils/lit/tests/unit/TestRunner.py b/llvm/utils/lit/tests/unit/TestRunner.py
index 01e771b..e9888d6 100644
--- a/llvm/utils/lit/tests/unit/TestRunner.py
+++ b/llvm/utils/lit/tests/unit/TestRunner.py
@@ -45,7 +45,7 @@ class TestIntegratedTestKeywordParser(unittest.TestCase):
test_path = os.path.dirname(os.path.dirname(__file__))
inputs = [os.path.join(test_path, "Inputs/testrunner-custom-parsers/")]
assert os.path.isdir(inputs[0])
- tests = lit.discovery.find_tests_for_inputs(lit_config, inputs, False)
+ tests = lit.discovery.find_tests_for_inputs(lit_config, inputs)
assert len(tests) == 1 and "there should only be one test"
TestIntegratedTestKeywordParser.inputTestCase = tests[0]