From a4882234809a3412f8251e290a1e75d105d3f9d6 Mon Sep 17 00:00:00 2001 From: Tofik Sonono Date: Tue, 5 Nov 2024 09:30:54 +0100 Subject: [PATCH] Test additions and fixes --- .../single-root-UI/project-folder/CMakeLists.txt | 16 ++++++++-------- .../single-root-UI/test/coverage.test.ts | 3 +++ test/unit-tests/coverage.test.ts | 3 ++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/test/end-to-end-tests/single-root-UI/project-folder/CMakeLists.txt b/test/end-to-end-tests/single-root-UI/project-folder/CMakeLists.txt index 207e388e8..9a2d2ca14 100644 --- a/test/end-to-end-tests/single-root-UI/project-folder/CMakeLists.txt +++ b/test/end-to-end-tests/single-root-UI/project-folder/CMakeLists.txt @@ -48,7 +48,7 @@ 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) @@ -56,25 +56,25 @@ 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}) diff --git a/test/end-to-end-tests/single-root-UI/test/coverage.test.ts b/test/end-to-end-tests/single-root-UI/test/coverage.test.ts index 94e280d1d..c836c28c4 100644 --- a/test/end-to-end-tests/single-root-UI/test/coverage.test.ts +++ b/test/end-to-end-tests/single-root-UI/test/coverage.test.ts @@ -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 { @@ -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); }); diff --git a/test/unit-tests/coverage.test.ts b/test/unit-tests/coverage.test.ts index 00936e6f1..c7f766a7c 100644 --- a/test/unit-tests/coverage.test.ts +++ b/test/unit-tests/coverage.test.ts @@ -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', () => { @@ -27,7 +28,7 @@ suite('Coverage Handling', () => { const coverageData = new WeakMap(); 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;