@@ -16,7 +16,7 @@ import {
16
16
Output ,
17
17
} from '../../../client/common/process/types' ;
18
18
import { PythonTestServer } from '../../../client/testing/testController/common/server' ;
19
- import { ITestDebugLauncher } from '../../../client/testing/common/types' ;
19
+ import { ITestDebugLauncher , LaunchOptions } from '../../../client/testing/common/types' ;
20
20
import { Deferred , createDeferred } from '../../../client/common/utils/async' ;
21
21
import { MockChildProcess } from '../../mocks/mockChildProcess' ;
22
22
import {
@@ -240,6 +240,64 @@ suite('Python Test Server, Send command etc', () => {
240
240
assert ( false , errorMessage ) ;
241
241
}
242
242
} ) ;
243
+ test ( 'sendCommand should add right extra variables to command during debug' , async ( ) => {
244
+ const deferred2 = createDeferred ( ) ;
245
+ const RUN_TEST_IDS_PORT_CONST = '5678' ;
246
+ const error = false ;
247
+ const errorMessage = '' ;
248
+ const debugLauncherMock = typeMoq . Mock . ofType < ITestDebugLauncher > ( ) ;
249
+ let actualLaunchOptions : LaunchOptions = { } as LaunchOptions ;
250
+ const deferred4 = createDeferred ( ) ;
251
+ debugLauncherMock
252
+ . setup ( ( x ) => x . launchDebugger ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) )
253
+ . returns ( ( options , _ ) => {
254
+ actualLaunchOptions = options ;
255
+ deferred4 . resolve ( ) ;
256
+ return Promise . resolve ( ) ;
257
+ } ) ;
258
+ execService
259
+ . setup ( ( x ) => x . execObservable ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) )
260
+ . returns ( ( ) => typeMoq . Mock . ofType < ObservableExecutionResult < string > > ( ) . object ) ;
261
+ const execFactory = typeMoq . Mock . ofType < IPythonExecutionFactory > ( ) ;
262
+ execFactory
263
+ . setup ( ( x ) => x . createActivatedEnvironment ( typeMoq . It . isAny ( ) ) )
264
+ . returns ( ( ) => {
265
+ deferred2 . resolve ( ) ;
266
+ return Promise . resolve ( execService . object ) ;
267
+ } ) ;
268
+ server = new PythonTestServer ( execFactory . object , debugLauncherMock . object ) ;
269
+ sinon . stub ( server , 'getPort' ) . returns ( 12345 ) ;
270
+ // const portServer = server.getPort();
271
+ await server . serverReady ( ) ;
272
+ const options = {
273
+ command : { script : 'myscript' , args : [ '-foo' , 'foo' ] } ,
274
+ workspaceFolder : Uri . file ( '/foo/bar' ) ,
275
+ cwd : '/foo/bar' ,
276
+ uuid : FAKE_UUID ,
277
+ debugBool : true ,
278
+ } ;
279
+ try {
280
+ server . sendCommand ( options , { } , RUN_TEST_IDS_PORT_CONST ) ;
281
+ } catch ( e ) {
282
+ assert ( false , `Error sending command, ${ e } ` ) ;
283
+ }
284
+ // add in await and trigger
285
+ await deferred2 . promise ;
286
+ await deferred4 . promise ;
287
+ mockProc . trigger ( 'close' ) ;
288
+
289
+ assert . notDeepEqual ( actualLaunchOptions , { } , 'launch options should be set' ) ;
290
+ assert . strictEqual ( actualLaunchOptions . cwd , '/foo/bar' ) ;
291
+ assert . strictEqual ( actualLaunchOptions . testProvider , 'unittest' ) ;
292
+ assert . strictEqual ( actualLaunchOptions . pytestPort , '12345' ) ;
293
+ assert . strictEqual ( actualLaunchOptions . pytestUUID , 'fake-uuid' ) ;
294
+ assert . strictEqual ( actualLaunchOptions . runTestIdsPort , '5678' ) ;
295
+
296
+ debugLauncherMock . verify ( ( x ) => x . launchDebugger ( typeMoq . It . isAny ( ) , typeMoq . It . isAny ( ) ) , typeMoq . Times . once ( ) ) ;
297
+ if ( error ) {
298
+ assert ( false , errorMessage ) ;
299
+ }
300
+ } ) ;
243
301
244
302
test ( 'sendCommand should write to an output channel if it is provided as an option' , async ( ) => {
245
303
const output2 : string [ ] = [ ] ;
0 commit comments