@@ -14,7 +14,7 @@ import { PYTHON_LANGUAGE } from '../../../client/common/constants';
1414import { EnumEx } from '../../../client/common/enumUtils' ;
1515import { IFileSystem , IPlatformService } from '../../../client/common/platform/types' ;
1616import { PythonDebugConfigurationProvider , PythonV2DebugConfigurationProvider } from '../../../client/debugger' ;
17- import { DebugOptions } from '../../../client/debugger/Common/Contracts' ;
17+ import { AttachRequestArguments , DebugOptions } from '../../../client/debugger/Common/Contracts' ;
1818import { IServiceContainer } from '../../../client/ioc/types' ;
1919
2020enum OS {
@@ -164,9 +164,44 @@ enum OS {
164164 const debugConfig = await debugProvider . resolveDebugConfiguration ! ( workspaceFolder , { localRoot, request : 'attach' } as any as DebugConfiguration ) ;
165165
166166 expect ( debugConfig ) . to . have . property ( 'localRoot' , localRoot ) ;
167- if ( provider . debugType === 'pythonExperimental' ) {
168- expect ( debugConfig ! . pathMappings ) . to . be . lengthOf ( 0 ) ;
169- }
167+ } ) ;
168+ [ 'localhost' , '127.0.0.1' , '::1' ] . forEach ( host => {
169+ test ( `Ensure path mappings are automatically added when host is '${ host } '` , async ( ) => {
170+ const activeFile = 'xyz.py' ;
171+ const workspaceFolder = createMoqWorkspaceFolder ( __dirname ) ;
172+ setupActiveEditor ( activeFile , PYTHON_LANGUAGE ) ;
173+ const defaultWorkspace = path . join ( 'usr' , 'desktop' ) ;
174+ setupWorkspaces ( [ defaultWorkspace ] ) ;
175+
176+ const localRoot = `Debug_PythonPath_${ new Date ( ) . toString ( ) } ` ;
177+ const debugConfig = await debugProvider . resolveDebugConfiguration ! ( workspaceFolder , { localRoot, host, request : 'attach' } as any as DebugConfiguration ) ;
178+
179+ expect ( debugConfig ) . to . have . property ( 'localRoot' , localRoot ) ;
180+ if ( provider . debugType === 'pythonExperimental' ) {
181+ const pathMappings = ( debugConfig as AttachRequestArguments ) . pathMappings ;
182+ expect ( pathMappings ) . to . be . lengthOf ( 1 ) ;
183+ expect ( pathMappings ! [ 0 ] . localRoot ) . to . be . equal ( workspaceFolder . uri . fsPath ) ;
184+ expect ( pathMappings ! [ 0 ] . remoteRoot ) . to . be . equal ( workspaceFolder . uri . fsPath ) ;
185+ }
186+ } ) ;
187+ } ) ;
188+ [ '192.168.1.123' , 'don.debugger.com' ] . forEach ( host => {
189+ test ( `Ensure path mappings are not automatically added when host is '${ host } '` , async ( ) => {
190+ const activeFile = 'xyz.py' ;
191+ const workspaceFolder = createMoqWorkspaceFolder ( __dirname ) ;
192+ setupActiveEditor ( activeFile , PYTHON_LANGUAGE ) ;
193+ const defaultWorkspace = path . join ( 'usr' , 'desktop' ) ;
194+ setupWorkspaces ( [ defaultWorkspace ] ) ;
195+
196+ const localRoot = `Debug_PythonPath_${ new Date ( ) . toString ( ) } ` ;
197+ const debugConfig = await debugProvider . resolveDebugConfiguration ! ( workspaceFolder , { localRoot, host, request : 'attach' } as any as DebugConfiguration ) ;
198+
199+ expect ( debugConfig ) . to . have . property ( 'localRoot' , localRoot ) ;
200+ if ( provider . debugType === 'pythonExperimental' ) {
201+ const pathMappings = ( debugConfig as AttachRequestArguments ) . pathMappings ;
202+ expect ( pathMappings ) . to . be . lengthOf ( 0 ) ;
203+ }
204+ } ) ;
170205 } ) ;
171206 test ( 'Ensure \'localRoot\' and \'remoteRoot\' is used' , async function ( ) {
172207 if ( provider . debugType !== 'pythonExperimental' ) {
0 commit comments