@@ -9,31 +9,27 @@ 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' ;
12+ import { IInvalidPythonPathInDebuggerService } from '../../../../../client/application/diagnostics/types' ;
13+ import { IDocumentManager , IWorkspaceService } from '../../../../../client/common/application/types' ;
1514import { PYTHON_LANGUAGE } from '../../../../../client/common/constants' ;
16- import { IFileSystem , IPlatformService } from '../../../../../client/common/platform/types' ;
15+ import { IPlatformService } from '../../../../../client/common/platform/types' ;
1716import { IPythonExecutionFactory , IPythonExecutionService } from '../../../../../client/common/process/types' ;
18- import { IConfigurationService , ILogger , IPythonSettings } from '../../../../../client/common/types' ;
17+ import { IConfigurationService , IPythonSettings } from '../../../../../client/common/types' ;
1918import { DebuggerTypeName } from '../../../../../client/debugger/constants' ;
19+ import { IDebugEnvironmentVariablesService } from '../../../../../client/debugger/extension/configuration/resolvers/helper' ;
2020import { LaunchConfigurationResolver } from '../../../../../client/debugger/extension/configuration/resolvers/launch' ;
2121import { DebugOptions , LaunchRequestArguments } from '../../../../../client/debugger/types' ;
2222import { IInterpreterHelper } from '../../../../../client/interpreter/contracts' ;
23- import { IServiceContainer } from '../../../../../client/ioc/types' ;
2423
2524suite ( 'Debugging - Config Resolver Launch' , ( ) => {
26- let serviceContainer : TypeMoq . IMock < IServiceContainer > ;
2725 let debugProvider : DebugConfigurationProvider ;
2826 let platformService : TypeMoq . IMock < IPlatformService > ;
29- let fileSystem : TypeMoq . IMock < IFileSystem > ;
30- let appShell : TypeMoq . IMock < IApplicationShell > ;
3127 let pythonExecutionService : TypeMoq . IMock < IPythonExecutionService > ;
32- let logger : TypeMoq . IMock < ILogger > ;
3328 let helper : TypeMoq . IMock < IInterpreterHelper > ;
3429 let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
3530 let documentManager : TypeMoq . IMock < IDocumentManager > ;
3631 let diagnosticsService : TypeMoq . IMock < IInvalidPythonPathInDebuggerService > ;
32+ let debugEnvHelper : TypeMoq . IMock < IDebugEnvironmentVariablesService > ;
3733 function createMoqWorkspaceFolder ( folderPath : string ) {
3834 const folder = TypeMoq . Mock . ofType < WorkspaceFolder > ( ) ;
3935 folder . setup ( f => f . uri ) . returns ( ( ) => Uri . file ( folderPath ) ) ;
@@ -43,13 +39,10 @@ suite('Debugging - Config Resolver Launch', () => {
4339 const confgService = TypeMoq . Mock . ofType < IConfigurationService > ( ) ;
4440 workspaceService = TypeMoq . Mock . ofType < IWorkspaceService > ( ) ;
4541 documentManager = TypeMoq . Mock . ofType < IDocumentManager > ( ) ;
46- serviceContainer = TypeMoq . Mock . ofType < IServiceContainer > ( ) ;
4742
4843 platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
49- fileSystem = TypeMoq . Mock . ofType < IFileSystem > ( ) ;
50- appShell = TypeMoq . Mock . ofType < IApplicationShell > ( ) ;
51- logger = TypeMoq . Mock . ofType < ILogger > ( ) ;
5244 diagnosticsService = TypeMoq . Mock . ofType < IInvalidPythonPathInDebuggerService > ( ) ;
45+ debugEnvHelper = TypeMoq . Mock . ofType < IDebugEnvironmentVariablesService > ( ) ;
5346
5447 pythonExecutionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
5548 helper = TypeMoq . Mock . ofType < IInterpreterHelper > ( ) ;
@@ -61,24 +54,22 @@ suite('Debugging - Config Resolver Launch', () => {
6154 . setup ( h => h . validatePythonPath ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
6255 . returns ( ( ) => Promise . resolve ( true ) ) ;
6356
64- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IPythonExecutionFactory ) ) ) . returns ( ( ) => factory . object ) ;
65- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IConfigurationService ) ) ) . returns ( ( ) => confgService . object ) ;
66- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IPlatformService ) ) ) . returns ( ( ) => platformService . object ) ;
67- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IFileSystem ) ) ) . returns ( ( ) => fileSystem . object ) ;
68- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IApplicationShell ) ) ) . returns ( ( ) => appShell . object ) ;
69- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( ILogger ) ) ) . returns ( ( ) => logger . object ) ;
70- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IInterpreterHelper ) ) ) . returns ( ( ) => helper . object ) ;
71- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IDiagnosticsService ) , TypeMoq . It . isValue ( InvalidPythonPathInDebuggerServiceId ) ) ) . returns ( ( ) => diagnosticsService . object ) ;
72-
7357 const settings = TypeMoq . Mock . ofType < IPythonSettings > ( ) ;
7458 settings . setup ( s => s . pythonPath ) . returns ( ( ) => pythonPath ) ;
7559 if ( workspaceFolder ) {
7660 settings . setup ( s => s . envFile ) . returns ( ( ) => path . join ( workspaceFolder ! . uri . fsPath , '.env2' ) ) ;
7761 }
7862 confgService . setup ( c => c . getSettings ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => settings . object ) ;
7963 setupOs ( isWindows , isMac , isLinux ) ;
80-
81- debugProvider = new LaunchConfigurationResolver ( workspaceService . object , documentManager . object , diagnosticsService . object , platformService . object , confgService . object ) ;
64+ debugEnvHelper . setup ( x => x . getEnvironmentVariables ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => Promise . resolve ( { } ) ) ;
65+
66+ debugProvider = new LaunchConfigurationResolver (
67+ workspaceService . object ,
68+ documentManager . object ,
69+ diagnosticsService . object ,
70+ platformService . object ,
71+ confgService . object ,
72+ debugEnvHelper . object ) ;
8273 }
8374 function setupActiveEditor ( fileName : string | undefined , languageId : string ) {
8475 if ( fileName ) {
@@ -91,12 +82,10 @@ suite('Debugging - Config Resolver Launch', () => {
9182 } else {
9283 documentManager . setup ( d => d . activeTextEditor ) . returns ( ( ) => undefined ) ;
9384 }
94- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IDocumentManager ) ) ) . returns ( ( ) => documentManager . object ) ;
9585 }
9686 function setupWorkspaces ( folders : string [ ] ) {
9787 const workspaceFolders = folders . map ( createMoqWorkspaceFolder ) ;
9888 workspaceService . setup ( w => w . workspaceFolders ) . returns ( ( ) => workspaceFolders ) ;
99- serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IWorkspaceService ) ) ) . returns ( ( ) => workspaceService . object ) ;
10089 }
10190 function setupOs ( isWindows : boolean , isMac : boolean , isLinux : boolean ) {
10291 platformService . setup ( p => p . isWindows ) . returns ( ( ) => isWindows ) ;
0 commit comments