@@ -9,22 +9,22 @@ import { expect } from 'chai';
99import * as path from 'path' ;
1010import * as TypeMoq from 'typemoq' ;
1111import { DebugConfiguration , DebugConfigurationProvider , TextDocument , TextEditor , Uri , WorkspaceFolder } from 'vscode' ;
12- import { InvalidPythonPathInDebuggerServiceId } from '../../../client/application/diagnostics/checks/invalidPythonPathInDebugger' ;
13- import { IDiagnosticsService , IInvalidPythonPathInDebuggerService } from '../../../client/application/diagnostics/types' ;
14- import { IApplicationShell , IDocumentManager , IWorkspaceService } from '../../../client/common/application/types' ;
15- import { PYTHON_LANGUAGE } from '../../../client/common/constants' ;
16- import { IFileSystem , IPlatformService } from '../../../client/common/platform/types' ;
17- import { IPythonExecutionFactory , IPythonExecutionService } from '../../../client/common/process/types' ;
18- import { IConfigurationService , ILogger , IPythonSettings } from '../../../client/common/types' ;
19- import { DebuggerTypeName } from '../../../client/debugger/constants' ;
20- import { ConfigurationProviderUtils } from '../../../client/debugger/extension/configProviders/configurationProviderUtils' ;
21- import { PythonV2DebugConfigurationProvider } from '../../../client/debugger/extension/configProviders/pythonV2Provider' ;
22- import { IConfigurationProviderUtils } from '../../../client/debugger/extension/configProviders/types' ;
23- import { DebugOptions , LaunchRequestArguments } from '../../../client/debugger/types' ;
24- import { IInterpreterHelper } from '../../../client/interpreter/contracts' ;
25- import { IServiceContainer } from '../../../client/ioc/types' ;
26-
27- suite ( 'Debugging - Config Provider' , ( ) => {
12+ import { InvalidPythonPathInDebuggerServiceId } from '../../../../ client/application/diagnostics/checks/invalidPythonPathInDebugger' ;
13+ import { IDiagnosticsService , IInvalidPythonPathInDebuggerService } from '../../../../ client/application/diagnostics/types' ;
14+ import { IApplicationShell , IDocumentManager , IWorkspaceService } from '../../../../ client/common/application/types' ;
15+ import { PYTHON_LANGUAGE } from '../../../../ client/common/constants' ;
16+ import { IFileSystem , IPlatformService } from '../../../../ client/common/platform/types' ;
17+ import { IPythonExecutionFactory , IPythonExecutionService } from '../../../../ client/common/process/types' ;
18+ import { IConfigurationService , ILogger , IPythonSettings } from '../../../../ client/common/types' ;
19+ import { DebuggerTypeName } from '../../../../ client/debugger/constants' ;
20+ import { ConfigurationProviderUtils } from '../../../../ client/debugger/extension/configProviders/configurationProviderUtils' ;
21+ import { PythonV2DebugConfigurationProvider } from '../../../../ client/debugger/extension/configProviders/pythonV2Provider' ;
22+ import { IConfigurationProviderUtils } from '../../../../ client/debugger/extension/configProviders/types' ;
23+ import { DebugOptions , LaunchRequestArguments } from '../../../../ client/debugger/types' ;
24+ import { IInterpreterHelper } from '../../../../ client/interpreter/contracts' ;
25+ import { IServiceContainer } from '../../../../ client/ioc/types' ;
26+
27+ suite ( 'Debuggingx - Config Provider' , ( ) => {
2828 let serviceContainer : TypeMoq . IMock < IServiceContainer > ;
2929 let debugProvider : DebugConfigurationProvider ;
3030 let platformService : TypeMoq . IMock < IPlatformService > ;
@@ -60,6 +60,7 @@ suite('Debugging - Config Provider', () => {
6060 diagnosticsService
6161 . setup ( h => h . validatePythonPath ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
6262 . returns ( ( ) => Promise . resolve ( true ) ) ;
63+ const pythonSettings = TypeMoq . Mock . ofType < IPythonSettings > ( ) ;
6364
6465 serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IPythonExecutionFactory ) ) ) . returns ( ( ) => factory . object ) ;
6566 serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IConfigurationService ) ) ) . returns ( ( ) => confgService . object ) ;
@@ -449,4 +450,28 @@ suite('Debugging - Config Provider', () => {
449450 diagnosticsService . verifyAll ( ) ;
450451 expect ( debugConfig ) . to . not . be . equal ( undefined , 'is undefined' ) ;
451452 } ) ;
453+ async function testSetting ( requestType : 'launch' | 'attach' , settings : { [ key : string ] : boolean } , debugOptionName : DebugOptions , mustHaveDebugOption : boolean ) {
454+ setupIoc ( 'pythonPath' ) ;
455+ const debugConfiguration : DebugConfiguration = { request : requestType , type : 'python' , name : '' , ...settings } ;
456+ const workspaceFolder = createMoqWorkspaceFolder ( __dirname ) ;
457+
458+
459+ const debugConfig = await debugProvider . resolveDebugConfiguration ! ( workspaceFolder , debugConfiguration ) ;
460+ if ( mustHaveDebugOption ) {
461+ expect ( ( debugConfig as any ) . debugOptions ) . contains ( debugOptionName ) ;
462+ } else {
463+ expect ( ( debugConfig as any ) . debugOptions ) . not . contains ( debugOptionName ) ;
464+ }
465+ }
466+ [ 'launch' , 'attach' ] . forEach ( ( requestType : 'launch' | 'attach' ) => {
467+ test ( `Must not contain Sub Process when not specified (${ requestType } )` , async ( ) => {
468+ await testSetting ( requestType , { } , DebugOptions . SubProcess , false ) ;
469+ } ) ;
470+ test ( `Must not contain Sub Process setting=false (${ requestType } )` , async ( ) => {
471+ await testSetting ( requestType , { subProcess : false } , DebugOptions . SubProcess , false ) ;
472+ } ) ;
473+ test ( `Must not contain Sub Process setting=true (${ requestType } )` , async ( ) => {
474+ await testSetting ( requestType , { subProcess : true } , DebugOptions . SubProcess , true ) ;
475+ } ) ;
476+ } ) ;
452477} ) ;
0 commit comments