mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-01-18 22:31:44 +07:00
test: add unit test for problem matcher
This commit is contained in:
parent
93a95a226b
commit
e8284b346f
32
__tests__/problem-matchers.json.test.ts
Normal file
32
__tests__/problem-matchers.json.test.ts
Normal file
@ -0,0 +1,32 @@
|
||||
import dotnetFormat from '../.github/dotnet-format.json';
|
||||
|
||||
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]",
|
||||
'/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'
|
||||
]
|
||||
])(
|
||||
'"%s" returns {file: "%s", line: "%s", column: "%s", severity: "%s", code: "%s", message: "%s", fromPath: "%s"}',
|
||||
(logOutput, file, line, column, severity, code, message, fromPath) => {
|
||||
const regexp = new RegExp(problemMatcher.regexp);
|
||||
const res = logOutput.match(regexp);
|
||||
|
||||
expect(res?.[problemMatcher.file]).toBe(file);
|
||||
expect(res?.[problemMatcher.line]).toBe(line);
|
||||
expect(res?.[problemMatcher.column]).toBe(column);
|
||||
expect(res?.[problemMatcher.severity]).toBe(severity);
|
||||
expect(res?.[problemMatcher.code]).toBe(code);
|
||||
expect(res?.[problemMatcher.message]).toBe(message);
|
||||
expect(res?.[problemMatcher.fromPath]).toBe(fromPath);
|
||||
}
|
||||
);
|
||||
});
|
Loading…
Reference in New Issue
Block a user