14
14
15
15
import * as util from "../../../src/utilities/utilities" ;
16
16
import * as lldb from "../../../src/debugger/lldb" ;
17
- import * as sinon from "sinon" ;
18
17
import * as vscode from "vscode" ;
19
18
import { expect } from "chai" ;
20
19
import {
@@ -23,20 +22,24 @@ import {
23
22
mockFn ,
24
23
mockGlobalModule ,
25
24
mockObject ,
26
- MockedFunction ,
27
25
mockGlobalValue ,
28
26
} from "../../MockUtils" ;
29
27
import { SwiftToolchain } from "../../../src/toolchain/toolchain" ;
30
28
31
29
suite ( "debugger.lldb Tests" , ( ) => {
30
+ const wsMock = mockGlobalValue ( vscode . workspace , "fs" ) ;
31
+ const fsMock = mockObject < vscode . FileSystem > ( { readDirectory : mockFn ( ) , stat : mockFn ( ) } ) ;
32
+
33
+ setup ( ( ) => {
34
+ wsMock . setValue ( fsMock ) ;
35
+ } ) ;
36
+
32
37
suite ( "getLLDBLibPath Tests" , ( ) => {
33
38
let mockToolchain : MockedObject < SwiftToolchain > ;
34
- let mockFindLibLLDB : MockedFunction < ( typeof lldb ) [ "findLibLLDB" ] > ;
35
39
const mockedPlatform = mockGlobalValue ( process , "platform" ) ;
36
40
const mockUtil = mockGlobalModule ( util ) ;
37
41
38
42
setup ( ( ) => {
39
- mockFindLibLLDB = sinon . stub ( ) ;
40
43
mockToolchain = mockObject < SwiftToolchain > ( {
41
44
getLLDB : mockFn ( ) ,
42
45
swiftFolderPath : "" ,
@@ -62,14 +65,9 @@ suite("debugger.lldb Tests", () => {
62
65
test ( "should return failure if findLibLLDB returns falsy values" , async ( ) => {
63
66
mockToolchain . getLLDB . resolves ( "/path/to/lldb" ) ;
64
67
mockUtil . execFile . resolves ( { stdout : "" , stderr : "" } ) ;
65
- mockFindLibLLDB . onFirstCall ( ) . resolves ( undefined ) ;
66
-
67
- let result = await lldb . getLLDBLibPath ( instance ( mockToolchain ) ) ;
68
- expect ( result . failure ) . to . not . equal ( undefined ) ;
69
-
70
- mockFindLibLLDB . onSecondCall ( ) . resolves ( "" ) ;
68
+ fsMock . stat . resolves ( { type : vscode . FileType . Directory } as any ) ;
71
69
72
- result = await lldb . getLLDBLibPath ( instance ( mockToolchain ) ) ;
70
+ const result = await lldb . getLLDBLibPath ( instance ( mockToolchain ) ) ;
73
71
expect ( result . failure ) . to . not . equal ( undefined ) ;
74
72
} ) ;
75
73
// NB(separate itest): contract test with toolchains of various platforms
@@ -106,13 +104,6 @@ suite("debugger.lldb Tests", () => {
106
104
} ) ;
107
105
108
106
suite ( "findFileByPattern Tests" , ( ) => {
109
- const wsMock = mockGlobalValue ( vscode . workspace , "fs" ) ;
110
- const fsMock = mockObject < vscode . FileSystem > ( { readDirectory : mockFn ( ) , stat : mockFn ( ) } ) ;
111
-
112
- setup ( ( ) => {
113
- wsMock . setValue ( fsMock ) ;
114
- } ) ;
115
-
116
107
test ( "should return null if no file matches the pattern" , async ( ) => {
117
108
fsMock . readDirectory . resolves ( [
118
109
[ "file1" , vscode . FileType . File ] ,
0 commit comments