Skip to content

Commit

Permalink
Fix MsTest exception message parsing (#848)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonCropp authored Apr 15, 2023
1 parent 3d84865 commit f66e8bd
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
NotEqual: [
{
Received: {CurrentDirectory}XAMLCombinerTests.TestOutput.received.xaml,
Verified: {CurrentDirectory}XAMLCombinerTests.TestOutput.verified.xaml
}
]
}
33 changes: 33 additions & 0 deletions src/Verify.ExceptionParsing.Tests/ExceptionParsingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,39 @@ public Task Nunit()
return Verify(result);
}

[Fact]
public Task MsTest()
{
var exceptionMessage = $"""
Test method TheTests.XAMLCombinerTests.TestOutput threw exception:
VerifyException : Directory: {Environment.CurrentDirectory}
NotEqual:
- Received: XAMLCombinerTests.TestOutput.received.xaml
Verified: XAMLCombinerTests.TestOutput.verified.xaml
FileContent:
NotEqual:
Received: XAMLCombinerTests.TestOutput.received.xaml
<?xml version="1.0" encoding="utf-8"?>
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:sys_0="clr-namespace:System;assembly=System.Runtime">
<Style x:Key="Control1" />
<Color x:Key="Control1_Color">#FF2B579A</Color>
<sys:String x:Key="string1">stringValue</sys:String>
<Style x:Key="Control2" />
<Color x:Key="Control2_Color">#FF2B579A</Color>
<sys:String x:Key="string2">stringValue</sys:String>
<sys_0:String x:Key="string3">stringValue</sys_0:String>
<Style TargetType="Block" />
</ResourceDictionary>
Verified: XAMLCombinerTests.TestOutput.verified.xaml
""";

var result = Parser.Parse(exceptionMessage);
return Verify(result);
}

[Fact]
public Task SingleNotEqual()
{
Expand Down
11 changes: 11 additions & 0 deletions src/Verify.ExceptionParsing/Parser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ static Result InnerParse(IEnumerable<string> lines)
}

var firstLine = enumerator.Current!;
//MsTest exception start with "Test method..." so lets swallow them
if (firstLine.StartsWith("Test method"))
{
if (!enumerator.MoveNext())
{
throw new ParseException("No content");
}

firstLine = enumerator.Current!;
}

var directory = GetDirectory(firstLine);

while (enumerator.MoveNext())
Expand Down

0 comments on commit f66e8bd

Please sign in to comment.