@@ -29,7 +29,7 @@ const mockWorkspaceContextService = {
29
29
}
30
30
} as any ;
31
31
32
- export function createMockSession ( model : DebugModel , name = 'mockSession' , options ?: IDebugSessionOptions ) : DebugSession {
32
+ export function createTestSession ( model : DebugModel , name = 'mockSession' , options ?: IDebugSessionOptions ) : DebugSession {
33
33
return new DebugSession ( generateUuid ( ) , { resolved : { name, type : 'node' , request : 'launch' } , unresolved : undefined } , undefined ! , model , options , {
34
34
getViewModel ( ) : any {
35
35
return {
@@ -79,7 +79,7 @@ suite('Debug - CallStack', () => {
79
79
test ( 'threads simple' , ( ) => {
80
80
const threadId = 1 ;
81
81
const threadName = 'firstThread' ;
82
- const session = createMockSession ( model ) ;
82
+ const session = createTestSession ( model ) ;
83
83
model . addSession ( session ) ;
84
84
85
85
assert . strictEqual ( model . getSessions ( true ) . length , 1 ) ;
@@ -98,15 +98,15 @@ suite('Debug - CallStack', () => {
98
98
assert . strictEqual ( model . getSessions ( true ) . length , 1 ) ;
99
99
} ) ;
100
100
101
- test ( 'threads multiple wtih allThreadsStopped' , async ( ) => {
101
+ test ( 'threads multiple with allThreadsStopped' , async ( ) => {
102
102
const threadId1 = 1 ;
103
103
const threadName1 = 'firstThread' ;
104
104
const threadId2 = 2 ;
105
105
const threadName2 = 'secondThread' ;
106
106
const stoppedReason = 'breakpoint' ;
107
107
108
108
// Add the threads
109
- const session = createMockSession ( model ) ;
109
+ const session = createTestSession ( model ) ;
110
110
model . addSession ( session ) ;
111
111
112
112
session [ 'raw' ] = < any > rawSession ;
@@ -178,15 +178,68 @@ suite('Debug - CallStack', () => {
178
178
assert . strictEqual ( session . getAllThreads ( ) . length , 0 ) ;
179
179
} ) ;
180
180
181
- test ( 'threads mutltiple without allThreadsStopped' , async ( ) => {
181
+ test ( 'allThreadsStopped in multiple events' , async ( ) => {
182
+ const threadId1 = 1 ;
183
+ const threadName1 = 'firstThread' ;
184
+ const threadId2 = 2 ;
185
+ const threadName2 = 'secondThread' ;
186
+ const stoppedReason = 'breakpoint' ;
187
+
188
+ // Add the threads
189
+ const session = createTestSession ( model ) ;
190
+ model . addSession ( session ) ;
191
+
192
+ session [ 'raw' ] = < any > rawSession ;
193
+
194
+ // Stopped event with all threads stopped
195
+ model . rawUpdate ( {
196
+ sessionId : session . getId ( ) ,
197
+ threads : [ {
198
+ id : threadId1 ,
199
+ name : threadName1
200
+ } , {
201
+ id : threadId2 ,
202
+ name : threadName2
203
+ } ] ,
204
+ stoppedDetails : {
205
+ reason : stoppedReason ,
206
+ threadId : threadId1 ,
207
+ allThreadsStopped : true
208
+ } ,
209
+ } ) ;
210
+
211
+ model . rawUpdate ( {
212
+ sessionId : session . getId ( ) ,
213
+ threads : [ {
214
+ id : threadId1 ,
215
+ name : threadName1
216
+ } , {
217
+ id : threadId2 ,
218
+ name : threadName2
219
+ } ] ,
220
+ stoppedDetails : {
221
+ reason : stoppedReason ,
222
+ threadId : threadId2 ,
223
+ allThreadsStopped : true
224
+ } ,
225
+ } ) ;
226
+
227
+ const thread1 = session . getThread ( threadId1 ) ! ;
228
+ const thread2 = session . getThread ( threadId2 ) ! ;
229
+
230
+ assert . strictEqual ( thread1 . stoppedDetails ?. reason , stoppedReason ) ;
231
+ assert . strictEqual ( thread2 . stoppedDetails ?. reason , stoppedReason ) ;
232
+ } ) ;
233
+
234
+ test ( 'threads multiple without allThreadsStopped' , async ( ) => {
182
235
const sessionStub = sinon . spy ( rawSession , 'stackTrace' ) ;
183
236
184
237
const stoppedThreadId = 1 ;
185
238
const stoppedThreadName = 'stoppedThread' ;
186
239
const runningThreadId = 2 ;
187
240
const runningThreadName = 'runningThread' ;
188
241
const stoppedReason = 'breakpoint' ;
189
- const session = createMockSession ( model ) ;
242
+ const session = createTestSession ( model ) ;
190
243
model . addSession ( session ) ;
191
244
192
245
session [ 'raw' ] = < any > rawSession ;
@@ -258,7 +311,7 @@ suite('Debug - CallStack', () => {
258
311
} ) ;
259
312
260
313
test ( 'stack frame get specific source name' , ( ) => {
261
- const session = createMockSession ( model ) ;
314
+ const session = createTestSession ( model ) ;
262
315
model . addSession ( session ) ;
263
316
const { firstStackFrame, secondStackFrame } = createTwoStackFrames ( session ) ;
264
317
@@ -267,7 +320,7 @@ suite('Debug - CallStack', () => {
267
320
} ) ;
268
321
269
322
test ( 'stack frame toString()' , ( ) => {
270
- const session = createMockSession ( model ) ;
323
+ const session = createTestSession ( model ) ;
271
324
const thread = new Thread ( session , 'mockthread' , 1 ) ;
272
325
const firstSource = new Source ( {
273
326
name : 'internalModule.js' ,
@@ -283,17 +336,17 @@ suite('Debug - CallStack', () => {
283
336
} ) ;
284
337
285
338
test ( 'debug child sessions are added in correct order' , ( ) => {
286
- const session = createMockSession ( model ) ;
339
+ const session = createTestSession ( model ) ;
287
340
model . addSession ( session ) ;
288
- const secondSession = createMockSession ( model , 'mockSession2' ) ;
341
+ const secondSession = createTestSession ( model , 'mockSession2' ) ;
289
342
model . addSession ( secondSession ) ;
290
- const firstChild = createMockSession ( model , 'firstChild' , { parentSession : session } ) ;
343
+ const firstChild = createTestSession ( model , 'firstChild' , { parentSession : session } ) ;
291
344
model . addSession ( firstChild ) ;
292
- const secondChild = createMockSession ( model , 'secondChild' , { parentSession : session } ) ;
345
+ const secondChild = createTestSession ( model , 'secondChild' , { parentSession : session } ) ;
293
346
model . addSession ( secondChild ) ;
294
- const thirdSession = createMockSession ( model , 'mockSession3' ) ;
347
+ const thirdSession = createTestSession ( model , 'mockSession3' ) ;
295
348
model . addSession ( thirdSession ) ;
296
- const anotherChild = createMockSession ( model , 'secondChild' , { parentSession : secondSession } ) ;
349
+ const anotherChild = createTestSession ( model , 'secondChild' , { parentSession : secondSession } ) ;
297
350
model . addSession ( anotherChild ) ;
298
351
299
352
const sessions = model . getSessions ( ) ;
@@ -306,7 +359,7 @@ suite('Debug - CallStack', () => {
306
359
} ) ;
307
360
308
361
test ( 'decorations' , ( ) => {
309
- const session = createMockSession ( model ) ;
362
+ const session = createTestSession ( model ) ;
310
363
model . addSession ( session ) ;
311
364
const { firstStackFrame, secondStackFrame } = createTwoStackFrames ( session ) ;
312
365
let decorations = createDecorationsForStackFrame ( firstStackFrame , true , false ) ;
@@ -338,7 +391,7 @@ suite('Debug - CallStack', () => {
338
391
} ) ;
339
392
340
393
test ( 'contexts' , ( ) => {
341
- const session = createMockSession ( model ) ;
394
+ const session = createTestSession ( model ) ;
342
395
model . addSession ( session ) ;
343
396
const { firstStackFrame, secondStackFrame } = createTwoStackFrames ( session ) ;
344
397
let context = getContext ( firstStackFrame ) ;
@@ -378,7 +431,7 @@ suite('Debug - CallStack', () => {
378
431
}
379
432
} ( generateUuid ( ) , { resolved : { name : 'stoppedSession' , type : 'node' , request : 'launch' } , unresolved : undefined } , undefined ! , model , undefined , undefined ! , undefined ! , undefined ! , undefined ! , undefined ! , mockWorkspaceContextService , undefined ! , undefined ! , undefined ! , mockUriIdentityService , new TestInstantiationService ( ) , undefined ! , undefined ! ) ;
380
433
381
- const runningSession = createMockSession ( model ) ;
434
+ const runningSession = createTestSession ( model ) ;
382
435
model . addSession ( runningSession ) ;
383
436
model . addSession ( session ) ;
384
437
0 commit comments