llvm.org GIT mirror llvm / 4571da6
[FileCheck] Provide an option for FileCheck to dump original input to stderr on failure The option can be either set using environment variable (e.g. env FILECHECK_DUMP_INPUT_ON_FAILURE=1 ninja check-fuzzer) or with a FileCheck flag. This can be extremely useful for debugging, cf. https://groups.google.com/forum/#!topic/llvm-dev/kLrzg8OM_h8 for discussion. Differential Revision: https://reviews.llvm.org/D49328 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@337609 91177308-0d34-0410-b5e6-96231b3b80d8 George Karpenkov 1 year, 3 months ago
4 changed file(s) with 36 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
7575 diagnostic messages from tools that don't have an option similar to ``clang
7676 -verify``. With this option FileCheck will verify that input does not contain
7777 warnings not covered by any ``CHECK:`` patterns.
78
79 .. option:: --dump-input-on-failure
80
81 When the check fails, dump all of the original input.
7882
7983 .. option:: --enable-var-scope
8084
0 ; RUN: not FileCheck -input-file %s %s --check-prefix=CHECK1 --match-full-lines --dump-input-on-failure 2>&1 | FileCheck %s --check-prefix=CHECKERROR --match-full-lines
1 ; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 not FileCheck -input-file %s %s --check-prefix=CHECK1 --match-full-lines 2>&1 | FileCheck %s --check-prefix=CHECKERROR --match-full-lines
2 ; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 not FileCheck -input-file %s %s --check-prefix=CHECK1 --match-full-lines --dump-input-on-failure=0 2>&1 | FileCheck %s --check-prefix=CHECKERRORNOVERBOSE --match-full-lines
3
4 hello
5 world
6
7 ; CHECK1: ciao
8 ; CHECK1-NEXT: world
9
10 ; CHECKERROR: Full input was:
11 ; CHECKERROR-NEXT: <<<<<<
12 ; CHECKERROR: hello
13 ; CHECKERROR: world
14 ; CHECKERROR: >>>>>>
15
16 ; CHECKERRORNOVERBOSE-NOT: <<<<<<
9696 "vv", cl::init(false),
9797 cl::desc("Print information helpful in diagnosing internal FileCheck\n"
9898 "issues. Implies -v.\n"));
99 static const char * DumpInputEnv = "FILECHECK_DUMP_INPUT_ON_FAILURE";
100
101 static cl::opt DumpInputOnFailure(
102 "dump-input-on-failure", cl::init(std::getenv(DumpInputEnv)),
103 cl::desc("Dump original input to stderr before failing.\n"
104 "The value can be also controlled using\n"
105 "FILECHECK_DUMP_INPUT_ON_FAILURE environment variable.\n"));
99106
100107 typedef cl::list::const_iterator prefix_iterator;
101108
16041611 InputFileText, InputFile.getBufferIdentifier()),
16051612 SMLoc());
16061613
1607 return CheckInput(SM, InputFileText, CheckStrings) ? EXIT_SUCCESS : 1;
1608 }
1614 int ExitCode = CheckInput(SM, InputFileText, CheckStrings) ? EXIT_SUCCESS : 1;
1615 if (ExitCode == 1 && DumpInputOnFailure)
1616 errs() << "Full input was:\n<<<<<<\n" << InputFileText << "\n>>>>>>\n";
1617
1618 return ExitCode;
1619 }
2424 'CLANG', 'LD_PRELOAD', 'ASAN_OPTIONS', 'UBSAN_OPTIONS',
2525 'LSAN_OPTIONS', 'ADB', 'ANDROID_SERIAL',
2626 'SANITIZER_IGNORE_CVE_2016_2143', 'TMPDIR', 'TMP', 'TEMP',
27 'TEMPDIR', 'AVRLIT_BOARD', 'AVRLIT_PORT']
27 'TEMPDIR', 'AVRLIT_BOARD', 'AVRLIT_PORT',
28 'FILECHECK_DUMP_INPUT_ON_FAILURE']
2829 for var in pass_vars:
2930 val = os.environ.get(var, '')
3031 # Check for empty string as some variables such as LD_PRELOAD cannot be empty