@@ -9,27 +9,31 @@ 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 { IInvalidPythonPathInDebuggerService } from '../../../../../client/application/diagnostics/types' ;
13
- import { IDocumentManager , IWorkspaceService } from '../../../../../client/common/application/types' ;
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' ;
14
15
import { PYTHON_LANGUAGE } from '../../../../../client/common/constants' ;
15
- import { IPlatformService } from '../../../../../client/common/platform/types' ;
16
+ import { IFileSystem , IPlatformService } from '../../../../../client/common/platform/types' ;
16
17
import { IPythonExecutionFactory , IPythonExecutionService } from '../../../../../client/common/process/types' ;
17
- import { IConfigurationService , IPythonSettings } from '../../../../../client/common/types' ;
18
+ import { IConfigurationService , ILogger , IPythonSettings } from '../../../../../client/common/types' ;
18
19
import { DebuggerTypeName } from '../../../../../client/debugger/constants' ;
19
- import { IDebugEnvironmentVariablesService } from '../../../../../client/debugger/extension/configuration/resolvers/helper' ;
20
20
import { LaunchConfigurationResolver } from '../../../../../client/debugger/extension/configuration/resolvers/launch' ;
21
21
import { DebugOptions , LaunchRequestArguments } from '../../../../../client/debugger/types' ;
22
22
import { IInterpreterHelper } from '../../../../../client/interpreter/contracts' ;
23
+ import { IServiceContainer } from '../../../../../client/ioc/types' ;
23
24
24
25
suite ( 'Debugging - Config Resolver Launch' , ( ) => {
26
+ let serviceContainer : TypeMoq . IMock < IServiceContainer > ;
25
27
let debugProvider : DebugConfigurationProvider ;
26
28
let platformService : TypeMoq . IMock < IPlatformService > ;
29
+ let fileSystem : TypeMoq . IMock < IFileSystem > ;
30
+ let appShell : TypeMoq . IMock < IApplicationShell > ;
27
31
let pythonExecutionService : TypeMoq . IMock < IPythonExecutionService > ;
32
+ let logger : TypeMoq . IMock < ILogger > ;
28
33
let helper : TypeMoq . IMock < IInterpreterHelper > ;
29
34
let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
30
35
let documentManager : TypeMoq . IMock < IDocumentManager > ;
31
36
let diagnosticsService : TypeMoq . IMock < IInvalidPythonPathInDebuggerService > ;
32
- let debugEnvHelper : TypeMoq . IMock < IDebugEnvironmentVariablesService > ;
33
37
function createMoqWorkspaceFolder ( folderPath : string ) {
34
38
const folder = TypeMoq . Mock . ofType < WorkspaceFolder > ( ) ;
35
39
folder . setup ( f => f . uri ) . returns ( ( ) => Uri . file ( folderPath ) ) ;
@@ -39,10 +43,13 @@ suite('Debugging - Config Resolver Launch', () => {
39
43
const confgService = TypeMoq . Mock . ofType < IConfigurationService > ( ) ;
40
44
workspaceService = TypeMoq . Mock . ofType < IWorkspaceService > ( ) ;
41
45
documentManager = TypeMoq . Mock . ofType < IDocumentManager > ( ) ;
46
+ serviceContainer = TypeMoq . Mock . ofType < IServiceContainer > ( ) ;
42
47
43
48
platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
49
+ fileSystem = TypeMoq . Mock . ofType < IFileSystem > ( ) ;
50
+ appShell = TypeMoq . Mock . ofType < IApplicationShell > ( ) ;
51
+ logger = TypeMoq . Mock . ofType < ILogger > ( ) ;
44
52
diagnosticsService = TypeMoq . Mock . ofType < IInvalidPythonPathInDebuggerService > ( ) ;
45
- debugEnvHelper = TypeMoq . Mock . ofType < IDebugEnvironmentVariablesService > ( ) ;
46
53
47
54
pythonExecutionService = TypeMoq . Mock . ofType < IPythonExecutionService > ( ) ;
48
55
helper = TypeMoq . Mock . ofType < IInterpreterHelper > ( ) ;
@@ -54,22 +61,24 @@ suite('Debugging - Config Resolver Launch', () => {
54
61
. setup ( h => h . validatePythonPath ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
55
62
. returns ( ( ) => Promise . resolve ( true ) ) ;
56
63
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
+
57
73
const settings = TypeMoq . Mock . ofType < IPythonSettings > ( ) ;
58
74
settings . setup ( s => s . pythonPath ) . returns ( ( ) => pythonPath ) ;
59
75
if ( workspaceFolder ) {
60
76
settings . setup ( s => s . envFile ) . returns ( ( ) => path . join ( workspaceFolder ! . uri . fsPath , '.env2' ) ) ;
61
77
}
62
78
confgService . setup ( c => c . getSettings ( TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => settings . object ) ;
63
79
setupOs ( isWindows , isMac , isLinux ) ;
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 ) ;
80
+
81
+ debugProvider = new LaunchConfigurationResolver ( workspaceService . object , documentManager . object , diagnosticsService . object , platformService . object , confgService . object ) ;
73
82
}
74
83
function setupActiveEditor ( fileName : string | undefined , languageId : string ) {
75
84
if ( fileName ) {
@@ -82,10 +91,12 @@ suite('Debugging - Config Resolver Launch', () => {
82
91
} else {
83
92
documentManager . setup ( d => d . activeTextEditor ) . returns ( ( ) => undefined ) ;
84
93
}
94
+ serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IDocumentManager ) ) ) . returns ( ( ) => documentManager . object ) ;
85
95
}
86
96
function setupWorkspaces ( folders : string [ ] ) {
87
97
const workspaceFolders = folders . map ( createMoqWorkspaceFolder ) ;
88
98
workspaceService . setup ( w => w . workspaceFolders ) . returns ( ( ) => workspaceFolders ) ;
99
+ serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IWorkspaceService ) ) ) . returns ( ( ) => workspaceService . object ) ;
89
100
}
90
101
function setupOs ( isWindows : boolean , isMac : boolean , isLinux : boolean ) {
91
102
platformService . setup ( p => p . isWindows ) . returns ( ( ) => isWindows ) ;
0 commit comments