2023-03-09 20:43:05 +08:00
|
|
|
import cscFile from '../.github/csc.json';
|
2020-06-13 01:46:25 +08:00
|
|
|
describe('csc tests', () => {
|
2023-05-15 20:09:29 +08:00
|
|
|
test('regular expression in csc.json is valid', async () => {
|
|
|
|
const regexPattern = cscFile['problemMatcher'][0]['pattern'][0]['regexp'];
|
|
|
|
const regexResultsMap = cscFile['problemMatcher'][0]['pattern'][0];
|
2020-06-13 01:46:25 +08:00
|
|
|
|
2023-05-15 20:09:29 +08:00
|
|
|
const regex = new RegExp(regexPattern);
|
2020-06-13 01:46:25 +08:00
|
|
|
|
2023-03-09 20:43:05 +08:00
|
|
|
const stringsToMatch = [
|
2020-06-13 01:46:25 +08:00
|
|
|
'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]"
|
|
|
|
];
|
2023-05-15 20:09:29 +08:00
|
|
|
// 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'
|
|
|
|
}
|
|
|
|
];
|
2020-06-13 01:46:25 +08:00
|
|
|
|
2023-05-15 20:09:29 +08:00
|
|
|
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);
|
|
|
|
}
|
2020-06-13 01:46:25 +08:00
|
|
|
});
|
|
|
|
}, 10000);
|
|
|
|
});
|