Skip to content

Commit

Permalink
Filter empty lines when comparing stack traces in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
iNinja committed Nov 14, 2024
1 parent 2a91435 commit 3b5a830
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions test/Microsoft.IdentityModel.TestUtils/IdentityComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1476,11 +1476,11 @@ internal static bool AreValidationErrorsEqual(ValidationError validationError1,
else
{
// If the stack trace is present, ensure it contains the expected amount of frames.
var stackTraceFrames = exception1.StackTrace.Trim('\n').Split('\n');
if (stackTraceFrames.Length != validationError2.StackFrames.Count)
var stackTraceFrames = exception1.StackTrace.Trim('\n').Split('\n').Where(s => !s.IsNullOrEmpty());
if (stackTraceFrames.Count() != validationError2.StackFrames.Count)
{
localContext.Diffs.Add($"(exception1.StackTrace.Trim('\\n\').Split('\\n').Length != validationError2.StackFrames.Count: " +
$"{stackTraceFrames.Length}, {validationError2.StackFrames.Count})");
localContext.Diffs.Add($"(exception1.StackTrace.Trim('\\n\').Split('\\n').Count() != validationError2.StackFrames.Count: " +
$"{stackTraceFrames.Count()}, {validationError2.StackFrames.Count})");
localContext.Diffs.Add($"exception1.StackTrace: {exception1.StackTrace}");
}
}
Expand Down

0 comments on commit 3b5a830

Please sign in to comment.