@@ -354,8 +354,6 @@ suite('Standard Debugging - Misc tests', () => {
354
354
await debugClient . assertStoppedLocation ( 'exception' , pauseLocation ) ;
355
355
} ) ;
356
356
test ( 'Test multi-threaded debugging' , async ( ) => {
357
- const threadIdPromise = debugClient . waitForEvent ( 'thread' ) ;
358
-
359
357
await Promise . all ( [
360
358
debugClient . configurationSequence ( ) ,
361
359
debugClient . launch ( buildLauncArgs ( 'multiThread.py' , false ) ) ,
@@ -370,31 +368,37 @@ suite('Standard Debugging - Misc tests', () => {
370
368
} ) ;
371
369
372
370
// hit breakpoint.
373
- const threadId = ( ( await threadIdPromise ) as ThreadEvent ) . body . threadId ;
374
- const stackFramesPromise = debugClient . assertStoppedLocation ( 'breakpoint' , breakpointLocation ) ;
375
- await debugClient . continueRequest ( { threadId } ) ;
376
- await stackFramesPromise ;
371
+ await debugClient . assertStoppedLocation ( 'breakpoint' , breakpointLocation ) ;
377
372
378
373
const threads = await debugClient . threadsRequest ( ) ;
379
374
expect ( threads . body . threads ) . of . lengthOf ( 2 , 'incorrect number of threads' ) ;
375
+ } ) ;
376
+ test ( 'Test stack frames' , async ( ) => {
377
+ await Promise . all ( [
378
+ debugClient . configurationSequence ( ) ,
379
+ debugClient . launch ( buildLauncArgs ( 'stackFrame.py' , false ) ) ,
380
+ debugClient . waitForEvent ( 'initialized' )
381
+ ] ) ;
382
+ const pythonFile = path . join ( debugFilesPath , 'stackFrame.py' ) ;
383
+ const breakpointLocation = { path : pythonFile , column : 0 , line : 5 } ;
384
+ await debugClient . setBreakpointsRequest ( {
385
+ lines : [ breakpointLocation . line ] ,
386
+ breakpoints : [ { line : breakpointLocation . line , column : breakpointLocation . column } ] ,
387
+ source : { path : breakpointLocation . path }
388
+ } ) ;
380
389
381
- for ( const thread of threads . body . threads ) {
382
- const stackframes = await debugClient . stackTraceRequest ( { threadId : thread . id } ) ;
383
- if ( thread . name === 'MainThread' ) {
384
- expect ( stackframes . body . stackFrames [ 0 ] . line ) . to . be . equal ( 11 , 'incorrect line number for main thread stack' ) ;
385
- expect ( stackframes . body . stackFrames [ 0 ] . source ! . path ) . to . be . equal ( pythonFile , 'incorrect source file for main thread stack' ) ;
390
+ // hit breakpoint.
391
+ const stackframes = await debugClient . assertStoppedLocation ( 'breakpoint' , breakpointLocation ) ;
386
392
387
- expect ( stackframes . body . stackFrames [ 1 ] . line ) . to . be . equal ( 14 , 'incorrect line number for main thread stack' ) ;
388
- expect ( stackframes . body . stackFrames [ 1 ] . source ! . path ) . to . be . equal ( pythonFile , 'incorrect source file for main thread stack' ) ;
389
- } else {
390
- expect ( thread . name ) . to . be . equal ( 'foo' , 'incorrect name for thread \'foo\'' ) ;
393
+ expect ( stackframes . body . stackFrames [ 0 ] . line ) . to . be . equal ( 5 ) ;
394
+ expect ( stackframes . body . stackFrames [ 0 ] . source ! . path ) . to . be . equal ( pythonFile ) ;
395
+ expect ( stackframes . body . stackFrames [ 0 ] . name ) . to . be . equal ( 'foo' ) ;
391
396
392
- expect ( stackframes . body . stackFrames [ 0 ] . line ) . to . be . equal ( 11 , 'incorrect line number for foo thread stack' ) ;
393
- expect ( stackframes . body . stackFrames [ 0 ] . source ! . path ) . to . be . equal ( pythonFile , 'incorrect source file for foo thread stack' ) ;
397
+ expect ( stackframes . body . stackFrames [ 1 ] . line ) . to . be . equal ( 8 ) ;
398
+ expect ( stackframes . body . stackFrames [ 1 ] . source ! . path ) . to . be . equal ( pythonFile ) ;
399
+ expect ( stackframes . body . stackFrames [ 1 ] . name ) . to . be . equal ( 'bar' ) ;
394
400
395
- expect ( stackframes . body . stackFrames [ 1 ] . line ) . to . be . equal ( 13 , 'incorrect line number for foo thread stack' ) ;
396
- expect ( stackframes . body . stackFrames [ 1 ] . source ! . path ) . to . be . equal ( pythonFile , 'incorrect source file for foo thread stack' ) ;
397
- }
398
- }
401
+ expect ( stackframes . body . stackFrames [ 2 ] . line ) . to . be . equal ( 10 ) ;
402
+ expect ( stackframes . body . stackFrames [ 2 ] . source ! . path ) . to . be . equal ( pythonFile ) ;
399
403
} ) ;
400
404
} ) ;
0 commit comments