-
Notifications
You must be signed in to change notification settings - Fork 93
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Also: - Enhance the "new-style" verification so that we no longer require the file "Invalid_Expected.sarif". Each file can now contain a property that specifies the expected locations of all the validation results.
- Loading branch information
Larry Golding
authored
Dec 4, 2018
1 parent
5841151
commit b389a3e
Showing
36 changed files
with
273 additions
and
1,376 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
src/Sarif.Multitool.FunctionalTests/Rules/ContextRegionRequiresRegionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// Copyright (c) Microsoft. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
using Xunit; | ||
|
||
namespace Microsoft.CodeAnalysis.Sarif.Multitool.Rules | ||
{ | ||
public class ContextRegionRequiresRegionTests : ValidationSkimmerTestsBase<ContextRegionRequiresRegion> | ||
{ | ||
[Fact(DisplayName = nameof(ContextRegionRequiresRegion_ReportsInvalidSarif))] | ||
public void ContextRegionRequiresRegion_ReportsInvalidSarif() | ||
{ | ||
// We need to disable compatibility transformations for any files that require | ||
// a malformed schema or malformed JSON, as this code fixes those things up | ||
Verify("Invalid.sarif", disablePrereleaseCompatibilityTransform: true); | ||
} | ||
|
||
[Fact(DisplayName = nameof(ContextRegionRequiresRegion_AcceptsValidSarif))] | ||
public void ContextRegionRequiresRegion_AcceptsValidSarif() | ||
{ | ||
Verify("Valid.sarif"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
src/Sarif.Multitool.FunctionalTests/TestData/ContextRegionRequiresRegion/Invalid.sarif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/sarif-2.0.0", | ||
"version": "2.0.0", | ||
"runs": [ | ||
{ | ||
"tool": { | ||
"name": "CodeScanner" | ||
}, | ||
"results": [ | ||
{ | ||
"ruleId": "TST0001", | ||
"level": "error", | ||
"locations": [ | ||
{ | ||
"physicalLocation": { | ||
"fileLocation": { | ||
"uri": "src/test.c" | ||
}, | ||
"contextRegion": { | ||
"startLine": 2, | ||
"endLine": 4 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"properties": { | ||
"expectedResults": { | ||
"resultLocationPointers": [ | ||
"runs[0].results[0].locations[0].physicalLocation" | ||
] | ||
} | ||
} | ||
} | ||
] | ||
} |
38 changes: 38 additions & 0 deletions
38
src/Sarif.Multitool.FunctionalTests/TestData/ContextRegionRequiresRegion/Valid.sarif
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
{ | ||
"$schema": "http://json.schemastore.org/sarif-2.0.0", | ||
"version": "2.0.0", | ||
"runs": [ | ||
{ | ||
"tool": { | ||
"name": "CodeScanner" | ||
}, | ||
"results": [ | ||
{ | ||
"ruleId": "TST0001", | ||
"level": "error", | ||
"locations": [ | ||
{ | ||
"physicalLocation": { | ||
"fileLocation": { | ||
"uri": "src/test.c" | ||
}, | ||
"region": { | ||
"startLine": 3 | ||
}, | ||
"contextRegion": { | ||
"startLine": 2, | ||
"endLine": 4 | ||
} | ||
} | ||
} | ||
] | ||
} | ||
], | ||
"properties": { | ||
"expectedResults": { | ||
"resultLocationPointers": [] | ||
} | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
126 changes: 0 additions & 126 deletions
126
...if.Multitool.FunctionalTests/TestData/DoNotUseFriendlyNameAsRuleId/Invalid_Expected.sarif
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,11 @@ | |
} | ||
} | ||
} | ||
}, | ||
"properties": { | ||
"expectedResults": { | ||
"resultLocationPointers": [] | ||
} | ||
} | ||
} | ||
] | ||
|
Oops, something went wrong.