@@ -46,8 +46,8 @@ export async function setupHistoryExplorerController() {
4646 }
4747}
4848
49- export function serverSpecForUri ( uri : vscode . Uri ) : IServerSpec | undefined {
50- const server = osAPI . serverForUri ( uri ) ;
49+ export async function serverSpecForUri ( uri : vscode . Uri ) : Promise < IServerSpec | undefined > {
50+ const server = await osAPI . asyncServerForUri ( uri ) ;
5151 if ( server ) {
5252 return {
5353 username : server . username ,
@@ -70,7 +70,7 @@ export async function serverSpec(item: vscode.TestItem): Promise<IServerSpec | u
7070 if ( ! smAPI ) {
7171 return undefined ;
7272 }
73- return await smAPI . getServerSpec ( serverName ) ;
73+ return smAPI . getServerSpec ( serverName ) ;
7474 }
7575 else if ( item . uri ) {
7676 return serverSpecForUri ( item . uri ) ;
@@ -131,20 +131,13 @@ async function addTestSuites(item: OurTestItem, controller: vscode.TestControlle
131131 } ,
132132 ) ;
133133 if ( response ) {
134- const run = controller . createTestRun ( new vscode . TestRunRequest ( ) , `Item '${ item . label } ' history` , false ) ;
135134 response ?. data ?. result ?. content ?. forEach ( element => {
136- const child : OurTestItem = controller . createTestItem ( `${ item . id } :${ element . ID } ` , `${ element . Name } ` ) ;
135+ const child : OurTestItem = controller . createTestItem ( `${ item . id } :${ element . ID } ` , `${ element . Name } ` , item . uri ) ;
136+ child . description = element . Status . toString ( ) ;
137137 child . canResolveChildren = true ;
138138 child . supportsCoverage = item . supportsCoverage ;
139139 item . children . add ( child ) ;
140- if ( element . Status ) {
141- run . passed ( child , element . Duration * 1000 ) ;
142- }
143- else {
144- run . failed ( child , new vscode . TestMessage ( element . ErrorDescription ) , element . Duration * 1000 ) ;
145- }
146140 } ) ;
147- run . end ( ) ;
148141 }
149142 }
150143}
@@ -165,20 +158,13 @@ async function addTestCases(item: OurTestItem, controller: vscode.TestController
165158 } ,
166159 ) ;
167160 if ( response ) {
168- const run = controller . createTestRun ( new vscode . TestRunRequest ( ) , `Item '${ item . label } ' history` , false ) ;
169161 response ?. data ?. result ?. content ?. forEach ( element => {
170- const child : OurTestItem = controller . createTestItem ( `${ item . id } :${ element . ID } ` , `${ element . Name . split ( '.' ) . pop ( ) } ` ) ;
162+ const child : OurTestItem = controller . createTestItem ( `${ item . id } :${ element . ID } ` , `${ element . Name . split ( '.' ) . pop ( ) } ` , item . uri ) ;
163+ child . description = element . Status . toString ( ) ;
171164 child . canResolveChildren = true ;
172165 child . supportsCoverage = item . supportsCoverage ;
173166 item . children . add ( child ) ;
174- if ( element . Status ) {
175- run . passed ( child , element . Duration * 1000 ) ;
176- }
177- else {
178- run . failed ( child , new vscode . TestMessage ( element . ErrorDescription ) , element . Duration * 1000 ) ;
179- }
180167 } ) ;
181- run . end ( ) ;
182168 }
183169 }
184170}
@@ -199,25 +185,18 @@ async function addTestMethods(item: OurTestItem, controller: vscode.TestControll
199185 } ,
200186 ) ;
201187 if ( response ) {
202- const run = controller . createTestRun ( new vscode . TestRunRequest ( ) , `Item '${ item . label } ' history` , false ) ;
203188 response ?. data ?. result ?. content ?. forEach ( element => {
204189 const methodName : string = element . Name ;
205190 // We drop the first 4 characters of the method name because they should always be "Test"
206- const child : OurTestItem = controller . createTestItem ( `${ item . id } :${ element . ID } ` , `${ methodName . slice ( 4 ) } ` ) ;
191+ const child : OurTestItem = controller . createTestItem ( `${ item . id } :${ element . ID } ` , `${ methodName . slice ( 4 ) } ` , item . uri ) ;
192+ child . description = element . Status . toString ( ) ;
207193 child . canResolveChildren = true ;
208194 child . supportsCoverage = item . supportsCoverage ;
209195 item . children . add ( child ) ;
210196
211197 // Remember result fields so they can be reinstated when the descendant Asserts are 'run'
212198 resultMap . set ( child , { status : element . Status , errorDescription : element . ErrorDescription , duration : element . Duration } ) ;
213- if ( element . Status ) {
214- run . passed ( child , element . Duration * 1000 ) ;
215- }
216- else {
217- run . failed ( child , new vscode . TestMessage ( element . ErrorDescription ) , element . Duration * 1000 ) ;
218- }
219199 } ) ;
220- run . end ( ) ;
221200 }
222201 }
223202}
@@ -238,35 +217,14 @@ async function addTestAsserts(item: OurTestItem, controller: vscode.TestControll
238217 } ,
239218 ) ;
240219 if ( response ) {
241- const run = controller . createTestRun ( new vscode . TestRunRequest ( ) , `Item '${ item . label } ' history` , false ) ;
242-
243- // Prevent this level's duration from being blanked out because of children's (absent) durations
244- const itemResult = resultMap . get ( item ) ;
245- if ( itemResult ) {
246- if ( itemResult . status ) {
247- run . passed ( item , itemResult . duration * 1000 ) ;
248- }
249- else {
250- run . failed ( item , new vscode . TestMessage ( itemResult . errorDescription || "(No error description)" ) , itemResult . duration * 1000 ) ;
251- }
252- }
253-
254220 response ?. data ?. result ?. content ?. forEach ( element => {
255- const child : OurTestItem = controller . createTestItem ( `${ item . id } :${ element . ID } ` , `${ element . Action } ` ) ;
221+ const child : OurTestItem = controller . createTestItem ( `${ item . id } :${ element . ID } ` , `${ element . Action } ` , item . uri ) ;
256222 child . sortText = `${ element . Counter . toString ( ) . padStart ( element . MaxCounter . toString ( ) . length , "0" ) } ` ;
257- child . description = element . Description ;
223+ child . description = ` ${ element . Status } ${ element . Description } ` ;
258224 child . canResolveChildren = false ;
259225 child . supportsCoverage = item . supportsCoverage ;
260226 item . children . add ( child ) ;
261- if ( element . Status ) {
262- run . passed ( child ) ;
263- }
264- else {
265- run . failed ( child , new vscode . TestMessage ( element . Description ) ) ;
266- }
267227 } ) ;
268-
269- run . end ( ) ;
270228 }
271229 }
272230}
0 commit comments