[PATCH] D20716: FileCheck: dump command line context with empty input

David Li via llvm-commits llvm-commits at lists.llvm.org
Thu May 26 18:05:03 PDT 2016


davidxl created this revision.
davidxl added a reviewer: dblaikie.
davidxl added a subscriber: llvm-commits.

FileCheck dumps minimal information when input is empty.  We have many tests that include more than one FileCheck command lines. When such an error happens, figuring out which command actually is the problem can be hard sometimes (e.g, without running environment to reproduce).

This patch enables FileCheck to dump the full command line as a context line so that it is easier to identify the problem.

http://reviews.llvm.org/D20716

Files:
  test/FileCheck/check-empty.txt
  utils/FileCheck/FileCheck.cpp

Index: utils/FileCheck/FileCheck.cpp
===================================================================
--- utils/FileCheck/FileCheck.cpp
+++ utils/FileCheck/FileCheck.cpp
@@ -1298,6 +1298,13 @@
     CheckPrefixes.push_back("CHECK");
 }
 
+static void DumpCommandLine(int argc, char **argv) {
+  errs() << "FileCheck command line: ";
+  for (int I = 0; I < argc; I++)
+    errs() << " " << argv[I];
+  errs() << "\n";
+}
+
 int main(int argc, char **argv) {
   sys::PrintStackTraceOnErrorSignal();
   PrettyStackTraceProgram X(argc, argv);
@@ -1331,6 +1338,7 @@
 
   if (File->getBufferSize() == 0 && !AllowEmptyInput) {
     errs() << "FileCheck error: '" << InputFilename << "' is empty.\n";
+    DumpCommandLine(argc, argv);
     return 2;
   }
 
Index: test/FileCheck/check-empty.txt
===================================================================
--- test/FileCheck/check-empty.txt
+++ test/FileCheck/check-empty.txt
@@ -7,5 +7,6 @@
 ; NOFOO-NOT: foo
 
 ; EMPTY-ERR: FileCheck error: '-' is empty.
+; EMPTY-ERR-NEXT: FileCheck command line: {{.*}}FileCheck -check-prefix={{.*}}FOO {{.*}}check-empty.txt
 ; NO-EMPTY-ERR-NOT: FileCheck error: '-' is empty.
 ; NOT-FOUND: error: expected string not found in input


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20716.58736.patch
Type: text/x-patch
Size: 1221 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160527/dc302878/attachment-0001.bin>


More information about the llvm-commits mailing list