Index: llvm/utils/lit/lit/LitConfig.py =================================================================== --- llvm/utils/lit/lit/LitConfig.py +++ llvm/utils/lit/lit/LitConfig.py @@ -26,7 +26,8 @@ maxIndividualTestTime = 0, maxFailures = None, parallelism_groups = {}, - echo_all_commands = False): + echo_all_commands = False, + debug_level = 0): # The name of the test runner. self.progname = progname # The items to add to the PATH environment variable. @@ -68,6 +69,7 @@ self.maxFailures = maxFailures self.parallelism_groups = parallelism_groups self.echo_all_commands = echo_all_commands + self.debug_level = debug_level @property def maxIndividualTestTime(self): Index: llvm/utils/lit/lit/TestingConfig.py =================================================================== --- llvm/utils/lit/lit/TestingConfig.py +++ llvm/utils/lit/lit/TestingConfig.py @@ -21,6 +21,9 @@ 'LLVM_DISABLE_CRASH_REPORT' : '1', } + if (litConfig.debug_level >= 2): + environment['FILECHECK_DUMP_INPUT_ON_FAILURE'] = '1' + pass_vars = ['LIBRARY_PATH', 'LD_LIBRARY_PATH', 'SYSTEMROOT', 'TERM', 'CLANG', 'LD_PRELOAD', 'ASAN_OPTIONS', 'UBSAN_OPTIONS', 'LSAN_OPTIONS', 'ADB', 'ANDROID_SERIAL', Index: llvm/utils/lit/lit/main.py =================================================================== --- llvm/utils/lit/lit/main.py +++ llvm/utils/lit/lit/main.py @@ -201,10 +201,14 @@ def main_with_tmp(builtinParameters): parser = argparse.ArgumentParser() + debug_level = 0 + if os.getenv("LIT_DEBUG") == "1": + debug_level = 1 + if os.getenv("LIT_DEBUG") == "2": + debug_level = 2 parser.add_argument('test_paths', nargs='*', help='Files or paths to include in the test suite') - parser.add_argument("--version", dest="show_version", help="Show version and exit", action="store_true", default=False) @@ -233,7 +237,7 @@ action="store_true", default=False) format_group.add_argument("-vv", "--echo-all-commands", dest="echoAllCommands", - action="store_true", default=False, + action="store_true", default=(debug_level >= 1), help="Echo all commands as they are executed to stdout.\ In case of failure, last command shown will be the\ failing one.") @@ -382,7 +386,8 @@ maxIndividualTestTime = maxIndividualTestTime, maxFailures = opts.maxFailures, parallelism_groups = {}, - echo_all_commands = opts.echoAllCommands) + echo_all_commands = opts.echoAllCommands, + debug_level = debug_level) # Perform test discovery. run = lit.run.Run(litConfig, Index: llvm/utils/lit/tests/Inputs/test_verbose_filecheck =================================================================== --- /dev/null +++ llvm/utils/lit/tests/Inputs/test_verbose_filecheck @@ -0,0 +1,13 @@ +; RUN: not FileCheck -input-file %s %s --check-prefix=CHECK1 --match-full-lines 2>&1 | FileCheck %s --match-full-lines + +hello +world + +; CHECK1: ciao +; CHECK1-NEXT: world + +; CHECK: Full input was: +; CHECK-NEXT: <<<<<< +; CHECK: hello +; CHECK: world +; CHECK: >>>>>> Index: llvm/utils/lit/tests/debug.py =================================================================== --- /dev/null +++ llvm/utils/lit/tests/debug.py @@ -0,0 +1,3 @@ +# Check that LIT_DEBUG causes FileCheck to be verbose. + +# RUN: env LIT_DEBUG=2 %{lit} %{inputs}/test_verbose_filecheck Index: llvm/utils/lit/tests/shtest-run-at-line.py =================================================================== --- llvm/utils/lit/tests/shtest-run-at-line.py +++ llvm/utils/lit/tests/shtest-run-at-line.py @@ -3,6 +3,8 @@ # # RUN: not %{lit} -j 1 -vv %{inputs}/shtest-run-at-line > %t.out # RUN: FileCheck --input-file %t.out %s +# RUN: env LIT_DEBUG=1 not %{lit} -j 1 %{inputs}/shtest-run-at-line > %t.out +# RUN: FileCheck --input-file %t.out %s # # END.