@@ -31,7 +31,7 @@ async function resolveItemChildren(item: vscode.TestItem) {
3131 vscode . Uri . from ( {
3232 scheme : "isfs-readonly" ,
3333 authority : item . id . toLowerCase ( ) ,
34- path : "/" + fullClassName . replace ( / \. / , "/" ) + ".cls"
34+ path : "/" + fullClassName . replace ( / \. / g , "/" ) + ".cls"
3535 } )
3636 ) ;
3737 const symbols = await vscode . commands . executeCommand < vscode . ProviderResult < vscode . SymbolInformation [ ] | vscode . DocumentSymbol [ ] > > ( 'vscode.executeDocumentSymbolProvider' , tiClass . uri ) ;
@@ -42,7 +42,7 @@ async function resolveItemChildren(item: vscode.TestItem) {
4242 if ( childSymbol . kind === vscode . SymbolKind . Method && childSymbol . name . startsWith ( "Test" ) ) {
4343 const testMethodName = childSymbol . name ;
4444 const tiMethod = loadedTestController . createTestItem (
45- `${ item . id } :${ testMethodName } ` ,
45+ `${ tiClass . id } :${ testMethodName } ` ,
4646 testMethodName . slice ( 4 ) ,
4747 tiClass . uri
4848 ) ;
@@ -88,6 +88,7 @@ export async function runTestsHandler(request: vscode.TestRunRequest, cancellati
8888 true
8989 ) ;
9090 run . appendOutput ( 'Fake output from fake run of fake server tests.\r\nTODO' ) ;
91+ const mapAuthorities = new Map < string , Map < string , vscode . Uri > > ( ) ;
9192 const queue : vscode . TestItem [ ] = [ ] ;
9293
9394 // Loop through all included tests, or all known tests, and add them to our queue
@@ -113,39 +114,48 @@ export async function runTestsHandler(request: vscode.TestRunRequest, cancellati
113114 resolveItemChildren ( test ) ;
114115 }
115116
116- // Return result for leaf items
117- if ( test . children . size === 0 ) {
118- let suffix = test . id . split ( '.' ) . pop ( ) ;
119- if ( ! suffix ?. match ( / ^ \d + $ / ) ) {
120- suffix = ( Math . random ( ) * 5 + 1 ) . toPrecision ( 1 ) ;
121- }
122- switch ( suffix ) {
123- case '1' :
124- run . skipped ( test ) ;
125- break ;
126-
127- case '2' :
128- run . failed ( test , new vscode . TestMessage ( 'fake failure' ) , 12300 ) ;
129- break ;
130-
131- case '3' :
132- run . errored ( test , new vscode . TestMessage ( 'fake error' ) , 900 ) ;
133- break ;
134-
135- case '4' :
136- run . enqueued ( test ) ;
137- break ;
138-
139- default :
140- run . passed ( test , 45600 ) ;
141- break ;
142- }
117+ // Mark each leaf item as enqueued and note its .cls file for copying
118+ if ( test . children . size === 0 && test . uri ) {
119+ run . enqueued ( test ) ;
120+ const authority = test . uri . authority ;
121+ const mapUris = mapAuthorities . get ( authority ) || new Map < string , vscode . Uri > ( ) ;
122+ mapUris . set ( test . uri . path , test . uri ) ;
123+ mapAuthorities . set ( authority , mapUris ) ;
143124 }
144125
145126 // Queue any children
146127 test . children . forEach ( test => queue . push ( test ) ) ;
147128 }
148129
130+ if ( cancellation . isCancellationRequested ) {
131+ // TODO what?
132+ }
133+
134+ for await ( const one of mapAuthorities ) {
135+ const authority = one [ 0 ] ;
136+ const mapUris = one [ 1 ] ;
137+ const username = 'johnm' ; //TODO
138+ const testRoot = vscode . Uri . from ( { scheme : 'isfs' , authority, path : `/.vscode/UnitTestRoot/${ username } ` } ) ;
139+ try {
140+ await vscode . workspace . fs . delete ( testRoot , { recursive : true } ) ;
141+ } catch ( error ) {
142+ console . log ( error ) ;
143+ }
144+ for await ( const one of mapUris ) {
145+ const key = one [ 0 ] ;
146+ const uri = one [ 1 ] ;
147+ const keyParts = key . split ( '/' ) ;
148+ const clsFile = keyParts . pop ( ) || '' ;
149+ const directoryUri = testRoot . with ( { path : testRoot . path . concat ( keyParts . join ( '/' ) ) } ) ;
150+ try {
151+ await vscode . workspace . fs . copy ( uri , directoryUri . with ( { path : directoryUri . path . concat ( clsFile ) } ) ) ;
152+ } catch ( error ) {
153+ console . log ( error ) ;
154+ }
155+ }
156+ }
157+
158+ // TODO
149159 await new Promise ( resolve => setTimeout ( resolve , 5000 ) ) ;
150160 run . end ( ) ;
151- }
161+ }
0 commit comments