[PATCH] D49328: [FileCheck] Provide an option for FileCheck to dump original input to stderr on failure
George Karpenkov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 17 11:37:52 PDT 2018
george.karpenkov updated this revision to Diff 155933.
george.karpenkov marked an inline comment as done.
https://reviews.llvm.org/D49328
Files:
llvm/utils/FileCheck/FileCheck.cpp
llvm/utils/lit/lit/TestingConfig.py
Index: llvm/utils/lit/lit/TestingConfig.py
===================================================================
--- llvm/utils/lit/lit/TestingConfig.py
+++ llvm/utils/lit/lit/TestingConfig.py
@@ -25,7 +25,8 @@
'CLANG', 'LD_PRELOAD', 'ASAN_OPTIONS', 'UBSAN_OPTIONS',
'LSAN_OPTIONS', 'ADB', 'ANDROID_SERIAL',
'SANITIZER_IGNORE_CVE_2016_2143', 'TMPDIR', 'TMP', 'TEMP',
- 'TEMPDIR', 'AVRLIT_BOARD', 'AVRLIT_PORT']
+ 'TEMPDIR', 'AVRLIT_BOARD', 'AVRLIT_PORT',
+ 'FILECHECK_DUMP_INPUT_ON_FAILURE']
for var in pass_vars:
val = os.environ.get(var, '')
# Check for empty string as some variables such as LD_PRELOAD cannot be empty
Index: llvm/utils/FileCheck/FileCheck.cpp
===================================================================
--- llvm/utils/FileCheck/FileCheck.cpp
+++ llvm/utils/FileCheck/FileCheck.cpp
@@ -90,6 +90,14 @@
"provided for convenience as old tests are migrated to the new\n"
"non-overlapping CHECK-DAG implementation.\n"));
+static const char * DumpInputEnv = "FILECHECK_DUMP_INPUT_ON_FAILURE";
+
+static cl::opt<const char*> DumpInputOnFailure(
+ "dump-input-on-failure", cl::init(std::getenv(DumpInputEnv)),
+ cl::desc("Dump original input to stderr before failing.\n"
+ "The value can be also controlled using\n"
+ "FILECHECK_DUMP_INPUT_ON_FAILURE environment variable.\n"));
+
typedef cl::list<std::string>::const_iterator prefix_iterator;
//===----------------------------------------------------------------------===//
@@ -1501,5 +1509,9 @@
InputFileText, InputFile.getBufferIdentifier()),
SMLoc());
- return CheckInput(SM, InputFileText, CheckStrings) ? EXIT_SUCCESS : 1;
+ int ExitCode = CheckInput(SM, InputFileText, CheckStrings) ? EXIT_SUCCESS : 1;
+ if (ExitCode == 1 && std::getenv(DumpInputEnv))
+ errs() << "Full input was:\n<<<<<<\n" << InputFileText << "\n>>>>>>\n";
+
+ return ExitCode;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49328.155933.patch
Type: text/x-patch
Size: 2114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180717/c961cf5e/attachment.bin>
More information about the llvm-commits
mailing list