@@ -9,22 +9,22 @@ import { expect } from 'chai';
9
9
import * as path from 'path' ;
10
10
import * as TypeMoq from 'typemoq' ;
11
11
import { 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' , ( ) => {
28
28
let serviceContainer : TypeMoq . IMock < IServiceContainer > ;
29
29
let debugProvider : DebugConfigurationProvider ;
30
30
let platformService : TypeMoq . IMock < IPlatformService > ;
@@ -60,6 +60,7 @@ suite('Debugging - Config Provider', () => {
60
60
diagnosticsService
61
61
. setup ( h => h . validatePythonPath ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
62
62
. returns ( ( ) => Promise . resolve ( true ) ) ;
63
+ const pythonSettings = TypeMoq . Mock . ofType < IPythonSettings > ( ) ;
63
64
64
65
serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IPythonExecutionFactory ) ) ) . returns ( ( ) => factory . object ) ;
65
66
serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IConfigurationService ) ) ) . returns ( ( ) => confgService . object ) ;
@@ -449,4 +450,28 @@ suite('Debugging - Config Provider', () => {
449
450
diagnosticsService . verifyAll ( ) ;
450
451
expect ( debugConfig ) . to . not . be . equal ( undefined , 'is undefined' ) ;
451
452
} ) ;
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
+ } ) ;
452
477
} ) ;
0 commit comments