Skip to content

Commit

Permalink
Review fixes + disable coverage test on Win
Browse files Browse the repository at this point in the history
MSVC can not produce gcov based coverage data, therefore the coverage
end-to-end tests are disabled on Windows.
  • Loading branch information
TSonono committed Nov 21, 2024
1 parent 8542165 commit 08020d9
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as logging from '@cmt/logging';
nls.config({ messageFormat: nls.MessageFormat.bundle, bundleFormat: nls.BundleFormat.standalone })();
const localize: nls.LocalizeFunc = nls.loadMessageBundle();

const log = logging.createLogger('ctest');
const log = logging.createLogger('ctest-coverage');

export async function handleCoverageInfoFiles(run: vscode.TestRun, coverageInfoFiles: string[], coverageData: WeakMap<vscode.FileCoverage, vscode.FileCoverageDetail[]>) {
for (const coverageInfoFile of coverageInfoFiles) {
Expand Down
4 changes: 2 additions & 2 deletions src/ctest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@ export class CTestDriver implements vscode.Disposable {
if (rc !== 0) {
log.error(localize('test.preRunCoverageTargetFailure', 'Building the preRunCoverageTarget \'{0}\' on project in {1} failed. Skipping running tests.', projectCoverageConfig.preRunCoverageTarget, projectCoverageConfig.project.sourceDir));
run.end();
return 0;
return rc;
}
}
}
Expand All @@ -970,7 +970,7 @@ export class CTestDriver implements vscode.Disposable {
const rc = await projectCoverageConfig.project.build([projectCoverageConfig.postRunCoverageTarget]);
if (rc !== 0) {
log.error(localize('test.postRunCoverageTargetFailure', 'Building target postRunCoverageTarget on project in {0} failed. Skipping handling of coverage data.', projectCoverageConfig.project.sourceDir));
return 0;
return rc;
}
}
}
Expand Down
12 changes: 10 additions & 2 deletions test/end-to-end-tests/single-root-UI/test/coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ suite('Coverage integration', () => {

testEnv = new DefaultEnvironment('test/end-to-end-tests/single-root-UI/project-folder', build_loc, exe_res);

if (process.platform === 'win32') {
// MSVC compiler does not produce gcov based coverage data
return this.skip();
}

await vscode.workspace.getConfiguration('cmake', vscode.workspace.workspaceFolders![0].uri).update('useCMakePresets', 'always');
await vscode.commands.executeCommand('cmake.getSettingsChangePromise');

Expand All @@ -50,8 +55,11 @@ suite('Coverage integration', () => {
await vscode.workspace.getConfiguration('cmake', vscode.workspace.workspaceFolders![0].uri).update('postRunCoverageTarget', 'non-existing-target');

testResult = await vscode.commands.executeCommand('testing.coverage.uri', vscode.Uri.file(testEnv.projectFolder.location));
expect(testResult['tasks'][0].hasCoverage).to.be.eq(false);
expect(testResult['items'][2].computedState).to.be.eq(TestResultState.Unset);
if (testResult !== undefined) {
// May or may not be undefined in this case evidently based on platform
expect(testResult['tasks'][0].hasCoverage).to.be.eq(false);
expect(testResult['items'][2].computedState).to.be.eq(TestResultState.Unset);
}
}).timeout(60000);

test('Good Run test with coverage', async () => {
Expand Down

0 comments on commit 08020d9

Please sign in to comment.