@@ -6,7 +6,7 @@ import * as path from 'path';
6
6
import * as net from 'net' ;
7
7
import { IConfigurationService , ITestOutputChannel } from '../../../common/types' ;
8
8
import { createDeferred , Deferred } from '../../../common/utils/async' ;
9
- import { traceError , traceLog , traceVerbose } from '../../../logging' ;
9
+ import { traceError , traceInfo , traceLog , traceVerbose } from '../../../logging' ;
10
10
import { DataReceivedEvent , ExecutionTestPayload , ITestExecutionAdapter , ITestServer } from '../common/types' ;
11
11
import {
12
12
ExecutionFactoryCreateWithEnvironmentOptions ,
@@ -21,7 +21,7 @@ import { EXTENSION_ROOT_DIR } from '../../../common/constants';
21
21
// eslint-disable-next-line @typescript-eslint/no-explicit-any
22
22
// (global as any).EXTENSION_ROOT_DIR = EXTENSION_ROOT_DIR;
23
23
/**
24
- * Wrapper Class for pytest test execution. This is where we call `runTestCommand`?
24
+ * Wrapper Class for pytest test execution..
25
25
*/
26
26
27
27
export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
@@ -52,7 +52,6 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
52
52
executionFactory ?: IPythonExecutionFactory ,
53
53
debugLauncher ?: ITestDebugLauncher ,
54
54
) : Promise < ExecutionTestPayload > {
55
- traceVerbose ( uri , testIds , debugBool ) ;
56
55
if ( executionFactory !== undefined ) {
57
56
// ** new version of run tests.
58
57
return this . runTestsNew ( uri , testIds , debugBool , executionFactory , debugLauncher ) ;
@@ -120,41 +119,43 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
120
119
const testData = JSON . stringify ( testIds ) ;
121
120
const headers = [ `Content-Length: ${ Buffer . byteLength ( testData ) } ` , 'Content-Type: application/json' ] ;
122
121
const payload = `${ headers . join ( '\r\n' ) } \r\n\r\n${ testData } ` ;
122
+ traceLog ( `Running pytest execution for the following test ids: ${ testIds } ` ) ;
123
123
124
124
let pytestRunTestIdsPort : string | undefined ;
125
125
const startServer = ( ) : Promise < number > =>
126
126
new Promise ( ( resolve , reject ) => {
127
127
const server = net . createServer ( ( socket : net . Socket ) => {
128
128
socket . on ( 'end' , ( ) => {
129
- traceLog ( 'Client disconnected' ) ;
129
+ traceVerbose ( 'Client disconnected for pytest test ids server ' ) ;
130
130
} ) ;
131
131
} ) ;
132
132
133
133
server . listen ( 0 , ( ) => {
134
134
const { port } = server . address ( ) as net . AddressInfo ;
135
- traceLog ( `Server listening on port ${ port } ` ) ;
135
+ traceVerbose ( `Server listening on port ${ port } for pytest test ids server ` ) ;
136
136
resolve ( port ) ;
137
137
} ) ;
138
138
139
139
server . on ( 'error' , ( error : Error ) => {
140
+ traceError ( 'Error starting server for pytest test ids server:' , error ) ;
140
141
reject ( error ) ;
141
142
} ) ;
142
143
server . on ( 'connection' , ( socket : net . Socket ) => {
143
144
socket . write ( payload ) ;
144
- traceLog ( 'payload sent' , payload ) ;
145
+ traceVerbose ( 'payload sent for pytest execution ' , payload ) ;
145
146
} ) ;
146
147
} ) ;
147
148
148
149
// Start the server and wait until it is listening
149
150
await startServer ( )
150
151
. then ( ( assignedPort ) => {
151
- traceLog ( `Server started and listening on port ${ assignedPort } ` ) ;
152
+ traceVerbose ( `Server started for pytest test ids server and listening on port ${ assignedPort } ` ) ;
152
153
pytestRunTestIdsPort = assignedPort . toString ( ) ;
153
154
if ( spawnOptions . extraVariables )
154
155
spawnOptions . extraVariables . RUN_TEST_IDS_PORT = pytestRunTestIdsPort ;
155
156
} )
156
157
. catch ( ( error ) => {
157
- traceError ( 'Error starting server:' , error ) ;
158
+ traceError ( 'Error starting server for pytest test ids server :' , error ) ;
158
159
} ) ;
159
160
160
161
if ( debugBool ) {
@@ -169,20 +170,21 @@ export class PytestTestExecutionAdapter implements ITestExecutionAdapter {
169
170
pytestUUID,
170
171
pytestRunTestIdsPort,
171
172
} ;
172
- traceVerbose ( `Running debug test with arguments: ${ testArgs . join ( ' ' ) } \r\n` ) ;
173
+ traceInfo ( `Running DEBUG pytest with arguments: ${ testArgs . join ( ' ' ) } \r\n` ) ;
173
174
await debugLauncher ! . launchDebugger ( launchOptions ) ;
174
175
} else {
175
176
// combine path to run script with run args
176
177
const scriptPath = path . join ( fullPluginPath , 'vscode_pytest' , 'run_pytest_script.py' ) ;
177
178
const runArgs = [ scriptPath , ...testArgs ] ;
179
+ traceInfo ( `Running pytests with arguments: ${ runArgs . join ( ' ' ) } \r\n` ) ;
178
180
179
181
await execService ?. exec ( runArgs , spawnOptions ) . catch ( ( ex ) => {
180
182
traceError ( `Error while running tests: ${ testIds } \r\n${ ex } \r\n\r\n` ) ;
181
183
return Promise . reject ( ex ) ;
182
184
} ) ;
183
185
}
184
186
} catch ( ex ) {
185
- traceVerbose ( `Error while running tests: ${ testIds } \r\n${ ex } \r\n\r\n` ) ;
187
+ traceError ( `Error while running tests: ${ testIds } \r\n${ ex } \r\n\r\n` ) ;
186
188
return Promise . reject ( ex ) ;
187
189
}
188
190
0 commit comments