@@ -12,6 +12,8 @@ import Basics
12
12
import Foundation
13
13
import XCTest
14
14
15
+ import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails()
16
+
15
17
#if os(Windows)
16
18
private var windows : Bool { true }
17
19
#else
@@ -54,28 +56,36 @@ class PathTests: XCTestCase {
54
56
XCTAssertEqual ( rel2. pathString, " ~ " ) // `~` is not special
55
57
}
56
58
57
- func testRepeatedPathSeparators( ) {
59
+ func testRepeatedPathSeparators( ) throws {
60
+ try skipOnWindowsAsTestCurrentlyFails ( because: " all assertions fail " )
61
+
58
62
XCTAssertEqual ( AbsolutePath ( " /ab//cd//ef " ) . pathString, windows ? #"\ab\cd\ef"# : " /ab/cd/ef " )
59
63
XCTAssertEqual ( AbsolutePath ( " /ab///cd//ef " ) . pathString, windows ? #"\ab\cd\ef"# : " /ab/cd/ef " )
60
64
XCTAssertEqual ( RelativePath ( " ab//cd//ef " ) . pathString, windows ? #"ab\cd\ef"# : " ab/cd/ef " )
61
65
XCTAssertEqual ( RelativePath ( " ab//cd///ef " ) . pathString, windows ? #"ab\cd\ef"# : " ab/cd/ef " )
62
66
}
63
67
64
- func testTrailingPathSeparators( ) {
68
+ func testTrailingPathSeparators( ) throws {
69
+ try skipOnWindowsAsTestCurrentlyFails ( because: " trailing path seperator is not removed from pathString " )
70
+
65
71
XCTAssertEqual ( AbsolutePath ( " /ab/cd/ef/ " ) . pathString, windows ? #"\ab\cd\ef"# : " /ab/cd/ef " )
66
72
XCTAssertEqual ( AbsolutePath ( " /ab/cd/ef// " ) . pathString, windows ? #"\ab\cd\ef"# : " /ab/cd/ef " )
67
73
XCTAssertEqual ( RelativePath ( " ab/cd/ef/ " ) . pathString, windows ? #"ab\cd\ef"# : " ab/cd/ef " )
68
74
XCTAssertEqual ( RelativePath ( " ab/cd/ef// " ) . pathString, windows ? #"ab\cd\ef"# : " ab/cd/ef " )
69
75
}
70
76
71
- func testDotPathComponents( ) {
77
+ func testDotPathComponents( ) throws {
78
+ try skipOnWindowsAsTestCurrentlyFails ( )
79
+
72
80
XCTAssertEqual ( AbsolutePath ( " /ab/././cd//ef " ) . pathString, " /ab/cd/ef " )
73
81
XCTAssertEqual ( AbsolutePath ( " /ab/./cd//ef/. " ) . pathString, " /ab/cd/ef " )
74
82
XCTAssertEqual ( RelativePath ( " ab/./cd/././ef " ) . pathString, " ab/cd/ef " )
75
83
XCTAssertEqual ( RelativePath ( " ab/./cd/ef/. " ) . pathString, " ab/cd/ef " )
76
84
}
77
85
78
- func testDotDotPathComponents( ) {
86
+ func testDotDotPathComponents( ) throws {
87
+ try skipOnWindowsAsTestCurrentlyFails ( )
88
+
79
89
XCTAssertEqual ( AbsolutePath ( " /.. " ) . pathString, windows ? #"\"# : " / " )
80
90
XCTAssertEqual ( AbsolutePath ( " /../../../../.. " ) . pathString, windows ? #"\"# : " / " )
81
91
XCTAssertEqual ( AbsolutePath ( " /abc/.. " ) . pathString, windows ? #"\"# : " / " )
@@ -91,7 +101,9 @@ class PathTests: XCTestCase {
91
101
XCTAssertEqual ( RelativePath ( " abc/.. " ) . pathString, " . " )
92
102
}
93
103
94
- func testCombinationsAndEdgeCases( ) {
104
+ func testCombinationsAndEdgeCases( ) throws {
105
+ try skipOnWindowsAsTestCurrentlyFails ( )
106
+
95
107
XCTAssertEqual ( AbsolutePath ( " /// " ) . pathString, windows ? #"\"# : " / " )
96
108
XCTAssertEqual ( AbsolutePath ( " /./ " ) . pathString, windows ? #"\"# : " / " )
97
109
XCTAssertEqual ( RelativePath ( " " ) . pathString, " . " )
@@ -120,7 +132,9 @@ class PathTests: XCTestCase {
120
132
XCTAssertEqual ( RelativePath ( " a/../////../////.///// " ) . pathString, " .. " )
121
133
}
122
134
123
- func testDirectoryNameExtraction( ) {
135
+ func testDirectoryNameExtraction( ) throws {
136
+ try skipOnWindowsAsTestCurrentlyFails ( )
137
+
124
138
XCTAssertEqual ( AbsolutePath ( " / " ) . dirname, windows ? #"\"# : " / " )
125
139
XCTAssertEqual ( AbsolutePath ( " /a " ) . dirname, windows ? #"\"# : " / " )
126
140
XCTAssertEqual ( AbsolutePath ( " /./a " ) . dirname, windows ? #"\"# : " / " )
@@ -137,7 +151,9 @@ class PathTests: XCTestCase {
137
151
XCTAssertEqual ( RelativePath ( " . " ) . dirname, " . " )
138
152
}
139
153
140
- func testBaseNameExtraction( ) {
154
+ func testBaseNameExtraction( ) throws {
155
+ try skipOnWindowsAsTestCurrentlyFails ( )
156
+
141
157
XCTAssertEqual ( AbsolutePath ( " / " ) . basename, windows ? #"\"# : " / " )
142
158
XCTAssertEqual ( AbsolutePath ( " /a " ) . basename, " a " )
143
159
XCTAssertEqual ( AbsolutePath ( " /./a " ) . basename, " a " )
@@ -153,7 +169,9 @@ class PathTests: XCTestCase {
153
169
XCTAssertEqual ( RelativePath ( " . " ) . basename, " . " )
154
170
}
155
171
156
- func testBaseNameWithoutExt( ) {
172
+ func testBaseNameWithoutExt( ) throws {
173
+ try skipOnWindowsAsTestCurrentlyFails ( )
174
+
157
175
XCTAssertEqual ( AbsolutePath ( " / " ) . basenameWithoutExt, windows ? #"\"# : " / " )
158
176
XCTAssertEqual ( AbsolutePath ( " /a " ) . basenameWithoutExt, " a " )
159
177
XCTAssertEqual ( AbsolutePath ( " /./a " ) . basenameWithoutExt, " a " )
@@ -176,7 +194,9 @@ class PathTests: XCTestCase {
176
194
XCTAssertEqual ( RelativePath ( " abc.xyz.123 " ) . basenameWithoutExt, " abc.xyz " )
177
195
}
178
196
179
- func testSuffixExtraction( ) {
197
+ func testSuffixExtraction( ) throws {
198
+ try skipOnWindowsAsTestCurrentlyFails ( because: " expected nil is not the actual " )
199
+
180
200
XCTAssertEqual ( RelativePath ( " a " ) . suffix, nil )
181
201
XCTAssertEqual ( RelativePath ( " a " ) . extension, nil )
182
202
XCTAssertEqual ( RelativePath ( " a. " ) . suffix, nil )
@@ -201,7 +221,9 @@ class PathTests: XCTestCase {
201
221
XCTAssertEqual ( RelativePath ( " .a.foo.bar.baz " ) . extension, " baz " )
202
222
}
203
223
204
- func testParentDirectory( ) {
224
+ func testParentDirectory( ) throws {
225
+ try skipOnWindowsAsTestCurrentlyFails ( )
226
+
205
227
XCTAssertEqual ( AbsolutePath ( " / " ) . parentDirectory, AbsolutePath ( " / " ) )
206
228
XCTAssertEqual ( AbsolutePath ( " / " ) . parentDirectory. parentDirectory, AbsolutePath ( " / " ) )
207
229
XCTAssertEqual ( AbsolutePath ( " /bar " ) . parentDirectory, AbsolutePath ( " / " ) )
@@ -210,7 +232,9 @@ class PathTests: XCTestCase {
210
232
}
211
233
212
234
@available ( * , deprecated)
213
- func testConcatenation( ) {
235
+ func testConcatenation( ) throws {
236
+ try skipOnWindowsAsTestCurrentlyFails ( )
237
+
214
238
XCTAssertEqual ( AbsolutePath ( AbsolutePath ( " / " ) , RelativePath ( " " ) ) . pathString, windows ? #"\"# : " / " )
215
239
XCTAssertEqual ( AbsolutePath ( AbsolutePath ( " / " ) , RelativePath ( " . " ) ) . pathString, windows ? #"\"# : " / " )
216
240
XCTAssertEqual ( AbsolutePath ( AbsolutePath ( " / " ) , RelativePath ( " .. " ) ) . pathString, windows ? #"\"# : " / " )
@@ -247,7 +271,9 @@ class PathTests: XCTestCase {
247
271
XCTAssertEqual ( RelativePath ( " hello " ) . appending ( RelativePath ( " a/b/../c/d " ) ) . pathString, windows ? #"hello\a\c\d"# : " hello/a/c/d " )
248
272
}
249
273
250
- func testPathComponents( ) {
274
+ func testPathComponents( ) throws {
275
+ try skipOnWindowsAsTestCurrentlyFails ( )
276
+
251
277
XCTAssertEqual ( AbsolutePath ( " / " ) . components, [ " / " ] )
252
278
XCTAssertEqual ( AbsolutePath ( " /. " ) . components, [ " / " ] )
253
279
XCTAssertEqual ( AbsolutePath ( " /.. " ) . components, [ " / " ] )
@@ -275,7 +301,9 @@ class PathTests: XCTestCase {
275
301
XCTAssertEqual ( RelativePath ( " abc " ) . components, [ " abc " ] )
276
302
}
277
303
278
- func testRelativePathFromAbsolutePaths( ) {
304
+ func testRelativePathFromAbsolutePaths( ) throws {
305
+ try skipOnWindowsAsTestCurrentlyFails ( )
306
+
279
307
XCTAssertEqual ( AbsolutePath ( " / " ) . relative ( to: AbsolutePath ( " / " ) ) , RelativePath ( " . " ) ) ;
280
308
XCTAssertEqual ( AbsolutePath ( " /a/b/c/d " ) . relative ( to: AbsolutePath ( " / " ) ) , RelativePath ( " a/b/c/d " ) ) ;
281
309
XCTAssertEqual ( AbsolutePath ( " / " ) . relative ( to: AbsolutePath ( " /a/b/c " ) ) , RelativePath ( " ../../.. " ) ) ;
@@ -316,7 +344,9 @@ class PathTests: XCTestCase {
316
344
XCTAssertTrue ( AbsolutePath ( " /foo " ) . isAncestor ( of: AbsolutePath ( " /foo/bar " ) ) )
317
345
}
318
346
319
- func testAbsolutePathValidation( ) {
347
+ func testAbsolutePathValidation( ) throws {
348
+ try skipOnWindowsAsTestCurrentlyFails ( )
349
+
320
350
XCTAssertNoThrow ( try AbsolutePath ( validating: " /a/b/c/d " ) )
321
351
322
352
XCTAssertThrowsError ( try AbsolutePath ( validating: " ~/a/b/d " ) ) { error in
@@ -328,7 +358,9 @@ class PathTests: XCTestCase {
328
358
}
329
359
}
330
360
331
- func testRelativePathValidation( ) {
361
+ func testRelativePathValidation( ) throws {
362
+ try skipOnWindowsAsTestCurrentlyFails ( )
363
+
332
364
XCTAssertNoThrow ( try RelativePath ( validating: " a/b/c/d " ) )
333
365
334
366
XCTAssertThrowsError ( try RelativePath ( validating: " /a/b/d " ) ) { error in
@@ -342,6 +374,8 @@ class PathTests: XCTestCase {
342
374
}
343
375
344
376
func testCodable( ) throws {
377
+ try skipOnWindowsAsTestCurrentlyFails ( )
378
+
345
379
struct Foo : Codable , Equatable {
346
380
var path : AbsolutePath
347
381
}
0 commit comments