Index: llvm/docs/CommandGuide/FileCheck.rst =================================================================== --- llvm/docs/CommandGuide/FileCheck.rst +++ llvm/docs/CommandGuide/FileCheck.rst @@ -111,13 +111,16 @@ .. option:: -v - Print directive pattern matches. + Print good directive pattern matches. However, if ``-input-dump=fail`` or + ``-input-dump=always``, add those matches as input annotations instead. .. option:: -vv Print information helpful in diagnosing internal FileCheck issues, such as discarded overlapping ``CHECK-DAG:`` matches, implicit EOF pattern matches, and ``CHECK-NOT:`` patterns that do not have matches. Implies ``-v``. + However, if ``-input-dump=fail`` or ``-input-dump=always``, just add that + information as input annotations instead. .. option:: --allow-deprecated-dag-overlap Index: llvm/lib/Support/FileCheck.cpp =================================================================== --- llvm/lib/Support/FileCheck.cpp +++ llvm/lib/Support/FileCheck.cpp @@ -901,16 +901,24 @@ StringMap &VariableTable, size_t MatchPos, size_t MatchLen, const FileCheckRequest &Req, std::vector *Diags) { + bool PrintDiag = true; if (ExpectedMatch) { if (!Req.Verbose) return; if (!Req.VerboseVerbose && Pat.getCheckTy() == Check::CheckEOF) return; + // Due to their verbosity, we don't print verbose diagnostics here if we're + // gathering them for a different rendering, but we always print other + // diagnostics. + PrintDiag = !Diags; } SMRange MatchRange = ProcessMatchResult( ExpectedMatch ? FileCheckDiag::MatchFoundAndExpected : FileCheckDiag::MatchFoundButExcluded, SM, Loc, Pat.getCheckTy(), Buffer, MatchPos, MatchLen, Diags); + if (!PrintDiag) + return; + std::string Message = formatv("{0}: {1} string found in input", Pat.getCheckTy().getDescription(Prefix), (ExpectedMatch ? "expected" : "excluded")) @@ -941,27 +949,37 @@ StringRef Buffer, StringMap &VariableTable, bool VerboseVerbose, std::vector *Diags) { - if (!ExpectedMatch && !VerboseVerbose) + bool PrintDiag = true; + if (!ExpectedMatch) { + if (!VerboseVerbose) + return; + // Due to their verbosity, we don't print verbose diagnostics here if we're + // gathering them for a different rendering, but we always print other + // diagnostics. + PrintDiag = !Diags; + } + + // If the current position is at the end of a line, advance to the start of + // the next line. + Buffer = Buffer.substr(Buffer.find_first_not_of(" \t\n\r")); + SMRange SearchRange = ProcessMatchResult( + ExpectedMatch ? FileCheckDiag::MatchNoneButExpected + : FileCheckDiag::MatchNoneAndExcluded, + SM, Loc, Pat.getCheckTy(), Buffer, 0, Buffer.size(), Diags); + if (!PrintDiag) return; - // Otherwise, we have an error, emit an error message. + // Print "not found" diagnostic. std::string Message = formatv("{0}: {1} string not found in input", Pat.getCheckTy().getDescription(Prefix), (ExpectedMatch ? "expected" : "excluded")) .str(); if (Pat.getCount() > 1) Message += formatv(" ({0} out of {1})", MatchedCount, Pat.getCount()).str(); - SM.PrintMessage( Loc, ExpectedMatch ? SourceMgr::DK_Error : SourceMgr::DK_Remark, Message); - // Print the "scanning from here" line. If the current position is at the - // end of a line, advance to the start of the next line. - Buffer = Buffer.substr(Buffer.find_first_not_of(" \t\n\r")); - SMRange SearchRange = ProcessMatchResult( - ExpectedMatch ? FileCheckDiag::MatchNoneButExpected - : FileCheckDiag::MatchNoneAndExcluded, - SM, Loc, Pat.getCheckTy(), Buffer, 0, Buffer.size(), Diags); + // Print the "scanning from here" line. SM.PrintMessage(SearchRange.Start, SourceMgr::DK_Note, "scanning from here"); // Allow the pattern to print additional information if desired. @@ -1276,13 +1294,17 @@ break; } if (Req.VerboseVerbose) { - SMLoc OldStart = SMLoc::getFromPointer(Buffer.data() + MI->Pos); - SMLoc OldEnd = SMLoc::getFromPointer(Buffer.data() + MI->End); - SMRange OldRange(OldStart, OldEnd); - SM.PrintMessage(OldStart, SourceMgr::DK_Note, - "match discarded, overlaps earlier DAG match here", - {OldRange}); - if (Diags) + // Due to their verbosity, we don't print verbose diagnostics here if + // we're gathering them for a different rendering, but we always print + // other diagnostics. + if (!Diags) { + SMLoc OldStart = SMLoc::getFromPointer(Buffer.data() + MI->Pos); + SMLoc OldEnd = SMLoc::getFromPointer(Buffer.data() + MI->End); + SMRange OldRange(OldStart, OldEnd); + SM.PrintMessage(OldStart, SourceMgr::DK_Note, + "match discarded, overlaps earlier DAG match here", + {OldRange}); + } else Diags->rbegin()->MatchTy = FileCheckDiag::MatchFoundButDiscarded; } MatchPos = MI->End; Index: llvm/test/FileCheck/dump-input-annotations.txt =================================================================== --- llvm/test/FileCheck/dump-input-annotations.txt +++ llvm/test/FileCheck/dump-input-annotations.txt @@ -16,7 +16,12 @@ ; RUN: echo 'CHECK: universe' >> %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -strict-whitespace -match-full-lines -check-prefix=ALIGN %s +; RUN: | FileCheck -strict-whitespace -match-full-lines -check-prefix=ALIGN \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' %s + +; Verbose diagnostics are suppressed but not errors. +; ALIGN:{{.*}}error:{{.*}} +; ALIGN:{{.*}}possible intended match here{{.*}} ; ALIGN:Full input was: ; ALIGN-NEXT:<<<<<< @@ -47,11 +52,18 @@ ; RUN: echo 'CHECK: world' >> %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefix=CHK +; RUN: | FileCheck -match-full-lines %s -check-prefix=CHK \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=CHK,CHK-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; CHK: {{.*}}error:{{.*}} +; CHK: {{.*}}possible intended match here{{.*}} ; CHK: <<<<<< ; CHK-NEXT: 1: hello @@ -77,11 +89,17 @@ ; RUN: echo 'CHECK-COUNT-3: pete' > %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-Q +; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-Q \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=CNT,CNT-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; CNT: {{.*}}error:{{.*}} ; CNT: <<<<<< ; CNT-NEXT: 1: pete @@ -108,11 +126,17 @@ ; RUN: echo 'CHECK-NEXT: world' >> %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefix=NXT +; RUN: | FileCheck -match-full-lines %s -check-prefix=NXT \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V,NXT-VV +; RUN: | FileCheck -match-full-lines %s -check-prefixes=NXT,NXT-V,NXT-VV \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; NXT: {{.*}}error:{{.*}} ; NXT: <<<<<< ; NXT-NEXT: 1: hello @@ -155,11 +179,17 @@ ; RUN: echo 'CHECK-SAME: again' >> %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefix=SAM +; RUN: | FileCheck -match-full-lines %s -check-prefix=SAM \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V,SAM-VV +; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM,SAM-V,SAM-VV \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; SAM: {{.*}}error:{{.*}} ; SAM: <<<<<< ; SAM-NEXT: 1: hello world! @@ -174,7 +204,11 @@ ; RUN: echo 'again' >> %t.in ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM2 +; RUN: | FileCheck -match-full-lines %s -check-prefixes=SAM2 \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; SAM2: {{.*}}error:{{.*}} ; SAM2: <<<<<< ; SAM2-NEXT: 1: hello world! @@ -208,11 +242,17 @@ ; RUN: echo 'CHECK-LABEL: label' >> %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP +; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V,EMP-VV +; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP,EMP-V,EMP-VV \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; EMP: {{.*}}error:{{.*}} ; EMP: <<<<<< ; EMP-NEXT: 1: hello @@ -236,11 +276,17 @@ ; RUN: echo 'CHECK-EMPTY:' >> %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP2 +; RUN: | FileCheck -match-full-lines %s -check-prefix=EMP2 \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V,EMP2-VV +; RUN: | FileCheck -match-full-lines %s -check-prefixes=EMP2,EMP2-V,EMP2-VV \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; EMP2: {{.*}}error:{{.*}} ; EMP2: <<<<<< ; EMP2-NEXT: 1: hello @@ -265,11 +311,17 @@ ; RUN: echo 'CHECK-NOT: world' >> %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT +; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V,NOT-VV +; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT,NOT-V,NOT-VV \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; NOT: {{.*}}error:{{.*}} ; NOT: <<<<<< ; NOT-NEXT: 1: hello @@ -289,11 +341,17 @@ ; RUN: echo 'CHECK: ain' >> %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT2 +; RUN: | FileCheck -match-full-lines %s -check-prefix=NOT2 \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V,NOT2-VV +; RUN: | FileCheck -match-full-lines %s -check-prefixes=NOT2,NOT2-V,NOT2-VV \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; NOT2: {{.*}}error:{{.*}} ; NOT2: <<<<<< ; NOT2-NEXT: 1: hello @@ -330,11 +388,17 @@ ; DAG-VV = -vv ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-Q +; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-Q \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VQ +; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VQ \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VV +; RUN: | FileCheck -match-full-lines %s -check-prefixes=DAG,DAG-V,DAG-VV \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; DAG: {{.*}}error:{{.*}} ; DAG: <<<<<< ; DAG-NEXT: 1: abc @@ -371,11 +435,18 @@ ; RUN: echo 'CHECK-LABEL: lab2' >> %t.chk ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB +; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -v 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V +; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' ; RUN: not FileCheck -dump-input=always -input-file %t.in %t.chk -vv 2>&1 \ -; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V,LAB-VV +; RUN: | FileCheck -match-full-lines %s -check-prefixes=LAB,LAB-V,LAB-VV \ +; RUN: -implicit-check-not='{{.*}}remark:{{.*}}' + +; Verbose diagnostics are suppressed but not errors. +; LAB: {{.*}}error:{{.*}} +; LAB: {{.*}}possible intended match{{.*}} ; LAB: <<<<<< ; LAB-NEXT: 1: lab0 @@ -390,5 +461,3 @@ ; LAB-NEXT: label:3'0 ~~~ error: no match found ; LAB-NEXT: >>>>>> ; LAB-NOT: {{.}} - - Index: llvm/test/FileCheck/dump-input-enable.txt =================================================================== --- llvm/test/FileCheck/dump-input-enable.txt +++ llvm/test/FileCheck/dump-input-enable.txt @@ -1,14 +1,21 @@ -; RUN: echo ciao > %t.good +;-------------------------------------------------- +; Create the check file, good input, and bad input. +; +; For both good and bad input, make sure the -v trace has at least one remark +; so we can check how trace suppression is affected by -dump-input. +;-------------------------------------------------- + +; RUN: echo hello > %t.good ; RUN: echo world >> %t.good ; RUN: echo hello > %t.err -; RUN: echo world >> %t.err +; RUN: echo whirled >> %t.err -; RUN: echo 'CHECK: ciao' > %t.check +; RUN: echo 'CHECK: hello' > %t.check ; RUN: echo 'CHECK-NEXT: world' >> %t.check ;-------------------------------------------------- -; unknown value +; Check -dump-input=. ;-------------------------------------------------- ; RUN: not FileCheck -input-file %t.good %t.check -check-prefix=CHECK \ @@ -22,7 +29,7 @@ BADVAL: FileCheck{{.*}}: for the -dump-input option: Cannot find option named 'foobar'! ;-------------------------------------------------- -; help +; Check -dump-input=help. ;-------------------------------------------------- ; Appended to normal command line. @@ -38,91 +45,131 @@ HELP-NOT: {{.}} ;-------------------------------------------------- -; never +; Check -dump-input=never. +; +; Include the case without -v, which isn't covered elsewhere. ;-------------------------------------------------- ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \ ; RUN: -match-full-lines -dump-input=never 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty +; RUN: | FileCheck %s -match-full-lines -allow-empty \ +; RUN: -check-prefixes=NOTRACE,NODUMP ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \ ; RUN: -match-full-lines -dump-input=never 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP +; RUN: | FileCheck %s -match-full-lines -check-prefixes=NOTRACE,ERR,NODUMP + +; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \ +; RUN: -match-full-lines -dump-input=never -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,NODUMP + +; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \ +; RUN: -match-full-lines -dump-input=never -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,ERR,NODUMP ;-------------------------------------------------- -; default: never +; Check no -dump-input, which defaults to never. ;-------------------------------------------------- ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \ -; RUN: -match-full-lines 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty +; RUN: -match-full-lines -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,NODUMP ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \ -; RUN: -match-full-lines 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP +; RUN: -match-full-lines -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines -check-prefixes=TRACE,ERR,NODUMP ;-------------------------------------------------- -; fail +; Check -dump-input=fail. +; +; Include the case without -v, which isn't covered elsewhere. ;-------------------------------------------------- ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \ ; RUN: -match-full-lines -dump-input=fail 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty +; RUN: | FileCheck %s -match-full-lines -allow-empty \ +; RUN: -check-prefixes=NOTRACE,NODUMP ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \ ; RUN: -match-full-lines -dump-input=fail 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR +; RUN: | FileCheck %s -match-full-lines -check-prefixes=NOTRACE,ERR,DUMP-ERR + +; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \ +; RUN: -match-full-lines -dump-input=fail -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines -allow-empty \ +; RUN: -check-prefixes=NOTRACE,NODUMP + +; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \ +; RUN: -match-full-lines -dump-input=fail -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines \ +; RUN: -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V ;-------------------------------------------------- -; -dump-input-on-failure +; Check -dump-input-on-failure. ;-------------------------------------------------- ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \ -; RUN: -match-full-lines -dump-input-on-failure 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty +; RUN: -match-full-lines -dump-input-on-failure -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines -allow-empty \ +; RUN: -check-prefixes=NOTRACE,NODUMP ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \ -; RUN: -match-full-lines -dump-input-on-failure 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR +; RUN: -match-full-lines -dump-input-on-failure -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines \ +; RUN: -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V ; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 \ ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \ -; RUN: -match-full-lines 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-NODUMP -allow-empty +; RUN: -match-full-lines -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines -allow-empty \ +; RUN: -check-prefixes=NOTRACE,NODUMP ; RUN: env FILECHECK_DUMP_INPUT_ON_FAILURE=1 \ ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \ -; RUN: -match-full-lines 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR +; RUN: -match-full-lines -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines \ +; RUN: -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V ;-------------------------------------------------- -; always +; Check -dump-input=always. ;-------------------------------------------------- ; RUN: FileCheck -input-file %t.good %t.check -check-prefix=CHECK \ ; RUN: -match-full-lines -dump-input=always -v 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-GOOD +; RUN: | FileCheck %s -match-full-lines -check-prefixes=NOTRACE,DUMP-OK ; RUN: not FileCheck -input-file %t.err %t.check -check-prefix=CHECK \ -; RUN: -match-full-lines -dump-input=always 2>&1 \ -; RUN: | FileCheck %s -match-full-lines -check-prefix=CHECK-ERR +; RUN: -match-full-lines -dump-input=always -v 2>&1 \ +; RUN: | FileCheck %s -match-full-lines \ +; RUN: -check-prefixes=NOTRACE,ERR,DUMP-ERR,DUMP-ERR-V ; END. -; CHECK-GOOD: Full input was: -; CHECK-GOOD-NEXT: <<<<<< -; CHECK-GOOD-NEXT: 1: ciao -; CHECK-GOOD-NEXT: check:1 ^~~~ -; CHECK-GOOD-NEXT: 2: world -; CHECK-GOOD-NEXT: next:2 ^~~~~ -; CHECK-GOOD-NEXT: >>>>>> - -; CHECK-ERR: Full input was: -; CHECK-ERR-NEXT: <<<<<< -; CHECK-ERR-NEXT: 1: hello -; CHECK-ERR-NEXT: check:1 X~~~~ -; CHECK-ERR-NEXT: 2: world -; CHECK-ERR-NEXT: check:1 ~~~~~ error: no match found -; CHECK-ERR-NEXT: >>>>>> - -; CHECK-NODUMP-NOT: <<<<<< +;-------------------------------------------------- +; Check the output for all cases that actually process directives. +;-------------------------------------------------- + +; Trace is sometimes suppressed. +; TRACE: {{.*}}remark:{{.*}} +; NOTRACE-NOT: {{.*}}remark:{{.*}} + +; Error diagnostics are never suppressed. +; ERR: {{.*}}error:{{.*}} + +; NODUMP-NOT: <<<<<< + +; DUMP-OK: Full input was: +; DUMP-OK-NEXT: <<<<<< +; DUMP-OK-NEXT: 1: hello +; DUMP-OK-NEXT: check:1 ^~~~~ +; DUMP-OK-NEXT: 2: world +; DUMP-OK-NEXT: next:2 ^~~~~ +; DUMP-OK-NEXT: >>>>>> + +; DUMP-ERR: Full input was: +; DUMP-ERR-NEXT: <<<<<< +; DUMP-ERR-NEXT: 1: hello +; DUMP-ERR-V-NEXT: check:1 ^~~~~ +; DUMP-ERR-NEXT: 2: whirled +; DUMP-ERR-NEXT: next:2 X~~~~~~ error: no match found +; DUMP-ERR-NEXT: >>>>>> Index: llvm/utils/FileCheck/FileCheck.cpp =================================================================== --- llvm/utils/FileCheck/FileCheck.cpp +++ llvm/utils/FileCheck/FileCheck.cpp @@ -79,13 +79,16 @@ "provided for convenience as old tests are migrated to the new\n" "non-overlapping CHECK-DAG implementation.\n")); -static cl::opt Verbose("v", cl::init(false), - cl::desc("Print directive pattern matches.\n")); +static cl::opt Verbose( + "v", cl::init(false), + cl::desc("Print directive pattern matches, or add them to the input dump\n" + "if enabled.\n")); static cl::opt VerboseVerbose( "vv", cl::init(false), cl::desc("Print information helpful in diagnosing internal FileCheck\n" - "issues. Implies -v.\n")); + "issues, or add it to the input dump if enabled. Implies\n" + "-v.\n")); static const char * DumpInputEnv = "FILECHECK_DUMP_INPUT_ON_FAILURE"; static cl::opt DumpInputOnFailure(