1212//
1313//===----------------------------------------------------------------------===//
1414import { expect } from "chai" ;
15+ import * as path from "path" ;
1516import * as sinon from "sinon" ;
1617import * as vscode from "vscode" ;
1718
@@ -64,12 +65,14 @@ 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
@@ -80,33 +83,39 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
8083
8184 test ( "returns correct path for nested toolchain directory" , ( ) => {
8285 mockFolderContext = createMockFolderContext (
83- "/usr/local/swift-6.3.0" ,
86+ path . normalize ( "/usr/local/swift-6.3.0" ) ,
8487 new Version ( 6 , 3 , 0 )
8588 ) ;
8689
8790 const result = localSchemaPath ( mockFolderContext ) ;
8891
8992 expect ( result ) . to . equal (
90- "/usr/local/swift-6.3.0/share/sourcekit-lsp/config.schema.json"
93+ path . normalize ( "/usr/local/swift-6.3.0/share/sourcekit-lsp/config.schema.json" )
9194 ) ;
9295 } ) ;
9396 } ) ;
9497
9598 suite ( "hasLocalSchema()" , ( ) => {
9699 test ( "returns true when schema file exists" , async ( ) => {
97- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 6 , 3 , 0 ) ) ;
100+ mockFolderContext = createMockFolderContext (
101+ path . normalize ( "/path/to/toolchain" ) ,
102+ new Version ( 6 , 3 , 0 )
103+ ) ;
98104 fileExistsStub . resolves ( true ) ;
99105
100106 const result = await hasLocalSchema ( mockFolderContext ) ;
101107
102108 expect ( result ) . to . be . true ;
103109 expect ( fileExistsStub ) . to . have . been . calledWith (
104- "/path/to/toolchain/share/sourcekit-lsp/config.schema.json"
110+ path . normalize ( "/path/to/toolchain/share/sourcekit-lsp/config.schema.json" )
105111 ) ;
106112 } ) ;
107113
108114 test ( "returns false when schema file doesn't exist" , async ( ) => {
109- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 6 , 1 , 0 ) ) ;
115+ mockFolderContext = createMockFolderContext (
116+ path . normalize ( "/path/to/toolchain" ) ,
117+ new Version ( 6 , 1 , 0 )
118+ ) ;
110119 fileExistsStub . resolves ( false ) ;
111120
112121 const result = await hasLocalSchema ( mockFolderContext ) ;
@@ -137,7 +146,10 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
137146 } ) ;
138147
139148 test ( "returns https:// URL when local schema doesn't exist" , async ( ) => {
140- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 6 , 1 , 0 ) ) ;
149+ mockFolderContext = createMockFolderContext (
150+ path . normalize ( "/path/to/toolchain" ) ,
151+ new Version ( 6 , 1 , 0 )
152+ ) ;
141153 fileExistsStub . resolves ( false ) ;
142154
143155 const result = await determineSchemaURL ( mockFolderContext ) ;
@@ -149,19 +161,22 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
149161
150162 test ( "local schema path includes share/sourcekit-lsp/config.schema.json" , async ( ) => {
151163 mockFolderContext = createMockFolderContext (
152- "/usr/local/swift-6.3" ,
164+ path . normalize ( "/usr/local/swift-6.3" ) ,
153165 new Version ( 6 , 3 , 0 )
154166 ) ;
155167 fileExistsStub . resolves ( true ) ;
156168
157169 const result = await determineSchemaURL ( mockFolderContext ) ;
158170
159- expect ( result ) . to . include ( "/usr/local/swift-6.3" ) ;
160- expect ( result ) . to . include ( "share/sourcekit-lsp/config.schema.json" ) ;
171+ expect ( result ) . to . include ( path . normalize ( "/usr/local/swift-6.3" ) ) ;
172+ expect ( result ) . to . include ( path . normalize ( "share/sourcekit-lsp/config.schema.json" ) ) ;
161173 } ) ;
162174
163175 test ( "remote URL uses correct branch for release version" , async ( ) => {
164- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 6 , 2 , 0 ) ) ;
176+ mockFolderContext = createMockFolderContext (
177+ path . normalize ( "/path/to/toolchain" ) ,
178+ new Version ( 6 , 2 , 0 )
179+ ) ;
165180 fileExistsStub . resolves ( false ) ;
166181
167182 const fetchStub = sandbox . stub ( globalThis , "fetch" ) ;
@@ -177,7 +192,7 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
177192
178193 test ( "remote URL uses main for dev version" , async ( ) => {
179194 mockFolderContext = createMockFolderContext (
180- "/path/to/toolchain" ,
195+ path . normalize ( "/path/to/toolchain" ) ,
181196 new Version ( 6 , 3 , 0 , true )
182197 ) ;
183198 fileExistsStub . resolves ( false ) ;
@@ -194,7 +209,10 @@ suite("generateSourcekitConfiguration - Schema Detection", () => {
194209 } ) ;
195210
196211 test ( "falls back to main when branch doesn't exist" , async ( ) => {
197- mockFolderContext = createMockFolderContext ( "/path/to/toolchain" , new Version ( 5 , 9 , 0 ) ) ;
212+ mockFolderContext = createMockFolderContext (
213+ path . normalize ( "/path/to/toolchain" ) ,
214+ new Version ( 5 , 9 , 0 )
215+ ) ;
198216 fileExistsStub . resolves ( false ) ;
199217
200218 const fetchStub = sandbox . stub ( globalThis , "fetch" ) ;
0 commit comments