-
Notifications
You must be signed in to change notification settings - Fork 554
Expand file tree
/
Copy pathproblem-matchers.json.test.ts
More file actions
70 lines (63 loc) · 2.39 KB
/
problem-matchers.json.test.ts
File metadata and controls
70 lines (63 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import csc from '../.github/csc.json';
import dotnetFormat from '../.github/dotnet-format.json';
// Unit tests for problem matchers
// https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md
describe('/.github/csc.json tests', () => {
const problemMatcher = csc.problemMatcher[0].pattern[0];
it.each([
[
'Program.cs(10,79): error CS1002: ; expected [/Users/zacharyeisinger/Documents/repo/setup-dotnet/__tests__/sample-broken-csproj/sample.csproj]',
{
file: 'Program.cs',
line: '10',
severity: 'error',
code: 'CS1002',
message: '; expected',
fromPath:
'/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]",
{
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'
}
]
])('log "%s" matches %o', (logOutput, expected) => {
const regexp = new RegExp(problemMatcher.regexp);
const res = logOutput.match(regexp);
for (const key in expected) {
expect(res?.[problemMatcher[key]]).toBe(expected[key]);
}
});
});
describe('/.github/dotnet-format.json tests', () => {
const problemMatcher = dotnetFormat.problemMatcher[0].pattern[0];
it.each([
[
"/home/runner/work/repo/Test.cs(18,6): error WHITESPACE: Fix whitespace formatting. Replace 12 characters with '\\n\\s\\s\\s\\s\\s\\s\\s\\s'. [/home/runner/work/repo/Test.csproj]",
{
file: '/home/runner/work/repo/Test.cs',
line: '18',
column: '6',
severity: 'error',
code: 'WHITESPACE',
message:
"Fix whitespace formatting. Replace 12 characters with '\\n\\s\\s\\s\\s\\s\\s\\s\\s'.",
fromPath: '/home/runner/work/repo/Test.csproj'
}
]
])('log "%s" matches %o', (logOutput, expected) => {
const regexp = new RegExp(problemMatcher.regexp);
const res = logOutput.match(regexp);
for (const key in expected) {
expect(res?.[problemMatcher[key]]).toBe(expected[key]);
}
});
});