Skip to content

Commit

Permalink
fix path rendering in InnerVerifyChecks
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp committed Sep 9, 2024
1 parent 6fcf07c commit c4f2e28
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project>
<PropertyGroup>
<NoWarn>CS1591;CS0649;xUnit1026;xUnit1013;CS1573;VerifyTestsProjectDir;VerifySetParameters;PolyFillTargetsForNuget</NoWarn>
<Version>26.4.1</Version>
<Version>26.4.2</Version>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>preview</LangVersion>
<AssemblyVersion>1.0.0</AssemblyVersion>
Expand Down
1 change: 1 addition & 0 deletions src/Verify.sln
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
testenvironments.json = testenvironments.json
Directory.Packages.props = Directory.Packages.props
nuget.config = nuget.config
..\.gitattributes = ..\.gitattributes
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Verify", "Verify\Verify.csproj", "{A017D3FD-7DA5-4DF4-A169-72DE4AF76048}"
Expand Down
30 changes: 22 additions & 8 deletions src/Verify/InnerVerifyChecks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static async Task CheckIncorrectlyImportedSnapshots(string solutionDirectory)

builder.AppendLine(
$"""
Project: file:///{project.Replace('\\', '/')}
Project: {GetPath(project)}
Line: {line.TrimStart()}
""");
}
Expand All @@ -47,7 +47,7 @@ Found incorrectly imported verified file.
This occurs when a test file is copied in the IDE and the IDE incorrectly duplicates the dynamically imported verified file nestings.

""");
throw new(builder.ToString());
throw new CheckException(builder.ToString());
}

static async Task CheckEditorConfig(string solutionDirectory)
Expand All @@ -66,10 +66,10 @@ static async Task CheckEditorConfig(string solutionDirectory)
return;
}

throw new(
throw new CheckException(
$$"""
Expected .editorconfig to contain settings for Verify.
Path: {{path}}
Path: {{GetPath(path)}}
Recommended settings:

# Verify
Expand Down Expand Up @@ -106,10 +106,10 @@ static async Task CheckGitAttributes(string solutionDirectory)
return;
}

throw new(
throw new CheckException(
$"""
Expected .gitattributes to contain settings for Verify.
Path: {path}
Path: {GetPath(path)}
Recommended settings:

# Verify
Expand All @@ -120,6 +120,9 @@ static async Task CheckGitAttributes(string solutionDirectory)
""");
}

static string GetPath(string path) =>
$"file:///{path.Replace('\\', '/')}";

static async Task CheckGitIgnore(string solutionDirectory)
{
var path = Path.Combine(solutionDirectory, ".gitIgnore");
Expand All @@ -142,10 +145,10 @@ static async Task CheckGitIgnore(string solutionDirectory)
return;
}

throw new(
throw new CheckException(
$"""
Expected .gitIgnore to contain settings for Verify.
Path: {path}
Path: {GetPath(path)}
Recommended settings:

# Verify
Expand All @@ -167,4 +170,15 @@ static Task<string[]> ReadLines(string path) =>
#else
Task.FromResult(File.ReadAllLines(path));
#endif
class CheckException : Exception
{
public CheckException(string message) :
base(message)
{
}

public override string ToString() => Message;

public override string StackTrace => "";
}
}

0 comments on commit c4f2e28

Please sign in to comment.