mirror of
https://github.com/actions/setup-node
synced 2024-12-22 21:22:42 +00:00
Fix TypeScript error line/column (#125)
* Fix TypeScript error line/column * Adopt official pattern from VS Code * Minor cleanup * Add tests for tsc problem matcher Co-authored-by: Lukas Spieß <lumaxis@github.com>
This commit is contained in:
parent
05f0551dbd
commit
46071b5c7a
3 changed files with 50 additions and 11 deletions
11
.github/tsc.json
vendored
11
.github/tsc.json
vendored
|
@ -4,12 +4,13 @@
|
||||||
"owner": "tsc",
|
"owner": "tsc",
|
||||||
"pattern": [
|
"pattern": [
|
||||||
{
|
{
|
||||||
"regexp": "^(?:\\s+\\d+\\>)?([^\\s].*)\\((\\d+|\\d+,\\d+|\\d+,\\d+,\\d+,\\d+)\\)\\s*:\\s+(error|warning|info)\\s+(\\w{1,2}\\d+)\\s*:\\s*(.*)$",
|
"regexp": "^([^\\s].*)[\\(:](\\d+)[,:](\\d+)(?:\\):\\s+|\\s+-\\s+)(error|warning|info)\\s+TS(\\d+)\\s*:\\s*(.*)$",
|
||||||
"file": 1,
|
"file": 1,
|
||||||
"location": 2,
|
"line": 2,
|
||||||
"severity": 3,
|
"column": 3,
|
||||||
"code": 4,
|
"severity": 4,
|
||||||
"message": 5
|
"code": 5,
|
||||||
|
"message": 6
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,15 +8,10 @@ import path from 'path';
|
||||||
import * as main from '../src/main';
|
import * as main from '../src/main';
|
||||||
import * as im from '../src/installer';
|
import * as im from '../src/installer';
|
||||||
import * as auth from '../src/authutil';
|
import * as auth from '../src/authutil';
|
||||||
import {context} from '@actions/github';
|
|
||||||
|
|
||||||
let nodeTestManifest = require('./data/versions-manifest.json');
|
let nodeTestManifest = require('./data/versions-manifest.json');
|
||||||
let nodeTestDist = require('./data/node-dist-index.json');
|
let nodeTestDist = require('./data/node-dist-index.json');
|
||||||
|
|
||||||
// let matchers = require('../matchers.json');
|
|
||||||
// let matcherPattern = matchers.problemMatcher[0].pattern[0];
|
|
||||||
// let matcherRegExp = new RegExp(matcherPattern.regexp);
|
|
||||||
|
|
||||||
describe('setup-node', () => {
|
describe('setup-node', () => {
|
||||||
let inputs = {} as any;
|
let inputs = {} as any;
|
||||||
let os = {} as any;
|
let os = {} as any;
|
||||||
|
|
43
__tests__/problem-matcher.test.ts
Normal file
43
__tests__/problem-matcher.test.ts
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
describe('problem matcher tests', () => {
|
||||||
|
it('tsc: matches TypeScript "pretty" error message', () => {
|
||||||
|
const [
|
||||||
|
{
|
||||||
|
pattern: [{regexp}]
|
||||||
|
}
|
||||||
|
] = require('../.github/tsc.json').problemMatcher;
|
||||||
|
const exampleErrorMessage =
|
||||||
|
"lib/index.js:23:42 - error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";
|
||||||
|
|
||||||
|
const match = exampleErrorMessage.match(new RegExp(regexp));
|
||||||
|
expect(match).not.toBeNull();
|
||||||
|
expect(match![1]).toEqual('lib/index.js');
|
||||||
|
expect(match![2]).toEqual('23');
|
||||||
|
expect(match![3]).toEqual('42');
|
||||||
|
expect(match![4]).toEqual('error');
|
||||||
|
expect(match![5]).toEqual('2345');
|
||||||
|
expect(match![6]).toEqual(
|
||||||
|
"Argument of type 'A' is not assignable to parameter of type 'B'."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('tsc: matches TypeScript error message from log file', () => {
|
||||||
|
const [
|
||||||
|
{
|
||||||
|
pattern: [{regexp}]
|
||||||
|
}
|
||||||
|
] = require('../.github/tsc.json').problemMatcher;
|
||||||
|
const exampleErrorMessage =
|
||||||
|
"lib/index.js(23,42): error TS2345: Argument of type 'A' is not assignable to parameter of type 'B'.";
|
||||||
|
|
||||||
|
const match = exampleErrorMessage.match(new RegExp(regexp));
|
||||||
|
expect(match).not.toBeNull();
|
||||||
|
expect(match![1]).toEqual('lib/index.js');
|
||||||
|
expect(match![2]).toEqual('23');
|
||||||
|
expect(match![3]).toEqual('42');
|
||||||
|
expect(match![4]).toEqual('error');
|
||||||
|
expect(match![5]).toEqual('2345');
|
||||||
|
expect(match![6]).toEqual(
|
||||||
|
"Argument of type 'A' is not assignable to parameter of type 'B'."
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
Loading…
Reference in a new issue