Skip to content

Commit

Permalink
Test additions and fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
TSonono committed Nov 5, 2024
1 parent 9014ffa commit a488223
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,33 +48,33 @@ add_custom_target(runTestTarget DEPENDS TestBuildProcess
COMMENT "Run test target"
)

find_program(LCOV lcov)
find_program(LCOV lcov REQUIRED)
set(LCOV_BASE lcov-base.info)
set(LCOV_TEST lcov-test.info)
set(LCOV_TOTAL lcov.info)
set(LCOV_LOG lcov.log)
set(LCOV_ERR lcov.err)
add_custom_target(init-coverage
COMMENT "Collecting initial coverage"
COMMAND ${LCOV} -c -i -d ${CMAKE_CURRENT_BINARY_DIR}
COMMAND lcov -c -i -d ${CMAKE_CURRENT_BINARY_DIR}
-o ${LCOV_BASE} 2>${LCOV_ERR} >${LCOV_LOG})
add_dependencies(init-coverage reset-coverage)

add_custom_target(reset-coverage
COMMENT "Reset all coverage counters to zero"
COMMAND ${LCOV} -q -z -d ${CMAKE_CURRENT_BINARY_DIR}
COMMAND lcov -q -z -d ${CMAKE_CURRENT_BINARY_DIR}
-o ${LCOV_BASE}
COMMAND ${LCOV} -q -z -d ${CMAKE_CURRENT_BINARY_DIR}
COMMAND lcov -q -z -d ${CMAKE_CURRENT_BINARY_DIR}
-o ${LCOV_TEST}
COMMAND ${LCOV} -q -z -d ${CMAKE_CURRENT_BINARY_DIR}
COMMAND lcov -q -z -d ${CMAKE_CURRENT_BINARY_DIR}
-o ${LCOV_TOTAL})

add_custom_target(capture-coverage
COMMENT "Capture coverage data"
DEPENDS ${LCOV_BASE}
COMMAND ${LCOV} -c -d ${CMAKE_CURRENT_BINARY_DIR} -o ${LCOV_TEST}
COMMAND lcov -c -d ${CMAKE_CURRENT_BINARY_DIR} -o ${LCOV_TEST}
2>${LCOV_ERR} >${LCOV_LOG}
COMMAND ${LCOV} -a ${LCOV_BASE} -a ${LCOV_TEST} -o ${LCOV_TOTAL}
COMMAND lcov -a ${LCOV_BASE} -a ${LCOV_TEST} -o ${LCOV_TOTAL}
>>${LCOV_LOG}
COMMAND ${LCOV} -r ${LCOV_TOTAL} -o ${LCOV_TOTAL} "'/usr/include*'"
COMMAND lcov -r ${LCOV_TOTAL} -o ${LCOV_TOTAL} "'/usr/include*'"
>>${LCOV_LOG})
3 changes: 3 additions & 0 deletions test/end-to-end-tests/single-root-UI/test/coverage.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { DefaultEnvironment, expect } from '@test/util';
import * as vscode from 'vscode';
import * as fs from 'fs';
import * as path from 'path';

// From vscode: src/vs/workbench/contrib/testing/common/testTypes.ts
const enum TestResultState {
Expand Down Expand Up @@ -59,5 +61,6 @@ suite('Coverage integration', () => {
const testResult: any = await vscode.commands.executeCommand('testing.coverage.uri', vscode.Uri.file(testEnv.projectFolder.location));
expect(testResult['tasks'][0].hasCoverage).to.be.eq(true);
expect(testResult['items'][2].computedState).to.be.eq(TestResultState.Passed);
expect(fs.existsSync(path.join(testEnv.projectFolder.location, testEnv.buildLocation, 'lcov.info'))).to.be.true;
}).timeout(60000);
});
3 changes: 2 additions & 1 deletion test/unit-tests/coverage.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { handleCoverageInfoFiles } from "@cmt/coverage";
import * as vscode from "vscode";
import { expect, getTestResourceFilePath } from "@test/util";
import * as path from "path";

suite('Coverage Handling', () => {

Expand All @@ -27,7 +28,7 @@ suite('Coverage Handling', () => {
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');
expect(filesCoverages[0].uri.fsPath).to.eq(path.join(path.sep, 'tmp', 'lcov', 'main.cpp'));
const coverageDetail = coverageData.get(filesCoverages[0]);
expect(coverageDetail).to.not.be.undefined;

Expand Down

0 comments on commit a488223

Please sign in to comment.