@@ -4,11 +4,8 @@ import { localTestController, OurTestItem, workspaceFolderTestClasses } from './
4
4
import logger from './logger' ;
5
5
import { resolveServerSpecAndNamespace , supportsCoverage } from './utils' ;
6
6
7
- const isResolvedMap = new WeakMap < vscode . TestItem , boolean > ( ) ;
8
-
9
7
async function resolveItemChildren ( item : OurTestItem ) {
10
8
if ( item ) {
11
- isResolvedMap . set ( item , true ) ;
12
9
const itemUri = item . ourUri ;
13
10
if ( itemUri ) {
14
11
const folderIndex = item . id . split ( ':' ) [ 0 ] ; //vscode.workspace.getWorkspaceFolder(itemUri)?.index || 0;
@@ -17,25 +14,41 @@ async function resolveItemChildren(item: OurTestItem) {
17
14
const contents = await vscode . workspace . fs . readDirectory ( itemUri ) ;
18
15
contents . filter ( ( entry ) => entry [ 1 ] === vscode . FileType . Directory ) . forEach ( ( entry ) => {
19
16
const name = entry [ 0 ] ;
20
- const child : OurTestItem = localTestController . createTestItem ( `${ item . id } ${ name } .` , name ) ;
17
+ const childId = `${ item . id } ${ name } .` ;
18
+ if ( item . children . get ( childId ) ) {
19
+ return ;
20
+ }
21
+ const child : OurTestItem = localTestController . createTestItem ( childId , name ) ;
21
22
child . ourUri = itemUri . with ( { path : `${ itemUri . path } /${ name } ` } ) ;
22
23
child . canResolveChildren = true ;
23
- child . supportsCoverage = item . supportsCoverage ;
24
+ child . supportsCoverage = item . supportsCoverage ;
24
25
item . children . add ( child ) ;
25
26
} ) ;
26
27
contents . filter ( ( entry ) => entry [ 1 ] === vscode . FileType . File ) . forEach ( ( entry ) => {
27
28
const name = entry [ 0 ] ;
28
29
if ( name . endsWith ( '.cls' ) ) {
29
- const child : OurTestItem = localTestController . createTestItem ( `${ item . id } ${ name . slice ( 0 , name . length - 4 ) } ` , name , itemUri . with ( { path : `${ itemUri . path } /${ name } ` } ) ) ;
30
+ const childId = `${ item . id } ${ name . slice ( 0 , name . length - 4 ) } ` ;
31
+ if ( item . children . get ( childId ) ) {
32
+ return ;
33
+ }
34
+ const child : OurTestItem = localTestController . createTestItem ( childId , name , itemUri . with ( { path : `${ itemUri . path } /${ name } ` } ) ) ;
30
35
child . ourUri = child . uri ;
31
36
child . canResolveChildren = true ;
32
37
child . supportsCoverage = item . supportsCoverage ;
33
38
item . children . add ( child ) ;
34
39
const fullClassName = child . id . split ( ':' ) [ 3 ] ;
40
+ if ( ! child . parent ) {
41
+ console . log ( `*** BUG - child (id=${ child . id } ) has no parent after item.children.add(child) where item.id=${ item . id } ` ) ;
42
+ }
35
43
//console.log(`workspaceFolderTestClasses.length=${workspaceFolderTestClasses.length}, index=${folderIndex}`);
36
44
workspaceFolderTestClasses [ folderIndex ] . set ( fullClassName , child ) ;
37
45
}
38
46
} ) ;
47
+ if ( item . children . size === 0 ) {
48
+ // If no children, this is a class with no tests
49
+ item . canResolveChildren = false ;
50
+ item . supportsCoverage = false ;
51
+ }
39
52
} catch ( error ) {
40
53
if ( error . code !== vscode . FileSystemError . FileNotADirectory ( ) . code ) {
41
54
throw error ;
@@ -58,7 +71,11 @@ async function resolveItemChildren(item: OurTestItem) {
58
71
const match = lineText . match ( / ^ M e t h o d T e s t ( .+ ) \( / ) ;
59
72
if ( match ) {
60
73
const testName = match [ 1 ] ;
61
- const child : OurTestItem = localTestController . createTestItem ( `${ item . id } :Test${ testName } ` , testName , itemUri ) ;
74
+ const childId = `${ item . id } :Test${ testName } ` ;
75
+ if ( item . children . get ( childId ) ) {
76
+ continue ;
77
+ }
78
+ const child : OurTestItem = localTestController . createTestItem ( childId , testName , itemUri ) ;
62
79
child . ourUri = child . uri ;
63
80
child . range = new vscode . Range ( new vscode . Position ( index , 0 ) , new vscode . Position ( index + 1 , 0 ) )
64
81
child . canResolveChildren = false ;
0 commit comments