Skip to content

Commit

Permalink
Add more logging on missing node type
Browse files Browse the repository at this point in the history
  • Loading branch information
rouke-broersma committed Dec 20, 2024
1 parent 59eaecc commit 9d3b3b9
Showing 1 changed file with 33 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
Expand All @@ -16,34 +17,32 @@ namespace Validation;
public class ValidateStrykerResults
{
private readonly ReadOnlyCollection<SyntaxKind> _blacklistedSyntaxKindsForMutating =
new(new[]
{
// Usings
SyntaxKind.UsingDirective,
SyntaxKind.UsingKeyword,
SyntaxKind.UsingStatement,
// Comments
SyntaxKind.DocumentationCommentExteriorTrivia,
SyntaxKind.EndOfDocumentationCommentToken,
SyntaxKind.MultiLineCommentTrivia,
SyntaxKind.MultiLineDocumentationCommentTrivia,
SyntaxKind.SingleLineCommentTrivia,
SyntaxKind.SingleLineDocumentationCommentTrivia,
SyntaxKind.XmlComment,
SyntaxKind.XmlCommentEndToken,
SyntaxKind.XmlCommentStartToken,
}
new([
// Usings
SyntaxKind.UsingDirective,
SyntaxKind.UsingKeyword,
SyntaxKind.UsingStatement,
// Comments
SyntaxKind.DocumentationCommentExteriorTrivia,
SyntaxKind.EndOfDocumentationCommentToken,
SyntaxKind.MultiLineCommentTrivia,
SyntaxKind.MultiLineDocumentationCommentTrivia,
SyntaxKind.SingleLineCommentTrivia,
SyntaxKind.SingleLineDocumentationCommentTrivia,
SyntaxKind.XmlComment,
SyntaxKind.XmlCommentEndToken,
SyntaxKind.XmlCommentStartToken,
]
);
private readonly ReadOnlyCollection<SyntaxKind> _parentSyntaxKindsForMutating =
new(new[]
{
SyntaxKind.MethodDeclaration,
SyntaxKind.PropertyDeclaration,
SyntaxKind.ConstructorDeclaration,
SyntaxKind.FieldDeclaration,
SyntaxKind.OperatorDeclaration,
SyntaxKind.IndexerDeclaration,
}
new([
SyntaxKind.MethodDeclaration,
SyntaxKind.PropertyDeclaration,
SyntaxKind.ConstructorDeclaration,
SyntaxKind.FieldDeclaration,
SyntaxKind.OperatorDeclaration,
SyntaxKind.IndexerDeclaration,
]
);
private const string MutationReportJson = "mutation-report.json";

Expand Down Expand Up @@ -102,7 +101,7 @@ public async Task CSharp_NetCore_WithTwoTestProjects()

var report = await strykerRunOutput.DeserializeJsonReportAsync();

CheckReportMutants(report, total: 601, ignored: 105, survived: 5, killed: 11, timeout: 2, nocoverage: 447);
CheckReportMutants(report, total: 631, ignored: 105, survived: 5, killed: 11, timeout: 2, nocoverage: 447);
CheckReportTestCounts(report, total: 21);
}

Expand All @@ -121,7 +120,7 @@ public async Task CSharp_NetCore_SolutionRun()

var report = await strykerRunOutput.DeserializeJsonReportAsync();

CheckReportMutants(report, total: 601, ignored: 247, survived: 4, killed: 9, timeout: 2, nocoverage: 308);
CheckReportMutants(report, total: 631, ignored: 256, survived: 4, killed: 9, timeout: 2, nocoverage: 323);
CheckReportTestCounts(report, total: 23);
}

Expand All @@ -140,7 +139,12 @@ private void CheckMutationKindsValidity(IJsonReport report)
var nodeKind = node.Kind();
_blacklistedSyntaxKindsForMutating.ShouldNotContain(nodeKind);

node.AncestorsAndSelf().ShouldContain(pn => _parentSyntaxKindsForMutating.Contains(pn.Kind()));
node
.AncestorsAndSelf()
.ShouldContain(pn =>
_parentSyntaxKindsForMutating.Contains(pn.Kind()),
$"Mutation {mutation.MutatorName} in file {file.Key} does not have one of the known parent syntax kinds as it's parent. {Environment.NewLine}" +
$"Instead it has: {Environment.NewLine} {string.Join($",{Environment.NewLine}", node.AncestorsAndSelf().Select(n => n.Kind()))}");
}
}
}
Expand Down

0 comments on commit 9d3b3b9

Please sign in to comment.