diff --git a/llvm/docs/CommandGuide/lit.rst b/llvm/docs/CommandGuide/lit.rst --- a/llvm/docs/CommandGuide/lit.rst +++ b/llvm/docs/CommandGuide/lit.rst @@ -154,6 +154,12 @@ suite take the most time to execute. Note that this option is most useful with ``-j 1``. +.. 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. The environment + variable ``LIT_NO_INDIRECT_CHECK`` can also be used in place of this option. + .. _selection-options: SELECTION OPTIONS diff --git a/llvm/utils/lit/lit/cl_arguments.py b/llvm/utils/lit/lit/cl_arguments.py --- a/llvm/utils/lit/lit/cl_arguments.py +++ b/llvm/utils/lit/lit/cl_arguments.py @@ -128,6 +128,7 @@ 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.", + default=not bool(os.environ.get("LIT_NO_INDIRECT_CHECK", False)), action="store_false") selection_group = parser.add_argument_group("Test Selection") diff --git a/llvm/utils/lit/tests/discovery.py b/llvm/utils/lit/tests/discovery.py --- a/llvm/utils/lit/tests/discovery.py +++ b/llvm/utils/lit/tests/discovery.py @@ -143,11 +143,22 @@ # # CHECK-ERROR-INDIRECT-RUN-CHECK: error: 'top-level-suite :: test.not-txt' would not be run indirectly +# Check an error is emitted with empty LIT_NO_INDIRECT_CHECK. +# +# RUN: env LIT_NO_INDIRECT_CHECK='' not %{lit} \ +# RUN: %{inputs}/discovery/test.not-txt -j 1 2>%t.err +# RUN: FileCheck --check-prefix=CHECK-ERROR-INDIRECT-RUN-CHECK < %t.err %s + # Check that no error is emitted with --no-indirectly-run-check. # # RUN: %{lit} \ # RUN: %{inputs}/discovery/test.not-txt -j 1 --no-indirectly-run-check +# Check that no error is emitted with LIT_NO_INDIRECT_CHECK set. +# +# RUN: env LIT_NO_INDIRECT_CHECK='TRUE' %{lit} \ +# RUN: %{inputs}/discovery/test.not-txt -j 1 --no-indirectly-run-check + # Check that we don't recurse infinitely when loading an site specific test # suite located inside the test source root. #