Skip to content

Commit 58cc189

Browse files
committed
Fix tests when building swift-format using Swift 6.0.2
When traversing the file URL with Foundation from Swift 6.0.2, you get the following components - `["/", "C:", "test.swift"]` - `["/", "C:"]` - `[]` The component count never reaches 1. Foundation from Swift 6.1 goes - `["/", "C:", "test.swift"]` - `["/", "C:"]` - `["/"]` Cover both cases by checking for `<= 1` instead of `== 1`
1 parent 3ca1a18 commit 58cc189

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/SwiftFormat/API/Configuration.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ fileprivate extension URL {
478478
#if os(Windows)
479479
// FIXME: We should call into Windows' native check to check if this path is a root once https://github.com/swiftlang/swift-foundation/issues/976 is fixed.
480480
// https://github.com/swiftlang/swift-format/issues/844
481-
return self.pathComponents.count == 1
481+
return self.pathComponents.count <= 1
482482
#else
483483
// On Linux, we may end up with an string for the path due to https://github.com/swiftlang/swift-foundation/issues/980
484484
// TODO: Remove the check for "" once https://github.com/swiftlang/swift-foundation/issues/980 is fixed.

0 commit comments

Comments
 (0)