@@ -8,8 +8,8 @@ import { tmpNameSync } from 'tmp';
88import * as vscode from 'vscode' ;
99import * as yaml from 'yaml' ;
1010import { NotificationType , TestsuiteNotification } from './e3TestsuiteNotifications' ;
11- import { setTerminalEnvironment } from './helpers' ;
1211import { logger } from './extension' ;
12+ import { setTerminalEnvironment } from './helpers' ;
1313
1414interface Testsuite {
1515 uri : vscode . Uri ;
@@ -110,6 +110,13 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
110110 const fullOutput : Buffer [ ] = [ ] ;
111111 const p = spawn ( cmd [ 0 ] , [ ...cmd ] . splice ( 1 ) , {
112112 cwd : vscode . workspace . workspaceFolders ! [ 0 ] . uri . fsPath ,
113+ /**
114+ * This environment influences the resolution of the spawned
115+ * executable. If it's a basename 'python', then the PATH
116+ * variable in the environment given by getEnv() will decide
117+ * which Python gets used.
118+ */
119+ env : getEnv ( ) ,
113120 } ) ;
114121 p . stdout . on ( 'data' , ( chunk ) => {
115122 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
@@ -120,14 +127,21 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
120127 // eslint-disable-next-line @typescript-eslint/no-unsafe-argument
121128 p . stderr . on ( 'data' , ( chunk ) => fullOutput . push ( chunk ) ) ;
122129 p . on ( 'close' , ( code ) => {
123- if ( ! existsSync ( jsonFname ) ) {
124- reject ( new Error ( `Expected JSON file not found: ${ jsonFname } ` ) ) ;
125- }
130+ lastLoadError = '' ;
126131
127132 if ( code !== 0 ) {
128- lastLoadError = `Error getting test list from testsuite.py, ran: ${ cmd . join (
129- ' ' ,
130- ) } \n${ Buffer . concat ( fullOutput ) . toString ( ) } `;
133+ lastLoadError = `Error getting test list from testsuite.py` ;
134+ } else if ( ! existsSync ( jsonFname ) ) {
135+ lastLoadError = `Expected JSON file not found: ${ jsonFname } ` ;
136+ }
137+
138+ if ( lastLoadError . length > 0 ) {
139+ // Append command output
140+ lastLoadError += `\n$ ${ cmd . join ( ' ' ) } \n${ Buffer . concat (
141+ fullOutput ,
142+ ) . toString ( ) } `;
143+
144+ // Create an item in the test tree to hold the error
131145 const errorItem = this . createTestItem ( 'error' , 'Error' ) ;
132146 errorItem . error = new vscode . MarkdownString (
133147 `[Failed to load test list](command:${ showLoadTestListErrorCmdId } )` ,
@@ -292,6 +306,7 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
292306 vscode . TestRunProfileKind . Run ,
293307 runHandler ,
294308 ) ;
309+ context . subscriptions . push ( runProfile ) ;
295310
296311 function processTestsuiteResultIndex ( e3ResultsPath : string , run : vscode . TestRun ) {
297312 const indexPath = path . join ( e3ResultsPath , '_index.json' ) ;
@@ -488,19 +503,6 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
488503 run . appendOutput ( line + '\r\n' ) ;
489504 }
490505 }
491- context . subscriptions . push ( runProfile ) ;
492-
493- vscode . window . withProgress (
494- {
495- location : vscode . ProgressLocation . Notification ,
496- title : 'Loading e3-testsuite tests' ,
497- } ,
498- async ( _ , token ) => {
499- if ( controller . refreshHandler ) {
500- await controller . refreshHandler ( token ) ;
501- }
502- } ,
503- ) ;
504506
505507 function reportE3Result ( run : vscode . TestRun , result : TestResult , targetItem : vscode . TestItem ) {
506508 const messages = [ ] ;
@@ -532,6 +534,20 @@ export function activateE3TestsuiteIntegration(context: vscode.ExtensionContext)
532534
533535 reportResult ( run , result . status , targetItem , messages ) ;
534536 }
537+
538+ if ( existsSync ( getTestsuite ( ) . uri . fsPath ) ) {
539+ void vscode . window . withProgress (
540+ {
541+ location : vscode . ProgressLocation . Notification ,
542+ title : 'Loading e3-testsuite tests' ,
543+ } ,
544+ async ( _ , token ) => {
545+ if ( controller . refreshHandler ) {
546+ await controller . refreshHandler ( token ) ;
547+ }
548+ } ,
549+ ) ;
550+ }
535551}
536552
537553function getRootItemId ( ) : string {
0 commit comments