-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ProblemMatcher default values improvements
* by default regex group 0 should be used for message. If user has not specified the regex group - this means that message does not have one. Better to use whole line as default, than define regex group, which may not be in the regex. * in case if line has not been defined, first line can be used to identify the problem. Why are these defaults useful? As an example I have a **py.test** output ``` tests/test_something.py .F..................... ``` `F` identifies that one of the test failed. My problemMatcher pattern is very simple ``` "problemMatcher": { "owner": "python", "fileLocation": ["relative", "${workspaceRoot}"], "pattern": { "regexp": "([^\\s=]+) \\.*F\\.*", "file": 1 } } ``` As you can see I cannot define location. I can define message=0 on my own, but guess that default=0 is better than 4.
- Loading branch information
1 parent
be48a08
commit c05d681
Showing
3 changed files
with
80 additions
and
14 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
71 changes: 71 additions & 0 deletions
71
src/vs/platform/markers/test/common/problemMatcher.test.ts
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 |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
'use strict'; | ||
|
||
|
||
import assert = require('assert'); | ||
|
||
import * as Types from 'vs/base/common/types'; | ||
|
||
import Severity from 'vs/base/common/severity'; | ||
import {createLineMatcher, ProblemMatcher, ProblemPattern, ApplyToKind, FileLocationKind} from 'vs/platform/markers/common/problemMatcher'; | ||
|
||
suite('Problem Matcher', () => { | ||
test('default location for single line matcher', () => { | ||
let problemMatcher = <ProblemMatcher>{ | ||
owner: "external", | ||
applyTo: ApplyToKind.allDocuments, | ||
fileLocation: FileLocationKind.Absolute, | ||
pattern: <ProblemPattern>{ | ||
regexp: /([a-z]+) abc/, | ||
file: 1, | ||
message: 0 | ||
} | ||
}; | ||
var lineMatcher = createLineMatcher(problemMatcher); | ||
var result = lineMatcher.handle(["filename abc"]); | ||
assert.ok(result.match); | ||
assert.ok(!result.continue); | ||
assert.ok(Types.isUndefined(result.match.marker.code)); | ||
assert.equal(result.match.marker.severity, Severity.Error); | ||
assert.equal(result.match.marker.message, "filename abc"); | ||
assert.ok(Types.isUndefined(result.match.marker.source)); | ||
assert.equal(result.match.marker.startLineNumber, 1); | ||
assert.equal(result.match.marker.startColumn, 1); | ||
assert.equal(result.match.marker.endLineNumber, 1); | ||
assert.equal(result.match.marker.endColumn, Number.MAX_VALUE); | ||
}); | ||
|
||
test('default location for multi line matcher', () => { | ||
let problemMatcher = <ProblemMatcher>{ | ||
owner: "external", | ||
applyTo: ApplyToKind.allDocuments, | ||
fileLocation: FileLocationKind.Absolute, | ||
pattern: [ | ||
<ProblemPattern>{ | ||
regexp: /file = ([a-z]+)/, | ||
file: 1, | ||
message: 0 | ||
}, | ||
<ProblemPattern>{ | ||
regexp: /severity = ([a-z]+)/, | ||
severity: 1 | ||
} | ||
] | ||
}; | ||
var lineMatcher = createLineMatcher(problemMatcher); | ||
var result = lineMatcher.handle(["file = filename", "severity = warning"]); | ||
assert.ok(result.match); | ||
assert.ok(!result.continue); | ||
assert.ok(Types.isUndefined(result.match.marker.code)); | ||
assert.equal(result.match.marker.severity, Severity.Warning); | ||
assert.equal(result.match.marker.message, "file = filename"); | ||
assert.ok(Types.isUndefined(result.match.marker.source)); | ||
assert.equal(result.match.marker.startLineNumber, 1); | ||
assert.equal(result.match.marker.startColumn, 1); | ||
assert.equal(result.match.marker.endLineNumber, 1); | ||
assert.equal(result.match.marker.endColumn, Number.MAX_VALUE); | ||
}) | ||
}); |
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