-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { handleCoverageInfoFiles } from "@cmt/coverage"; | ||
import * as vscode from "vscode"; | ||
import { expect, getTestResourceFilePath } from "@test/util"; | ||
|
||
suite('Coverage Handling', () => { | ||
|
||
test('Coverage Info (LCOV)', async () => { | ||
const filesCoverages: vscode.FileCoverage[] = []; | ||
const testRun: vscode.TestRun = { | ||
name: '', | ||
token: {} as vscode.CancellationToken, | ||
isPersisted: false, | ||
enqueued: (_test: vscode.TestItem) => {}, | ||
started: (_test: vscode.TestItem) => {}, | ||
passed: (_test: vscode.TestItem, _duration: number) => {}, | ||
failed: (_test: vscode.TestItem, _message: vscode.TestMessage | vscode.TestMessage[], _duration: number) => {}, | ||
skipped: (_test: vscode.TestItem) => {}, | ||
errored: (_test: vscode.TestItem, _message: vscode.TestMessage | vscode.TestMessage[], _duration: number) => {}, | ||
appendOutput: (_output: string, _location?: vscode.Location, _test?: vscode.TestItem) => {}, | ||
addCoverage: (fileCoverage: vscode.FileCoverage) => { | ||
filesCoverages.push(fileCoverage); | ||
}, | ||
end: () => {}, | ||
onDidDispose: (_listener: () => void): vscode.Disposable => new vscode.Disposable(() => {}) | ||
}; | ||
|
||
const coverageData = new WeakMap<vscode.FileCoverage, vscode.FileCoverageDetail[]>(); | ||
await handleCoverageInfoFiles(testRun, [getTestResourceFilePath('lcov.info')], coverageData); | ||
expect(filesCoverages.length).to.eq(1); | ||
expect(filesCoverages[0].uri.fsPath).to.eq('/tmp/lcov/main.cpp'); | ||
const coverageDetail = coverageData.get(filesCoverages[0]); | ||
expect(coverageDetail).to.not.be.undefined; | ||
|
||
expect(coverageDetail![0].executed).to.eq(1); | ||
expect((coverageDetail![0].location as vscode.Position).line).to.eq(2); | ||
|
||
expect(coverageDetail![1].executed).to.eq(1); | ||
expect((coverageDetail![1].location as vscode.Position).line).to.eq(3); | ||
|
||
console.log(JSON.stringify(coverageDetail, null, 4)); | ||
}); | ||
}); |
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,16 @@ | ||
TN: | ||
SF:/tmp/lcov/main.cpp | ||
FN:3,4,main | ||
FN:5,5,_GLOBAL__sub_I_main | ||
FN:5,5,_Z41__static_initialization_and_destruction_0ii | ||
FNDA:1,main | ||
FNDA:1,_GLOBAL__sub_I_main | ||
FNDA:1,_Z41__static_initialization_and_destruction_0ii | ||
FNF:3 | ||
FNH:3 | ||
DA:3,1 | ||
DA:4,1 | ||
DA:5,4 | ||
LF:3 | ||
LH:3 | ||
end_of_record |