[PATCH] D52999: [FileCheck] Annotate input dump

Joel E. Denny via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 8 14:25:34 PDT 2018


jdenny created this revision.
jdenny added reviewers: probinson, george.karpenkov, hfinkel.
Herald added subscribers: kristina, mgrang, delcypher, hiraditya.

Extend FileCheck to annotate its input dump to indicate pattern
failures, good matches if -v, and additional information if -vv.  For
example:

  $ cat input | FileCheck -v -dump-input=always checks |& tail -7
  <<<<<<
         1: abc def
  chk:1     ^~~
  sam:2         ^~~
         2: ghI jkl
  nxt:3     X~~~~~~
  >>>>>>
  
  $ cat checks
  CHECK: abc
  CHECK-SAME: def
  CHECK-NEXT: ghi
  CHECK-SAME: jkl
  
  $ cat input
  abc def
  ghI jkl

Some parts of the output are hard to show in a commit log, so I've
elided them above:

1. Colored Annotations: The last part of the output is the annotated input, as in the above example, except that it is colored if colors are supported.  For example, errors are red.  This patch also makes it so that -color, which was already accepted by FileCheck, forces colors for these annotations so that you can pipe FileCheck output through less -R.  We should probably fix -color for normal diagnostics as well.

2. Annotation Key: Before the annotated input, a key is printed to explain the annotations.  It becomes more verbose as kinds of annotations are added by -v, -vv, or colors.

3. Diagnostics: The usual diagnostics are not suppressed in this mode and are printed first.  Sometimes they're perfectly sufficient, and then they make debugging quicker than if you were forced to hunt through a dump of long input looking for the error.  If you think they'll get in the way sometimes, keep in mind that it's pretty easy to grep for the start of the input dump, which is "<<<".

This patch also renames -dump-input-on-failure to -dump-input and
FILECHECK_DUMP_INPUT_ON_FAILURE to FILECHECK_DUMP_INPUT, and it
changes accepted values to 'always', 'fail', or 'never'.  The previous
functionality only permitted the 'fail' and 'never' functionality, but
sometimes you want to investigate a successful FileCheck run, perhaps
for an unexpected pass.

I'd be happy to separate out patches for the changes to -dump-input
and -color if that's helpful.

I don't know how to test color in the output, so any hints here would
be appreciated.


Repository:
  rL LLVM

https://reviews.llvm.org/D52999

Files:
  llvm/docs/CommandGuide/FileCheck.rst
  llvm/include/llvm/Support/FileCheck.h
  llvm/include/llvm/Support/WithColor.h
  llvm/lib/Support/FileCheck.cpp
  llvm/test/FileCheck/dump-input-annotations.txt
  llvm/test/FileCheck/dump-input-enable.txt
  llvm/test/FileCheck/match-full-lines.txt
  llvm/test/FileCheck/verbose_mode.txt
  llvm/utils/FileCheck/FileCheck.cpp
  llvm/utils/lit/lit/TestingConfig.py

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52999.168707.patch
Type: text/x-patch
Size: 64180 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181008/17067503/attachment-0001.bin>


More information about the llvm-commits mailing list