@@ -9,6 +9,7 @@ import { ChildProcessAttachEventHandler } from '../../../../client/debugger/exte
99import { ChildProcessAttachService } from '../../../../client/debugger/extension/hooks/childProcessAttachService' ;
1010import { DebuggerEvents } from '../../../../client/debugger/extension/hooks/constants' ;
1111import { AttachRequestArguments } from '../../../../client/debugger/types' ;
12+ import { DebuggerTypeName } from '../../../../client/debugger/constants' ;
1213
1314suite ( 'Debug - Child Process' , ( ) => {
1415 test ( 'Do not attach if the event is undefined' , async ( ) => {
@@ -21,23 +22,31 @@ suite('Debug - Child Process', () => {
2122 const attachService = mock ( ChildProcessAttachService ) ;
2223 const handler = new ChildProcessAttachEventHandler ( instance ( attachService ) ) ;
2324 const body : any = { } ;
24- const session : any = { } ;
25+ const session : any = { configuration : { type : DebuggerTypeName } } ;
26+ await handler . handleCustomEvent ( { event : 'abc' , body, session } ) ;
27+ verify ( attachService . attach ( body , session ) ) . never ( ) ;
28+ } ) ;
29+ test ( 'Do not attach to child process if debugger type is different' , async ( ) => {
30+ const attachService = mock ( ChildProcessAttachService ) ;
31+ const handler = new ChildProcessAttachEventHandler ( instance ( attachService ) ) ;
32+ const body : any = { } ;
33+ const session : any = { configuration : { type : 'other-type' } } ;
2534 await handler . handleCustomEvent ( { event : 'abc' , body, session } ) ;
2635 verify ( attachService . attach ( body , session ) ) . never ( ) ;
2736 } ) ;
2837 test ( 'Do not attach to child process if ptvsd_attach event is invalid' , async ( ) => {
2938 const attachService = mock ( ChildProcessAttachService ) ;
3039 const handler = new ChildProcessAttachEventHandler ( instance ( attachService ) ) ;
3140 const body : any = { } ;
32- const session : any = { } ;
41+ const session : any = { configuration : { type : DebuggerTypeName } } ;
3342 await handler . handleCustomEvent ( { event : DebuggerEvents . PtvsdAttachToSubprocess , body, session } ) ;
3443 verify ( attachService . attach ( body , session ) ) . never ( ) ;
3544 } ) ;
3645 test ( 'Do not attach to child process if debugpy_attach event is invalid' , async ( ) => {
3746 const attachService = mock ( ChildProcessAttachService ) ;
3847 const handler = new ChildProcessAttachEventHandler ( instance ( attachService ) ) ;
3948 const body : any = { } ;
40- const session : any = { } ;
49+ const session : any = { configuration : { type : DebuggerTypeName } } ;
4150 await handler . handleCustomEvent ( { event : DebuggerEvents . DebugpyAttachToSubprocess , body, session } ) ;
4251 verify ( attachService . attach ( body , session ) ) . never ( ) ;
4352 } ) ;
@@ -51,9 +60,11 @@ suite('Debug - Child Process', () => {
5160 port : 1234 ,
5261 subProcessId : 2 ,
5362 } ;
54- const session : any = { } ;
63+ const session : any = {
64+ configuration : { type : DebuggerTypeName } ,
65+ } ;
5566 when ( attachService . attach ( body , session ) ) . thenThrow ( new Error ( 'Kaboom' ) ) ;
56- await handler . handleCustomEvent ( { event : DebuggerEvents . DebugpyAttachToSubprocess , body, session : { } as any } ) ;
67+ await handler . handleCustomEvent ( { event : DebuggerEvents . DebugpyAttachToSubprocess , body, session } ) ;
5768 verify ( attachService . attach ( body , anything ( ) ) ) . once ( ) ;
5869 const [ , secondArg ] = capture ( attachService . attach ) . last ( ) ;
5970 expect ( secondArg ) . to . deep . equal ( session ) ;
0 commit comments