Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ms test exception parsing #897

Merged
merged 3 commits into from
May 25, 2023
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
Type: ParseException,
Message: Expected content to contain `Directory:` or `VerifyException : Directory:` at the start. Ensure the current stable of Verify is being used.
Message: Expected content to contain `Directory:`, or `VerifyException : Directory:`, or `VerifyException: Directory:` at the start. Ensure the current stable of Verify is being used.
}
2 changes: 1 addition & 1 deletion src/Verify.ExceptionParsing.Tests/ExceptionParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public Task MsTest()
{
var exceptionMessage = $"""
Test method TheTests.XAMLCombinerTests.TestOutput threw exception:
VerifyException : Directory: {Environment.CurrentDirectory}
VerifyException: Directory: {Environment.CurrentDirectory}
NotEqual:
- Received: XAMLCombinerTests.TestOutput.received.xaml
Verified: XAMLCombinerTests.TestOutput.verified.xaml
Expand Down
12 changes: 11 additions & 1 deletion src/Verify.ExceptionParsing/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,16 @@ void ThrowIfEmpty(string directory)
return directory;
}

// MsTest
if (firstLine.StartsWith("VerifyException: Directory: "))
{
var directory = firstLine[28..];

ThrowIfEmpty(directory);

return directory;
}

if (firstLine.StartsWith("Directory: "))
{
var directory = firstLine[11..];
Expand All @@ -128,7 +138,7 @@ void ThrowIfEmpty(string directory)
return directory;
}

throw new ParseException("Expected content to contain `Directory:` or `VerifyException : Directory:` at the start.");
throw new ParseException("Expected content to contain `Directory:`, or `VerifyException : Directory:`, or `VerifyException: Directory:` at the start.");
}

static string TrimStart(string next, string prefix)
Expand Down