-
Notifications
You must be signed in to change notification settings - Fork 93
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
The multiool, core sarif, and validation test binaries now all pass #1215
Changes from 4 commits
bd80b54
0e99aee
66ce107
008b49f
5077d2c
c278310
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using FluentAssertions; | ||
|
@@ -87,15 +88,31 @@ protected void Verify(string testFileName, bool disablePrereleaseCompatibilityTr | |
// Verify that those detected result locations match the expected locations. | ||
private void Verify(Run run, ExpectedValidationResults expectedResults) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I couldn't debug this test easily. So made a slight improvement where the relevant locations of unexpected conditions were isolated/more obvious. #ByDesign |
||
{ | ||
string[] detectedResultLocations = run.Results.Select(r => r.Message.Arguments[0]).OrderBy(loc => loc).ToArray(); | ||
string[] expectedResultLocations = expectedResults.ResultLocationPointers.OrderBy(loc => loc).ToArray(); | ||
HashSet<string> actualResultLocations = new HashSet<string>(run.Results.Select(r => r.Message.Arguments[0]).OrderBy(loc => loc)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Since you're making a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Got it. FYI, i have updated this PR to merge files-array, will push an update in a moment. #Closed |
||
HashSet<string> unexpectedlyAbsentResultLocations = new HashSet<string>(expectedResults.ResultLocationPointers.OrderBy(loc => loc)); | ||
|
||
// We could make this assertion at the start of the method. We delay it until here | ||
// so that, during debugging, you can set a breakpoint here, and you'll have the | ||
// detected and expected result location arrays available to compare. | ||
run.Results.Count.Should().Be(expectedResults.ResultCount); | ||
List<string> unexpectedNewIssues = new List<string>(); | ||
|
||
detectedResultLocations.Should().ContainInOrder(expectedResultLocations); | ||
foreach(string location in actualResultLocations) | ||
{ | ||
if (unexpectedlyAbsentResultLocations.Contains(location)) | ||
{ | ||
// Happy path. Actual location found in expected | ||
unexpectedlyAbsentResultLocations.Remove(location); | ||
} | ||
else | ||
{ | ||
// Bad new unexpected issue | ||
unexpectedNewIssues.Add(location); | ||
} | ||
} | ||
|
||
// No new issues | ||
unexpectedNewIssues.Count.Should().Be(0); | ||
|
||
// No unexpectedly absent issues. If we found everything we expected, | ||
// then our expected results should be empty | ||
unexpectedlyAbsentResultLocations.Count.Should().Be(0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This whole thing can be done with a couple of LINQ calls. Also, a suggested variable rename for consistency:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I considered this but I don't like leaving O(N^2) comparisons hanging around. The code as authored is much less compact/elegant but is clear and performant. In reply to: 248362142 [](ancestors = 248362142) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would you at least do the variable rename? In reply to: 248384220 [](ancestors = 248384220,248362142) |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rule derives from PropertyBag. The big problem with not using interfaces, of course, is that you need a single, sensible base class chain. We barely are able to accomplish this to eliminate IRule (thanks to the SARIF design change to make everything have a property bag). #ByDesign