1212//
1313//===----------------------------------------------------------------------===//
1414import { expect } from "chai" ;
15+ import * as path from "path" ;
1516import * as sinon from "sinon" ;
1617import * as vscode from "vscode" ;
1718
@@ -64,49 +65,59 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
6465
6566 const result = localSchemaPath ( mockFolderContext ) ;
6667
67- expect ( result ) . to . equal ( "/path/to/toolchain/share/sourcekit-lsp/config.schema.json" ) ;
68+ expect ( result ) . to . equal (
69+ path . normalize ( "/path/to/toolchain/share/sourcekit-lsp/config.schema.json" )
70+ ) ;
6871 } ) ;
6972
7073 test ( "returns correct path for toolchain with trailing slash" , ( ) => {
7174 mockFolderContext = createMockFolderContext (
72- "/path/to/toolchain/" ,
75+ path . normalize ( "/path/to/toolchain/" ) ,
7376 new Version ( 6 , 3 , 0 )
7477 ) ;
7578
7679 const result = localSchemaPath ( mockFolderContext ) ;
7780
78- expect ( result ) . to . equal ( "/path/to/toolchain/share/sourcekit-lsp/config.schema.json" ) ;
81+ expect ( result ) . to . equal (
82+ path . normalize ( "/path/to/toolchain/share/sourcekit-lsp/config.schema.json" )
83+ ) ;
7984 } ) ;
8085
8186 test ( "returns correct path for nested toolchain directory" , ( ) => {
8287 mockFolderContext = createMockFolderContext (
83- "/usr/local/swift-6.3.0" ,
88+ path . normalize ( "/usr/local/swift-6.3.0" ) ,
8489 new Version ( 6 , 3 , 0 )
8590 ) ;
8691
8792 const result = localSchemaPath ( mockFolderContext ) ;
8893
8994 expect ( result ) . to . equal (
90- "/usr/local/swift-6.3.0/share/sourcekit-lsp/config.schema.json"
95+ path . normalize ( "/usr/local/swift-6.3.0/share/sourcekit-lsp/config.schema.json" )
9196 ) ;
9297 } ) ;
9398 } ) ;
9499
95100 suite ( "hasLocalSchema()" , ( ) => {
96101 test ( "returns true when schema file exists" , async ( ) => {
97- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 6 , 3 , 0 ) ) ;
102+ mockFolderContext = createMockFolderContext (
103+ path . normalize ( "/path/to/toolchain" ) ,
104+ new Version ( 6 , 3 , 0 )
105+ ) ;
98106 fileExistsStub . resolves ( true ) ;
99107
100108 const result = await hasLocalSchema ( mockFolderContext ) ;
101109
102110 expect ( result ) . to . be . true ;
103111 expect ( fileExistsStub ) . to . have . been . calledWith (
104- "/path/to/toolchain/share/sourcekit-lsp/config.schema.json"
112+ path . normalize ( "/path/to/toolchain/share/sourcekit-lsp/config.schema.json" )
105113 ) ;
106114 } ) ;
107115
108116 test ( "returns false when schema file doesn't exist" , async ( ) => {
109- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 6 , 1 , 0 ) ) ;
117+ mockFolderContext = createMockFolderContext (
118+ path . normalize ( "/path/to/toolchain" ) ,
119+ new Version ( 6 , 1 , 0 )
120+ ) ;
110121 fileExistsStub . resolves ( false ) ;
111122
112123 const result = await hasLocalSchema ( mockFolderContext ) ;
@@ -137,7 +148,10 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
137148 } ) ;
138149
139150 test ( "returns https:// URL when local schema doesn't exist" , async ( ) => {
140- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 6 , 1 , 0 ) ) ;
151+ mockFolderContext = createMockFolderContext (
152+ path . normalize ( "/path/to/toolchain" ) ,
153+ new Version ( 6 , 1 , 0 )
154+ ) ;
141155 fileExistsStub . resolves ( false ) ;
142156
143157 const result = await determineSchemaURL ( mockFolderContext ) ;
@@ -149,19 +163,22 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
149163
150164 test ( "local schema path includes share/sourcekit-lsp/config.schema.json" , async ( ) => {
151165 mockFolderContext = createMockFolderContext (
152- "/usr/local/swift-6.3" ,
166+ path . normalize ( "/usr/local/swift-6.3" ) ,
153167 new Version ( 6 , 3 , 0 )
154168 ) ;
155169 fileExistsStub . resolves ( true ) ;
156170
157171 const result = await determineSchemaURL ( mockFolderContext ) ;
158172
159- expect ( result ) . to . include ( "/usr/local/swift-6.3" ) ;
160- expect ( result ) . to . include ( "share/sourcekit-lsp/config.schema.json" ) ;
173+ expect ( result ) . to . include ( path . normalize ( "/usr/local/swift-6.3" ) ) ;
174+ expect ( result ) . to . include ( path . normalize ( "share/sourcekit-lsp/config.schema.json" ) ) ;
161175 } ) ;
162176
163177 test ( "remote URL uses correct branch for release version" , async ( ) => {
164- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 6 , 2 , 0 ) ) ;
178+ mockFolderContext = createMockFolderContext (
179+ path . normalize ( "/path/to/toolchain" ) ,
180+ new Version ( 6 , 2 , 0 )
181+ ) ;
165182 fileExistsStub . resolves ( false ) ;
166183
167184 const fetchStub = sandbox . stub ( globalThis , "fetch" ) ;
@@ -177,7 +194,7 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
177194
178195 test ( "remote URL uses main for dev version" , async ( ) => {
179196 mockFolderContext = createMockFolderContext (
180- "/path/to/toolchain" ,
197+ path . normalize ( "/path/to/toolchain" ) ,
181198 new Version ( 6 , 3 , 0 , true )
182199 ) ;
183200 fileExistsStub . resolves ( false ) ;
@@ -194,7 +211,10 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
194211 } ) ;
195212
196213 test ( "falls back to main when branch doesn't exist" , async ( ) => {
197- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 5 , 9 , 0 ) ) ;
214+ mockFolderContext = createMockFolderContext (
215+ path . normalize ( "/path/to/toolchain" ) ,
216+ new Version ( 5 , 9 , 0 )
217+ ) ;
198218 fileExistsStub . resolves ( false ) ;
199219
200220 const fetchStub = sandbox . stub ( globalThis , "fetch" ) ;
0 commit comments