@@ -12,7 +12,7 @@ import Basics
12
12
import Foundation
13
13
import XCTest
14
14
15
- import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFails ()
15
+ import _InternalTestSupport // for skipOnWindowsAsTestCurrentlyFailsDang ()
16
16
17
17
#if os(Windows)
18
18
private var windows : Bool { true }
@@ -57,35 +57,29 @@ class PathTests: XCTestCase {
57
57
}
58
58
59
59
func testRepeatedPathSeparators( ) throws {
60
- try skipOnWindowsAsTestCurrentlyFails ( because: " all assertions fail " )
61
-
62
60
XCTAssertEqual ( AbsolutePath ( " /ab//cd//ef " ) . pathString, windows ? #"\ab\cd\ef"# : " /ab/cd/ef " )
63
61
XCTAssertEqual ( AbsolutePath ( " /ab///cd//ef " ) . pathString, windows ? #"\ab\cd\ef"# : " /ab/cd/ef " )
64
62
XCTAssertEqual ( RelativePath ( " ab//cd//ef " ) . pathString, windows ? #"ab\cd\ef"# : " ab/cd/ef " )
65
63
XCTAssertEqual ( RelativePath ( " ab//cd///ef " ) . pathString, windows ? #"ab\cd\ef"# : " ab/cd/ef " )
66
64
}
67
65
68
66
func testTrailingPathSeparators( ) throws {
69
- try skipOnWindowsAsTestCurrentlyFails ( because: " trailing path seperator is not removed from pathString " )
70
-
71
67
XCTAssertEqual ( AbsolutePath ( " /ab/cd/ef/ " ) . pathString, windows ? #"\ab\cd\ef"# : " /ab/cd/ef " )
72
68
XCTAssertEqual ( AbsolutePath ( " /ab/cd/ef// " ) . pathString, windows ? #"\ab\cd\ef"# : " /ab/cd/ef " )
69
+ XCTAssertEqual ( AbsolutePath ( " /ab/cd/ef/// " ) . pathString, windows ? #"\ab\cd\ef"# : " /ab/cd/ef " )
73
70
XCTAssertEqual ( RelativePath ( " ab/cd/ef/ " ) . pathString, windows ? #"ab\cd\ef"# : " ab/cd/ef " )
74
71
XCTAssertEqual ( RelativePath ( " ab/cd/ef// " ) . pathString, windows ? #"ab\cd\ef"# : " ab/cd/ef " )
72
+ XCTAssertEqual ( RelativePath ( " ab/cd/ef/// " ) . pathString, windows ? #"ab\cd\ef"# : " ab/cd/ef " )
75
73
}
76
74
77
75
func testDotPathComponents( ) throws {
78
- try skipOnWindowsAsTestCurrentlyFails ( )
79
-
80
76
XCTAssertEqual ( AbsolutePath ( " /ab/././cd//ef " ) . pathString, " /ab/cd/ef " )
81
77
XCTAssertEqual ( AbsolutePath ( " /ab/./cd//ef/. " ) . pathString, " /ab/cd/ef " )
82
78
XCTAssertEqual ( RelativePath ( " ab/./cd/././ef " ) . pathString, " ab/cd/ef " )
83
79
XCTAssertEqual ( RelativePath ( " ab/./cd/ef/. " ) . pathString, " ab/cd/ef " )
84
80
}
85
81
86
82
func testDotDotPathComponents( ) throws {
87
- try skipOnWindowsAsTestCurrentlyFails ( )
88
-
89
83
XCTAssertEqual ( AbsolutePath ( " /.. " ) . pathString, windows ? #"\"# : " / " )
90
84
XCTAssertEqual ( AbsolutePath ( " /../../../../.. " ) . pathString, windows ? #"\"# : " / " )
91
85
XCTAssertEqual ( AbsolutePath ( " /abc/.. " ) . pathString, windows ? #"\"# : " / " )
@@ -102,8 +96,6 @@ class PathTests: XCTestCase {
102
96
}
103
97
104
98
func testCombinationsAndEdgeCases( ) throws {
105
- try skipOnWindowsAsTestCurrentlyFails ( )
106
-
107
99
XCTAssertEqual ( AbsolutePath ( " /// " ) . pathString, windows ? #"\"# : " / " )
108
100
XCTAssertEqual ( AbsolutePath ( " /./ " ) . pathString, windows ? #"\"# : " / " )
109
101
XCTAssertEqual ( RelativePath ( " " ) . pathString, " . " )
@@ -133,8 +125,6 @@ class PathTests: XCTestCase {
133
125
}
134
126
135
127
func testDirectoryNameExtraction( ) throws {
136
- try skipOnWindowsAsTestCurrentlyFails ( )
137
-
138
128
XCTAssertEqual ( AbsolutePath ( " / " ) . dirname, windows ? #"\"# : " / " )
139
129
XCTAssertEqual ( AbsolutePath ( " /a " ) . dirname, windows ? #"\"# : " / " )
140
130
XCTAssertEqual ( AbsolutePath ( " /./a " ) . dirname, windows ? #"\"# : " / " )
@@ -152,8 +142,6 @@ class PathTests: XCTestCase {
152
142
}
153
143
154
144
func testBaseNameExtraction( ) throws {
155
- try skipOnWindowsAsTestCurrentlyFails ( )
156
-
157
145
XCTAssertEqual ( AbsolutePath ( " / " ) . basename, windows ? #"\"# : " / " )
158
146
XCTAssertEqual ( AbsolutePath ( " /a " ) . basename, " a " )
159
147
XCTAssertEqual ( AbsolutePath ( " /./a " ) . basename, " a " )
@@ -170,8 +158,6 @@ class PathTests: XCTestCase {
170
158
}
171
159
172
160
func testBaseNameWithoutExt( ) throws {
173
- try skipOnWindowsAsTestCurrentlyFails ( )
174
-
175
161
XCTAssertEqual ( AbsolutePath ( " / " ) . basenameWithoutExt, windows ? #"\"# : " / " )
176
162
XCTAssertEqual ( AbsolutePath ( " /a " ) . basenameWithoutExt, " a " )
177
163
XCTAssertEqual ( AbsolutePath ( " /./a " ) . basenameWithoutExt, " a " )
@@ -195,8 +181,6 @@ class PathTests: XCTestCase {
195
181
}
196
182
197
183
func testSuffixExtraction( ) throws {
198
- try skipOnWindowsAsTestCurrentlyFails ( because: " expected nil is not the actual " )
199
-
200
184
XCTAssertEqual ( RelativePath ( " a " ) . suffix, nil )
201
185
XCTAssertEqual ( RelativePath ( " a " ) . extension, nil )
202
186
XCTAssertEqual ( RelativePath ( " a. " ) . suffix, nil )
@@ -222,8 +206,6 @@ class PathTests: XCTestCase {
222
206
}
223
207
224
208
func testParentDirectory( ) throws {
225
- try skipOnWindowsAsTestCurrentlyFails ( )
226
-
227
209
XCTAssertEqual ( AbsolutePath ( " / " ) . parentDirectory, AbsolutePath ( " / " ) )
228
210
XCTAssertEqual ( AbsolutePath ( " / " ) . parentDirectory. parentDirectory, AbsolutePath ( " / " ) )
229
211
XCTAssertEqual ( AbsolutePath ( " /bar " ) . parentDirectory, AbsolutePath ( " / " ) )
@@ -233,8 +215,6 @@ class PathTests: XCTestCase {
233
215
234
216
@available ( * , deprecated)
235
217
func testConcatenation( ) throws {
236
- try skipOnWindowsAsTestCurrentlyFails ( )
237
-
238
218
XCTAssertEqual ( AbsolutePath ( AbsolutePath ( " / " ) , RelativePath ( " " ) ) . pathString, windows ? #"\"# : " / " )
239
219
XCTAssertEqual ( AbsolutePath ( AbsolutePath ( " / " ) , RelativePath ( " . " ) ) . pathString, windows ? #"\"# : " / " )
240
220
XCTAssertEqual ( AbsolutePath ( AbsolutePath ( " / " ) , RelativePath ( " .. " ) ) . pathString, windows ? #"\"# : " / " )
@@ -272,38 +252,34 @@ class PathTests: XCTestCase {
272
252
}
273
253
274
254
func testPathComponents( ) throws {
275
- try skipOnWindowsAsTestCurrentlyFails ( )
276
-
277
- XCTAssertEqual ( AbsolutePath ( " / " ) . components, [ " / " ] )
278
- XCTAssertEqual ( AbsolutePath ( " /. " ) . components, [ " / " ] )
279
- XCTAssertEqual ( AbsolutePath ( " /.. " ) . components, [ " / " ] )
280
- XCTAssertEqual ( AbsolutePath ( " /bar " ) . components, [ " / " , " bar " ] )
281
- XCTAssertEqual ( AbsolutePath ( " /foo/bar/.. " ) . components, [ " / " , " foo " ] )
282
- XCTAssertEqual ( AbsolutePath ( " /bar/../foo " ) . components, [ " / " , " foo " ] )
283
- XCTAssertEqual ( AbsolutePath ( " /bar/../foo/..// " ) . components, [ " / " ] )
284
- XCTAssertEqual ( AbsolutePath ( " /bar/../foo/..//yabba/a/b/ " ) . components, [ " / " , " yabba " , " a " , " b " ] )
255
+ XCTAssertEqual ( AbsolutePath ( " / " ) . components, windows ? [ ] : [ " / " ] )
256
+ XCTAssertEqual ( AbsolutePath ( " /. " ) . components, windows ? [ " . " ] : [ " / " ] )
257
+ XCTAssertEqual ( AbsolutePath ( " /.. " ) . components, windows ? [ " .. " ] : [ " / " ] )
258
+ XCTAssertEqual ( AbsolutePath ( " /bar " ) . components, windows ? [ " bar " ] : [ " / " , " bar " ] )
259
+ XCTAssertEqual ( AbsolutePath ( " /foo/bar/.. " ) . components, windows ? [ " foo " , " bar " , " .. " ] : [ " / " , " foo " ] )
260
+ XCTAssertEqual ( AbsolutePath ( " /bar/../foo " ) . components, windows ? [ " bar " , " .. " , " foo " ] : [ " / " , " foo " ] )
261
+ XCTAssertEqual ( AbsolutePath ( " /bar/../foo/..// " ) . components, windows ? [ " bar " , " .. " , " foo " , " .. " ] : [ " / " ] )
262
+ XCTAssertEqual ( AbsolutePath ( " /bar/../foo/..//yabba/a/b/ " ) . components, windows ? [ " bar " , " .. " , " foo " , " .. " , " yabba " , " a " , " b " ] : [ " / " , " yabba " , " a " , " b " ] )
285
263
286
264
XCTAssertEqual ( RelativePath ( " " ) . components, [ " . " ] )
287
265
XCTAssertEqual ( RelativePath ( " . " ) . components, [ " . " ] )
288
266
XCTAssertEqual ( RelativePath ( " .. " ) . components, [ " .. " ] )
289
267
XCTAssertEqual ( RelativePath ( " bar " ) . components, [ " bar " ] )
290
- XCTAssertEqual ( RelativePath ( " foo/bar/.. " ) . components, [ " foo " ] )
291
- XCTAssertEqual ( RelativePath ( " bar/../foo " ) . components, [ " foo " ] )
292
- XCTAssertEqual ( RelativePath ( " bar/../foo/..// " ) . components, [ " . " ] )
293
- XCTAssertEqual ( RelativePath ( " bar/../foo/..//yabba/a/b/ " ) . components, [ " yabba " , " a " , " b " ] )
268
+ XCTAssertEqual ( RelativePath ( " foo/bar/.. " ) . components, windows ? [ " foo " , " bar " , " .. " ] : [ " foo " ] )
269
+ XCTAssertEqual ( RelativePath ( " bar/../foo " ) . components, windows ? [ " bar " , " .. " , " foo " ] : [ " foo " ] )
270
+ XCTAssertEqual ( RelativePath ( " bar/../foo/..// " ) . components, windows ? [ " bar " , " .. " , " foo " , " .. " ] : [ " . " ] )
271
+ XCTAssertEqual ( RelativePath ( " bar/../foo/..//yabba/a/b/ " ) . components, windows ? [ " bar " , " .. " , " foo " , " .. " , " yabba " , " a " , " b " ] : [ " yabba " , " a " , " b " ] )
294
272
XCTAssertEqual ( RelativePath ( " ../.. " ) . components, [ " .. " , " .. " ] )
295
- XCTAssertEqual ( RelativePath ( " .././/.. " ) . components, [ " .. " , " .. " ] )
273
+ XCTAssertEqual ( RelativePath ( " .././/.. " ) . components, windows ? [ " .. " , " . " , " .. " ] : [ " .. " , " .. " ] )
296
274
XCTAssertEqual ( RelativePath ( " ../a " ) . components, [ " .. " , " a " ] )
297
- XCTAssertEqual ( RelativePath ( " ../a/.. " ) . components, [ " .. " ] )
298
- XCTAssertEqual ( RelativePath ( " a/.. " ) . components, [ " . " ] )
275
+ XCTAssertEqual ( RelativePath ( " ../a/.. " ) . components, windows ? [ " .. " , " a " , " .. " ] : [ " .. " ] )
276
+ XCTAssertEqual ( RelativePath ( " a/.. " ) . components, windows ? [ " a " , " .. " ] : [ " . " ] )
299
277
XCTAssertEqual ( RelativePath ( " ./.. " ) . components, [ " .. " ] )
300
278
XCTAssertEqual ( RelativePath ( " a/../////../////.///// " ) . components, [ " .. " ] )
301
279
XCTAssertEqual ( RelativePath ( " abc " ) . components, [ " abc " ] )
302
280
}
303
281
304
282
func testRelativePathFromAbsolutePaths( ) throws {
305
- try skipOnWindowsAsTestCurrentlyFails ( )
306
-
307
283
XCTAssertEqual ( AbsolutePath ( " / " ) . relative ( to: AbsolutePath ( " / " ) ) , RelativePath ( " . " ) ) ;
308
284
XCTAssertEqual ( AbsolutePath ( " /a/b/c/d " ) . relative ( to: AbsolutePath ( " / " ) ) , RelativePath ( " a/b/c/d " ) ) ;
309
285
XCTAssertEqual ( AbsolutePath ( " / " ) . relative ( to: AbsolutePath ( " /a/b/c " ) ) , RelativePath ( " ../../.. " ) ) ;
@@ -345,22 +321,20 @@ class PathTests: XCTestCase {
345
321
}
346
322
347
323
func testAbsolutePathValidation( ) throws {
348
- try skipOnWindowsAsTestCurrentlyFails ( )
349
-
350
324
XCTAssertNoThrow ( try AbsolutePath ( validating: " /a/b/c/d " ) )
351
325
326
+ #if !os(Windows)
352
327
XCTAssertThrowsError ( try AbsolutePath ( validating: " ~/a/b/d " ) ) { error in
353
328
XCTAssertEqual ( " \( error) " , " invalid absolute path '~/a/b/d'; absolute path must begin with '/' " )
354
329
}
330
+ #endif
355
331
356
332
XCTAssertThrowsError ( try AbsolutePath ( validating: " a/b/d " ) ) { error in
357
333
XCTAssertEqual ( " \( error) " , " invalid absolute path 'a/b/d' " )
358
334
}
359
335
}
360
336
361
337
func testRelativePathValidation( ) throws {
362
- try skipOnWindowsAsTestCurrentlyFails ( )
363
-
364
338
XCTAssertNoThrow ( try RelativePath ( validating: " a/b/c/d " ) )
365
339
366
340
XCTAssertThrowsError ( try RelativePath ( validating: " /a/b/d " ) ) { error in
@@ -374,8 +348,6 @@ class PathTests: XCTestCase {
374
348
}
375
349
376
350
func testCodable( ) throws {
377
- try skipOnWindowsAsTestCurrentlyFails ( )
378
-
379
351
struct Foo : Codable , Equatable {
380
352
var path : AbsolutePath
381
353
}
0 commit comments