<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/77257>77257</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            FileCheck should a unified diff output
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            testing-tools
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          cjdb
      </td>
    </tr>
</table>

<pre>
    I find the way in which FileCheck renders its output very confusing and difficult to read. It would be good if there was a `--diff` option that let users render their mismatches in the form of various diff outputs too. In addition to making the output more readable, this would also make it easier to show multiple mismatches in the same run.

**FileCheck default**
```
--
/tmp/example/test:52:17: error: CHECK_CMAKE: expected string not found in input
// CHECK_CMAKE: -- The C compiler identification is [[COMPILER]] {{\d+(.\d+)*}}
 ^
<stdin>:6:32: note: scanning from here
-- Running vcpkg install - done
                               ^
<stdin>:6:32: note: with "COMPILER" equal to "GNU"
-- Running vcpkg install - done
 ^
<stdin>:7:1: note: possible intended match here
-- The C compiler identification is GNU 13.2.1
^

Input file: <stdin>
Check file: /tmp/example/test

-dump-input=help explains the following input dump.

Input was:
<<<<<<
 1: -- Bootstrapping vcpkg before install 
            2: -- Bootstrapping vcpkg before install - done 
            3: -- Running vcpkg install 
 4: All requested packages are currently installed. 
 5: Total install time: 581 ns 
            6: -- Running vcpkg install - done 
check:52'0                                    X error: no match found
check:52'1                                      with "COMPILER" equal to "GNU"
            7: -- The C compiler identification is GNU 13.2.1 
check:52'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:52'2     ? possible intended match
            8: -- The CXX compiler identification is GNU 13.2.1 
check:52'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            9: -- Detecting C compiler ABI info 
check:52'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           10: -- Detecting C compiler ABI info - done 
check:52'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           11: -- Check for working C compiler: /usr/bin/gcc - skipped 
check:52'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
           12: -- Detecting C compile features 
check:52'0 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
 .
>>>>>>
```
**Unified diff**

A lot of the information that FileCheck provides should be implicitly available via the change in output structure. The failing check prefix is presented next to the filename.

```
--- /tmp/example/test (CHECK_CMAKE)
+++ <stdin>
@@ -52,2 +7,2 @@
- -- The C compiler identification is GNU {{\d+(.\d+)*}}
+ -- The C compiler identification is GNU 13.2.1
- -- The CXX compiler identification is GNU {{\d+(.\d+)*}}
+ -- The CXX compiler identification is GNU 13.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
```

Substitutions are automatically applied in the diff: perhaps there should be a `--diff=unidiff-no-substitutions` to show `[[COMPILER]]` instead of `GNU`.

**Possible interface**

```
--diff=<value> - Format how output is dumped to stderr
  =llvm - Outputs a traditional FileCheck output. `--dump-input-*` are
                                          ignored unless this mode is selected.
  =unidiff                              - Outputs a unified diff
  =unidiff-no-substitutions             - Outputs a unified diff, without substituting macros in the
 diff output
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8WEtv4zgS_jX0pSBDovw8-ODY8WwwOw_MTgN9W9BiyeKEIjUklXRf9rcvipJtJXbSTrBYgZAViaz6WC9-FeG9OhjEFZvesel2JNpQWbcq_pL70d7K76sHKJWRECqEZ_EdlIHnShUV7JTGTYXFIzg0Ep0HFTzYNjRtgCd036Gwpmy9MgcQRoJUZamKVgcIFhwKOYaHAM-21RL2CAdrJaiS9DjS5EEAm6VJQuvYLAXbBGUNhEoE0Big9aSz002rlINa-VqEokJPMAlxaV0NtoQn4ZRtfQTRY_QQrB3DgwEhpepkW6jFIwGmtf1Wausw4hV7jYxvIFTK97iF9n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