@@ -22,39 +22,39 @@ async function resolveItemChildren(item: vscode.TestItem) {
2222 { query : `CALL %Dictionary.ClassDefinition_SubclassOf('%UnitTest.TestCase', '${ ( namespace === "%SYS" ? "" : "@" ) } ')` } ,
2323 ) ;
2424 if ( response ) {
25- response ?. data ?. result ?. content ?. forEach ( async element => {
25+ for await ( const element of response ?. data ?. result ?. content ) {
2626 const fullClassName : string = element . Name ;
27-
28- const tiClass = loadedTestController . createTestItem (
29- ` ${ item . id } : ${ fullClassName } ` ,
30- fullClassName ,
31- vscode . Uri . from ( {
32- scheme : item . uri ?. scheme === "isfs" ? "isfs" : "isfs-readonly" ,
33- authority : item . id . toLowerCase ( ) ,
34- path : "/" + fullClassName . replace ( / \. / g , "/" ) + ".cls"
35- } )
36- ) ;
37- const symbols = await vscode . commands . executeCommand < vscode . ProviderResult < vscode . SymbolInformation [ ] | vscode . DocumentSymbol [ ] > > ( 'vscode.executeDocumentSymbolProvider' , tiClass . uri ) ;
38- if ( symbols ?. length === 1 && symbols [ 0 ] . kind === vscode . SymbolKind . Class ) {
39- const symbol = symbols [ 0 ] ;
40- tiClass . range = ( symbol as vscode . DocumentSymbol ) . range || ( symbol as vscode . SymbolInformation ) . location . range ;
41- ( symbol as vscode . DocumentSymbol ) . children . forEach ( childSymbol => {
42- if ( childSymbol . kind === vscode . SymbolKind . Method && childSymbol . name . startsWith ( "Test" ) ) {
43- const testMethodName = childSymbol . name ;
44- const tiMethod = loadedTestController . createTestItem (
45- `${ tiClass . id } :${ testMethodName } ` ,
46- testMethodName . slice ( 4 ) ,
47- tiClass . uri
48- ) ;
49- tiMethod . range = childSymbol . range ;
50- tiClass . children . add ( tiMethod ) ;
51- }
52- } ) ;
53- }
54- if ( tiClass . children . size > 0 ) {
55- item . children . add ( tiClass ) ;
56- }
57- } ) ;
27+ const tiClass = loadedTestController . createTestItem (
28+ ` ${ item . id } : ${ fullClassName } ` ,
29+ fullClassName ,
30+ vscode . Uri . from ( {
31+ scheme : item . uri ?. scheme === "isfs" ? "isfs" : "isfs-readonly" ,
32+ authority : item . id . toLowerCase ( ) ,
33+ path : "/" + fullClassName . replace ( / \. / g , "/" ) + ".cls" ,
34+ query : item . uri ?. query
35+ } )
36+ ) ;
37+ const symbols = await vscode . commands . executeCommand < vscode . ProviderResult < vscode . SymbolInformation [ ] | vscode . DocumentSymbol [ ] > > ( 'vscode.executeDocumentSymbolProvider' , tiClass . uri ) ;
38+ if ( symbols ?. length === 1 && symbols [ 0 ] . kind === vscode . SymbolKind . Class ) {
39+ const symbol = symbols [ 0 ] ;
40+ tiClass . range = ( symbol as vscode . DocumentSymbol ) . range || ( symbol as vscode . SymbolInformation ) . location . range ;
41+ ( symbol as vscode . DocumentSymbol ) . children . forEach ( childSymbol => {
42+ if ( childSymbol . kind === vscode . SymbolKind . Method && childSymbol . name . startsWith ( "Test" ) ) {
43+ const testMethodName = childSymbol . name ;
44+ const tiMethod = loadedTestController . createTestItem (
45+ `${ tiClass . id } :${ testMethodName } ` ,
46+ testMethodName . slice ( 4 ) ,
47+ tiClass . uri
48+ ) ;
49+ tiMethod . range = childSymbol . range ;
50+ tiClass . children . add ( tiMethod ) ;
51+ }
52+ } ) ;
53+ }
54+ if ( tiClass . children . size > 0 ) {
55+ item . children . add ( tiClass ) ;
56+ }
57+ }
5858 }
5959 }
6060 }
@@ -82,14 +82,6 @@ export async function setupServerTestsController() {
8282export async function runTestsHandler ( request : vscode . TestRunRequest , cancellation : vscode . CancellationToken ) {
8383 logger . info ( 'runTestsHandler invoked' ) ;
8484
85- const run = loadedTestController . createTestRun (
86- request ,
87- 'Test Results' ,
88- true
89- ) ;
90-
91- run . appendOutput ( 'Fake output from fake run of fake server tests.\r\nTODO' ) ;
92-
9385 // For each authority (i.e. server:namespace) accumulate a map of the class-level Test nodes in the tree.
9486 // We don't yet support running only some TestXXX methods in a testclass
9587 const mapAuthorities = new Map < string , Map < string , vscode . TestItem > > ( ) ;
@@ -121,7 +113,6 @@ export async function runTestsHandler(request: vscode.TestRunRequest, cancellati
121113 // Mark each leaf item (a TestXXX method in a class) as enqueued and note its .cls file for copying.
122114 // Every leaf must have a uri.
123115 if ( test . children . size === 0 && test . uri && test . parent ) {
124- run . enqueued ( test ) ;
125116 const authority = test . uri . authority ;
126117 const mapTestClasses = mapAuthorities . get ( authority ) || new Map < string , vscode . TestItem > ( ) ;
127118 mapTestClasses . set ( test . uri . path , test . parent ) ;
@@ -132,11 +123,23 @@ export async function runTestsHandler(request: vscode.TestRunRequest, cancellati
132123 test . children . forEach ( test => queue . push ( test ) ) ;
133124 }
134125
126+ if ( mapAuthorities . size === 0 ) {
127+ // Nothing included
128+ vscode . window . showWarningMessage ( `Empty test run` ) ;
129+ return ;
130+ }
131+
135132 if ( cancellation . isCancellationRequested ) {
136133 // TODO what?
137134 }
138135
139136 for await ( const mapInstance of mapAuthorities ) {
137+
138+ const run = loadedTestController . createTestRun (
139+ request ,
140+ 'Test Results' ,
141+ true
142+ ) ;
140143 const authority = mapInstance [ 0 ] ;
141144 const mapTestClasses = mapInstance [ 1 ] ;
142145 const firstClassTestItem = Array . from ( mapTestClasses . values ( ) ) [ 0 ] ;
@@ -157,21 +160,25 @@ export async function runTestsHandler(request: vscode.TestRunRequest, cancellati
157160 }
158161 for await ( const mapInstance of mapTestClasses ) {
159162 const key = mapInstance [ 0 ] ;
160- const uri = mapInstance [ 1 ] . uri ;
163+ const classTest = mapInstance [ 1 ] ;
164+ const uri = classTest . uri ;
161165 const keyParts = key . split ( '/' ) ;
162166 const clsFile = keyParts . pop ( ) || '' ;
163- const directoryUri = testRoot . with ( { path : testRoot . path . concat ( keyParts . join ( '/' ) ) } ) ;
167+ const directoryUri = testRoot . with ( { path : testRoot . path . concat ( keyParts . join ( '/' ) + '/' ) } ) ;
164168 // This will always be true since every test added to the map above required a uri
165169 if ( uri ) {
166170 try {
167171 await vscode . workspace . fs . copy ( uri , directoryUri . with ( { path : directoryUri . path . concat ( clsFile ) } ) ) ;
168172 } catch ( error ) {
169173 console . log ( error ) ;
174+ continue ;
170175 }
176+ classTest . children . forEach ( ( methodTest ) => {
177+ run . enqueued ( methodTest ) ;
178+ } ) ;
171179 }
172180 }
173181
174- // Find this user's most recent TestInstance
175182 const serverSpec : IServerSpec = {
176183 username : server . username ,
177184 name : server . serverName ,
@@ -183,6 +190,8 @@ export async function runTestsHandler(request: vscode.TestRunRequest, cancellati
183190 }
184191 }
185192 const namespace : string = server . namespace . toUpperCase ( ) ;
193+ /*
194+ // Find this user's most recent TestInstance (TODO - unused, can be removed)
186195 const response = await makeRESTRequest(
187196 "POST",
188197 serverSpec,
@@ -196,6 +205,7 @@ export async function runTestsHandler(request: vscode.TestRunRequest, cancellati
196205 const latestInstanceId = response?.data?.result?.content?.[0]?.ID;
197206 console.log(latestInstanceId);
198207 }
208+ */
199209
200210 // Run tests through the debugger but only stop at breakpoints etc if user chose "Debug Test" instead of "Run Test"
201211 const runIndex = allTestRuns . push ( run ) - 1 ;
@@ -208,7 +218,8 @@ export async function runTestsHandler(request: vscode.TestRunRequest, cancellati
208218 "testIdBase" : firstClassTestItem . id . split ( ":" , 2 ) . join ( ":" )
209219 } ;
210220 const sessionOptions : vscode . DebugSessionOptions = {
211- noDebug : request . profile ?. kind !== vscode . TestRunProfileKind . Debug
221+ noDebug : request . profile ?. kind !== vscode . TestRunProfileKind . Debug ,
222+ suppressDebugToolbar : request . profile ?. kind !== vscode . TestRunProfileKind . Debug
212223 }
213224 if ( ! await vscode . debug . startDebugging ( folder , configuration , sessionOptions ) ) {
214225 await vscode . window . showErrorMessage ( `Failed to launch testing` , { modal : true } ) ;
@@ -218,6 +229,4 @@ export async function runTestsHandler(request: vscode.TestRunRequest, cancellati
218229 }
219230 }
220231 }
221-
222- //run.end();
223232}
0 commit comments