Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/merge-dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
# Dependabot records the update type in its commit message metadata, for example
# "update-type: version-update:semver-minor". A grouped bump lists one per dependency.
# --match-head-commit refuses the merge if the branch moved after this build ran.
# A bump that conflicts with main (an earlier bump merged an adjacent line) is skipped:
# Dependabot rebases it, the rebase reruns Build, and that run triggers this workflow again.
# GitHub computes mergeability lazily, so UNKNOWN is retried briefly.
- name: Merge when the bump is minor or patch
env:
GH_TOKEN: ${{ github.token }}
Expand All @@ -42,4 +45,13 @@ jobs:
echo "::warning::No open pull request for $BRANCH"
exit 0
fi
for attempt in 1 2 3 4 5 6; do
mergeable=$(gh pr view "$pr" --json mergeable --jq '.mergeable')
[ "$mergeable" != "UNKNOWN" ] && break
sleep 5
done
if [ "$mergeable" = "CONFLICTING" ]; then
echo "::warning::Pull request #$pr conflicts with the base branch, leaving for Dependabot to rebase"
exit 0
fi
gh pr merge "$pr" --squash --match-head-commit "$HEAD_SHA"
2 changes: 1 addition & 1 deletion docs/comparer.md
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ Unsupported variants (16-bit, Adam7 interlacing) cause the decoder to throw. For
## Pre-packaged comparers

* [Verify.AngleSharp.Diffing](https://github.com/VerifyTests/Verify.AngleSharp.Diffing): Comparison of html files via [AngleSharp.Diffing](https://github.com/AngleSharp/AngleSharp.Diffing).
* [Verify.DiffPlex](https://github.com/VerifyTests/Verify.DiffPlex): Comparison of text via [DiffPlex](https://github.com/mmanela/diffplex).
* [Verify.DiffPlex](https://github.com/VerifyTests/Verify.DiffPlex): Comparison of text via [DiffPlex](https://github.com/mmanela/diffplex). Not required: a text diff is now shown by default. See [Text Diff Format](/docs/exception-message-format.md#text-diff-format).
* [Verify.ICSharpCode.Decompiler](https://github.com/VerifyTests/Verify.ICSharpCode.Decompiler): Comparison of assemblies and types via [ICSharpCode.Decompiler](https://github.com/icsharpcode/ILSpy/wiki/Getting-Started-With-ICSharpCode.Decompiler).
* [Verify.ImageHash](https://github.com/VerifyTests/Verify.ImageHash): Comparison of images via [ImageHash](https://github.com/coenm/ImageHash).
* [Verify.ImageMagick](https://github.com/VerifyTests/Verify.ImageMagick): Verification and comparison of images via [Magick.NET](https://github.com/dlemstra/Magick.NET).
Expand Down
90 changes: 83 additions & 7 deletions docs/exception-message-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,76 @@ The staged path lines are omitted when staging was unavailable (build server, or

After the file listing, a `FileContent:` section includes the text content of new and not-equal files. This section is only present when there are text-based new or not-equal files. Binary files are listed in the file listing but their content is not included.

A not-equal text file shows a `Diff:` of the verified text against the received text, rather than both texts in full. Lines compare exactly, whitespace and case included. When the texts differ only in something a line diff does not see, such as line endings, both texts are shown in full instead.


### Text Diff Format

The diff is produced by [DiffEngine](https://github.com/VerifyTests/DiffEngine)'s `TextDiff.Format`, in one of three formats:

* `Compact` (the default): the changed lines prefixed with `-` or `+`, each unchanged line next to a change prefixed with its received line number, and `[BOF]` or `[EOF]` where a change touches either end.
* `Full`: every line, prefixed with `-`, `+` or two spaces.
* `Minimal`: only the changed lines, prefixed with `-` or `+`.

<!-- snippet: VerifyExceptionMessageBuilderTests.NotEqual_TextDiffCompact.verified.txt -->
<a id='snippet-VerifyExceptionMessageBuilderTests.NotEqual_TextDiffCompact.verified.txt'></a>
```txt
Directory: {ProjectDirectory}
NotEqual:
- Received: VerifyExceptionMessageBuilderTests.Fake.received.txt
Verified: VerifyExceptionMessageBuilderTests.Fake.verified.txt

FileContent:

NotEqual:

Received: VerifyExceptionMessageBuilderTests.Fake.received.txt
Verified: VerifyExceptionMessageBuilderTests.Fake.verified.txt
Diff:
2 line 2
- line 3
+ line three
4 line 4

7 line 7
+ line 8
[EOF]
```
<sup><a href='/src/Verify.ExceptionParsing.Tests/VerifyExceptionMessageBuilderTests.NotEqual_TextDiffCompact.verified.txt#L1-L21' title='Snippet source file'>snippet source</a> | <a href='#snippet-VerifyExceptionMessageBuilderTests.NotEqual_TextDiffCompact.verified.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

The format is set globally:

<!-- snippet: UseTextDiffFormat -->
<a id='snippet-UseTextDiffFormat'></a>
```cs
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Init() =>
VerifierSettings.UseTextDiffFormat(DiffEngine.TextDiffFormat.Full);
}
```
<sup><a href='/src/ModuleInitDocs/UseTextDiffFormat.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-UseTextDiffFormat' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

To show both texts in full, as before diffs were shown, disable the diff:

<!-- snippet: DisableTextDiff -->
<a id='snippet-DisableTextDiff'></a>
```cs
public static class ModuleInitializer
{
[ModuleInitializer]
public static void Init() =>
VerifierSettings.DisableTextDiff();
}
```
<sup><a href='/src/ModuleInitDocs/DisableTextDiff.cs#L3-L12' title='Snippet source file'>snippet source</a> | <a href='#snippet-DisableTextDiff' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->

This only changes the exception message. Launching a diff tool is controlled separately, by [DisableDiff](/docs/verify-options.md#disablediff).


## Example: All Categories

Expand Down Expand Up @@ -80,11 +150,14 @@ the new content
NotEqual:

Received: MyTests.Test2.received.txt
received text
Verified: MyTests.Test2.verified.txt
verified text
Diff:
[BOF]
- verified text
+ received text
[EOF]
```
<sup><a href='/src/Verify.ExceptionParsing.Tests/ExceptionMessageFormatSamples.AllCategories.verified.txt#L1-L27' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExceptionMessageFormatSamples.AllCategories.verified.txt' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.ExceptionParsing.Tests/ExceptionMessageFormatSamples.AllCategories.verified.txt#L1-L30' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExceptionMessageFormatSamples.AllCategories.verified.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


Expand Down Expand Up @@ -163,17 +236,20 @@ inline expected
NotEqual:

Received: MyTests.Test1#01.received.txt
received text
Verified: MyTests.Test1#01.verified.txt
verified text
Diff:
[BOF]
- verified text
+ received text
[EOF]
```
<sup><a href='/src/Verify.ExceptionParsing.Tests/ExceptionMessageFormatSamples.InlineAndFileTogether.verified.txt#L1-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExceptionMessageFormatSamples.InlineAndFileTogether.verified.txt' title='Start of snippet'>anchor</a></sup>
<sup><a href='/src/Verify.ExceptionParsing.Tests/ExceptionMessageFormatSamples.InlineAndFileTogether.verified.txt#L1-L29' title='Snippet source file'>snippet source</a> | <a href='#snippet-ExceptionMessageFormatSamples.InlineAndFileTogether.verified.txt' title='Start of snippet'>anchor</a></sup>
<!-- endSnippet -->


### NotEqual with Comparer Message

When a custom comparer provides a message, the content section uses `Compare Result:` instead of inline file content:
When a custom comparer provides a message, the content section uses `Compare Result:` instead of a diff or the file content:

<!-- snippet: ExceptionMessageFormatSamples.NotEqualWithMessage.verified.txt -->
<a id='snippet-ExceptionMessageFormatSamples.NotEqualWithMessage.verified.txt'></a>
Expand Down
2 changes: 1 addition & 1 deletion docs/mdsource/comparer.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Unsupported variants (16-bit, Adam7 interlacing) cause the decoder to throw. For
## Pre-packaged comparers

* [Verify.AngleSharp.Diffing](https://github.com/VerifyTests/Verify.AngleSharp.Diffing): Comparison of html files via [AngleSharp.Diffing](https://github.com/AngleSharp/AngleSharp.Diffing).
* [Verify.DiffPlex](https://github.com/VerifyTests/Verify.DiffPlex): Comparison of text via [DiffPlex](https://github.com/mmanela/diffplex).
* [Verify.DiffPlex](https://github.com/VerifyTests/Verify.DiffPlex): Comparison of text via [DiffPlex](https://github.com/mmanela/diffplex). Not required: a text diff is now shown by default. See [Text Diff Format](/docs/exception-message-format.md#text-diff-format).
* [Verify.ICSharpCode.Decompiler](https://github.com/VerifyTests/Verify.ICSharpCode.Decompiler): Comparison of assemblies and types via [ICSharpCode.Decompiler](https://github.com/icsharpcode/ILSpy/wiki/Getting-Started-With-ICSharpCode.Decompiler).
* [Verify.ImageHash](https://github.com/VerifyTests/Verify.ImageHash): Comparison of images via [ImageHash](https://github.com/coenm/ImageHash).
* [Verify.ImageMagick](https://github.com/VerifyTests/Verify.ImageMagick): Verification and comparison of images via [Magick.NET](https://github.com/dlemstra/Magick.NET).
Expand Down
25 changes: 24 additions & 1 deletion docs/mdsource/exception-message-format.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@ The staged path lines are omitted when staging was unavailable (build server, or

After the file listing, a `FileContent:` section includes the text content of new and not-equal files. This section is only present when there are text-based new or not-equal files. Binary files are listed in the file listing but their content is not included.

A not-equal text file shows a `Diff:` of the verified text against the received text, rather than both texts in full. Lines compare exactly, whitespace and case included. When the texts differ only in something a line diff does not see, such as line endings, both texts are shown in full instead.


### Text Diff Format

The diff is produced by [DiffEngine](https://github.com/VerifyTests/DiffEngine)'s `TextDiff.Format`, in one of three formats:

* `Compact` (the default): the changed lines prefixed with `-` or `+`, each unchanged line next to a change prefixed with its received line number, and `[BOF]` or `[EOF]` where a change touches either end.
* `Full`: every line, prefixed with `-`, `+` or two spaces.
* `Minimal`: only the changed lines, prefixed with `-` or `+`.

snippet: VerifyExceptionMessageBuilderTests.NotEqual_TextDiffCompact.verified.txt

The format is set globally:

snippet: UseTextDiffFormat

To show both texts in full, as before diffs were shown, disable the diff:

snippet: DisableTextDiff

This only changes the exception message. Launching a diff tool is controlled separately, by [DisableDiff](/docs/verify-options.md#disablediff).


## Example: All Categories

Expand All @@ -63,7 +86,7 @@ snippet: ExceptionMessageFormatSamples.InlineAndFileTogether.verified.txt

### NotEqual with Comparer Message

When a custom comparer provides a message, the content section uses `Compare Result:` instead of inline file content:
When a custom comparer provides a message, the content section uses `Compare Result:` instead of a diff or the file content:

snippet: ExceptionMessageFormatSamples.NotEqualWithMessage.verified.txt

Expand Down
2 changes: 1 addition & 1 deletion docs/mdsource/verify-options.source.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ snippet: OnFluentHandlers

## OmitContentFromException

By default, when a verify mismatch occurs for text, the content of the received and verified files is included in the exception that is thrown. This results in that text being included in test runners and build output. To omit the content use `VerifierSettings.OmitContentFromException`.
By default, when a verify mismatch occurs for text, a diff of the received and verified files is included in the exception that is thrown. This results in that text being included in test runners and build output. To omit the content use `VerifierSettings.OmitContentFromException`. To change the diff format, or show both files in full, see [Text Diff Format](/docs/exception-message-format.md#text-diff-format).


## DisableDiff
Expand Down
2 changes: 1 addition & 1 deletion docs/verify-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public Task OnFluentCallbacks() =>

## OmitContentFromException

By default, when a verify mismatch occurs for text, the content of the received and verified files is included in the exception that is thrown. This results in that text being included in test runners and build output. To omit the content use `VerifierSettings.OmitContentFromException`.
By default, when a verify mismatch occurs for text, a diff of the received and verified files is included in the exception that is thrown. This results in that text being included in test runners and build output. To omit the content use `VerifierSettings.OmitContentFromException`. To change the diff format, or show both files in full, see [Text Diff Format](/docs/exception-message-format.md#text-diff-format).


## DisableDiff
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackageVersion Include="Argon" Version="0.37.0" />
<PackageVersion Include="Argon.FSharp" Version="0.37.0" />
<PackageVersion Include="BenchmarkDotNet" Version="0.15.8" />
<PackageVersion Include="DiffEngine" Version="20.5.2" />
<PackageVersion Include="DiffEngine" Version="20.6.0" />
<PackageVersion Include="Expecto" Version="11.1.0" />
<PackageVersion Include="Fixie" Version="4.2.0" />
<PackageVersion Include="Fixie.TestAdapter" Version="4.2.0" />
Expand Down
13 changes: 13 additions & 0 deletions src/ModuleInitDocs/DisableTextDiff.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class DisableTextDiff
{
#region DisableTextDiff

public static class ModuleInitializer
{
[ModuleInitializer]
public static void Init() =>
VerifierSettings.DisableTextDiff();
}

#endregion
}
13 changes: 13 additions & 0 deletions src/ModuleInitDocs/UseTextDiffFormat.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
public class UseTextDiffFormat
{
#region UseTextDiffFormat

public static class ModuleInitializer
{
[ModuleInitializer]
public static void Init() =>
VerifierSettings.UseTextDiffFormat(DiffEngine.TextDiffFormat.Full);
}

#endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ the new content
NotEqual:

Received: MyTests.Test2.received.txt
received text
Verified: MyTests.Test2.verified.txt
verified text
Diff:
[BOF]
- verified text
+ received text
[EOF]

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ inline expected
NotEqual:

Received: MyTests.Test1#01.received.txt
received text
Verified: MyTests.Test1#01.verified.txt
verified text
Diff:
[BOF]
- verified text
+ received text
[EOF]

Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@ the content
NotEqual:

Received: ExceptionParsingTests.Fake.received.txt
receivedText
Verified: ExceptionParsingTests.Fake.verified.txt
verifiedText
Diff:
[BOF]
- verifiedText
+ receivedText
[EOF]

,
result: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@ the content
NotEqual:

Received: ExceptionParsingTests.Fake.received.txt
receivedText
Verified: ExceptionParsingTests.Fake.verified.txt
verifiedText
Diff:
[BOF]
- verifiedText
+ receivedText
[EOF]

,
result: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ FileContent:
NotEqual:

Received: ExceptionParsingTests.Fake.received.txt
receivedText
Verified: ExceptionParsingTests.Fake.verified.txt
verifiedText
Diff:
[BOF]
- verifiedText
+ receivedText
[EOF]

,
result: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ new content
NotEqual:

Received: VerifyExceptionMessageBuilderTests.Fake.received.txt
received
Verified: VerifyExceptionMessageBuilderTests.Fake.verified.txt
verified
Diff:
[BOF]
- verified
+ received
[EOF]

Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ FileContent:
NotEqual:

Received: VerifyExceptionMessageBuilderTests.Fake.received.txt
received text
Verified: VerifyExceptionMessageBuilderTests.Fake.verified.txt
verified text
Diff:
[BOF]
- verified text
+ received text
[EOF]

Received: VerifyExceptionMessageBuilderTests.Fake.received.txt
Verified: VerifyExceptionMessageBuilderTests.Fake.verified.txt
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Directory: {ProjectDirectory}
NotEqual:
- Received: VerifyExceptionMessageBuilderTests.Fake.received.txt
Verified: VerifyExceptionMessageBuilderTests.Fake.verified.txt

FileContent:

NotEqual:

Received: VerifyExceptionMessageBuilderTests.Fake.received.txt
Verified: VerifyExceptionMessageBuilderTests.Fake.verified.txt
Diff:
2 line 2
- line 3
+ line three
4 line 4

7 line 7
+ line 8
[EOF]

Loading
Loading