@@ -466,7 +466,15 @@ export class TestController {
466
466
async findTestItem ( id : string , uri : vscode . Uri , line ?: number ) {
467
467
if ( this . testController . items . size === 0 ) {
468
468
// Discover and test items immediately if the test explorer hasn't been expanded
469
- await this . resolveHandler ( undefined ) ;
469
+ await vscode . window . withProgress (
470
+ {
471
+ title : "Discovering tests" ,
472
+ location : vscode . ProgressLocation . Notification ,
473
+ } ,
474
+ async ( progress ) => {
475
+ await this . resolveHandler ( undefined , progress ) ;
476
+ } ,
477
+ ) ;
470
478
}
471
479
472
480
const parentItem = await this . getParentTestItem ( uri ) ;
@@ -1022,12 +1030,18 @@ export class TestController {
1022
1030
1023
1031
private async resolveHandler (
1024
1032
item : vscode . TestItem | undefined ,
1033
+ progress ?: vscode . Progress < { message ?: string ; increment ?: number } > ,
1025
1034
) : Promise < void > {
1026
1035
const workspaceFolders = vscode . workspace . workspaceFolders ;
1027
1036
if ( ! workspaceFolders ) {
1028
1037
return ;
1029
1038
}
1030
1039
1040
+ // If we receive another initial resolve request, but the explorer is already populated, skip
1041
+ if ( item === undefined && this . testController . items . size > 0 ) {
1042
+ return ;
1043
+ }
1044
+
1031
1045
if ( item ) {
1032
1046
const workspaceFolder = vscode . workspace . getWorkspaceFolder ( item . uri ! ) ! ;
1033
1047
@@ -1063,7 +1077,7 @@ export class TestController {
1063
1077
} else if ( workspaceFolders . length === 1 ) {
1064
1078
// If there's only one workspace, there's no point in nesting the tests under the workspace name
1065
1079
await vscode . commands . executeCommand ( "testing.clearTestResults" ) ;
1066
- await this . gatherWorkspaceTests ( workspaceFolders [ 0 ] , undefined ) ;
1080
+ await this . gatherWorkspaceTests ( workspaceFolders [ 0 ] , undefined , progress ) ;
1067
1081
} else {
1068
1082
// If there's more than one workspace, we use them as the top level items
1069
1083
await vscode . commands . executeCommand ( "testing.clearTestResults" ) ;
@@ -1091,11 +1105,21 @@ export class TestController {
1091
1105
private async gatherWorkspaceTests (
1092
1106
workspaceFolder : vscode . WorkspaceFolder ,
1093
1107
item : vscode . TestItem | undefined ,
1108
+ progress ?: vscode . Progress < { message ?: string ; increment ?: number } > ,
1094
1109
) {
1095
1110
const initialCollection = item ? item . children : this . testController . items ;
1096
1111
const pattern = this . testPattern ( workspaceFolder ) ;
1112
+ const filePaths = await vscode . workspace . findFiles ( pattern ) ;
1113
+ const increment = Math . floor ( filePaths . length / 100 ) ;
1114
+
1115
+ for ( const uri of filePaths ) {
1116
+ if ( progress ) {
1117
+ progress . report ( {
1118
+ message : `Processing ${ path . basename ( uri . fsPath ) } ` ,
1119
+ increment,
1120
+ } ) ;
1121
+ }
1097
1122
1098
- for ( const uri of await vscode . workspace . findFiles ( pattern ) ) {
1099
1123
await this . addTestItemsForFile ( uri , workspaceFolder , initialCollection ) ;
1100
1124
}
1101
1125
}
0 commit comments