Skip to content

Commit 02f8324

Browse files
dduankylef
authored andcommitted
Update Tests For .lastComponentWithoutExetnison (#44)
_Background_ A test for this API has been [failing, but only on macOS][0]. This is due to a implementation difference between the closed-source Foundation and its open-source counterpart. Recently, a [patch][1] has been made to the latter to fix this issue. The patch is [included][2] in the upcoming Swift 4.1 release. _Changes_ Add a condition to the test so it passes on both platforms for now. The expectation is that come Swift 4.1, this test will start failing on Linux and the condition will be removed then. [0]: https://travis-ci.org/kylef/PathKit/builds/289637066 [1]: swiftlang/swift-corelibs-foundation#1376 [2]: https://github.com/apple/swift-corelibs-foundation/commits/swift-4.1-branch
1 parent a667cd3 commit 02f8324

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Sources/PathKit.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ extension Path {
221221

222222
/// The last path component without file extension
223223
///
224-
/// - Note: This returns "." for "..".
224+
/// - Note: This returns "." for ".." on Linux, and ".." on Apple platforms.
225225
///
226226
/// - Returns: the last path component without file extension
227227
///

Tests/PathKitTests/PathKitSpec.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ describe("PathKit") {
210210

211211
$0.it("can return the last component without extension") {
212212
try expect(Path("a/b/c.d").lastComponentWithoutExtension) == "c"
213-
try expect(Path("a/..").lastComponentWithoutExtension) == "."
213+
#if os(Linux) // no longer necessary after Swift 4.1
214+
try expect(Path("a/..").lastComponentWithoutExtension) == "."
215+
#else
216+
try expect(Path("a/..").lastComponentWithoutExtension) == ".."
217+
#endif
214218
}
215219

216220
$0.it("can be split into components") {

0 commit comments

Comments
 (0)