Skip to content

Commit a337192

Browse files
committed
Fix exclusion of instrumented sources when loading coverage report
Closes eng/ide/ada_language_server#1655
1 parent b643839 commit a337192

File tree

1 file changed

+18
-9
lines changed

1 file changed

+18
-9
lines changed

Diff for: integration/vscode/ada/src/gnatcov.ts

+18-9
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { cpus } from 'os';
55
import * as path from 'path';
66
import * as vscode from 'vscode';
77
import { CancellationToken } from 'vscode-languageclient';
8-
import { adaExtState } from './extension';
98
import { getMatchingPrefixes, parallelize, staggerProgress, toPosix } from './helpers';
109

1110
/**
@@ -386,15 +385,25 @@ export async function addCoverageData(run: vscode.TestRun, covDir: string) {
386385

387386
if (srcUri === undefined) {
388387
/**
389-
* Avoid searching in the object dir because we
390-
* might land on gnatcov-instrumented versions
391-
* of the sources.
388+
* GNATcov generates instrumented versions of the
389+
* sources with the same basenames. We want to
390+
* avoid associating coverage data with the
391+
* instrumented sources, so we exclude any paths
392+
* containing the special directory
393+
* `gnatcov-instr`. Ideally it would have been nice
394+
* to exclude precisely `<obj-dir>/gnatcov-instr`
395+
* but that would need to be repeated for each obj
396+
* dir of each project in the closure. As we don't
397+
* have access to that information, we ignore all
398+
* paths containing a `gnatcov-instr` component.
399+
*
400+
* Note that a previous version excluded the entire
401+
* object dir which did not work well on projects
402+
* that use '.' as the object dir. In that case
403+
* excluding the object dir would exclude the
404+
* entire workspace and prevent finding any files.
392405
*/
393-
const exclude = `${await adaExtState
394-
.getObjectDir()
395-
.then(vscode.workspace.asRelativePath)
396-
.then((objDir) => `${objDir}/**/*`)
397-
.catch(() => null)}`;
406+
const exclude = `**/gnatcov-instr/**/*`;
398407

399408
/**
400409
* If the prefixes haven't been found yet, or

0 commit comments

Comments
 (0)