-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor and update unit-tests (#418)
* Update unit-tests and dotnet-install scripts
- Loading branch information
1 parent
fc8786b
commit 0f534f5
Showing
9 changed files
with
867 additions
and
641 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -1,21 +1,45 @@ | ||
import cscFile from '../.github/csc.json'; | ||
describe('csc tests', () => { | ||
it('Valid regular expression', async () => { | ||
const regex = cscFile['problemMatcher'][0]['pattern'][0]['regexp']; | ||
test('regular expression in csc.json is valid', async () => { | ||
const regexPattern = cscFile['problemMatcher'][0]['pattern'][0]['regexp']; | ||
const regexResultsMap = cscFile['problemMatcher'][0]['pattern'][0]; | ||
|
||
console.log(regex); | ||
const re = new RegExp(regex); | ||
const regex = new RegExp(regexPattern); | ||
|
||
// Ideally we would verify that this | ||
const stringsToMatch = [ | ||
'Program.cs(10,79): error CS1002: ; expected [/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj]', | ||
"S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs(33,7): error CS1003: Syntax error, ',' expected [S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop]" | ||
]; | ||
// Expected results are calculated according to the csc matcher located in csc.json file | ||
const expectedResults = [ | ||
{ | ||
file: 'Program.cs', | ||
line: '10', | ||
severity: 'error', | ||
code: 'CS1002', | ||
message: '; expected', | ||
fromPath: | ||
'/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj' | ||
}, | ||
{ | ||
file: 'S:\\Msbuild\\src\\Build\\Evaluation\\ExpressionShredder.cs', | ||
line: '33', | ||
severity: 'error', | ||
code: 'CS1003', | ||
message: "Syntax error, ',' expected", | ||
fromPath: | ||
'S:\\msbuild\\src\\Build\\Microsoft.Build.csproj > Properties:prop' | ||
} | ||
]; | ||
|
||
stringsToMatch.forEach(string => { | ||
const matchStr = string.match(re); | ||
console.log(matchStr); | ||
expect(matchStr).toEqual(expect.anything()); | ||
stringsToMatch.map((string, index) => { | ||
const matchedResultsArray = string.match(regex); | ||
for (const propName in expectedResults[index]) { | ||
const propertyIndex = regexResultsMap[propName]; | ||
const expectedPropValue = expectedResults[index][propName]; | ||
const matchedPropValue = matchedResultsArray![propertyIndex]; | ||
expect(matchedPropValue).toEqual(expectedPropValue); | ||
} | ||
}); | ||
}, 10000); | ||
}); |
Oops, something went wrong.