@@ -5,7 +5,6 @@ import { cpus } from 'os';
5
5
import * as path from 'path' ;
6
6
import * as vscode from 'vscode' ;
7
7
import { CancellationToken } from 'vscode-languageclient' ;
8
- import { adaExtState } from './extension' ;
9
8
import { getMatchingPrefixes , parallelize , staggerProgress , toPosix } from './helpers' ;
10
9
11
10
/**
@@ -386,15 +385,25 @@ export async function addCoverageData(run: vscode.TestRun, covDir: string) {
386
385
387
386
if ( srcUri === undefined ) {
388
387
/**
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.
392
405
*/
393
- const exclude = `${ await adaExtState
394
- . getObjectDir ( )
395
- . then ( vscode . workspace . asRelativePath )
396
- . then ( ( objDir ) => `${ objDir } /**/*` )
397
- . catch ( ( ) => null ) } `;
406
+ const exclude = `**/gnatcov-instr/**/*` ;
398
407
399
408
/**
400
409
* If the prefixes haven't been found yet, or
0 commit comments