12
12
13
13
import Basics
14
14
import Foundation
15
- import XCTest
15
+ import Testing
16
16
17
- class PathShimTests : XCTestCase {
18
- func testRescursiveDirectoryCreation ( ) {
19
- // For the tests we'll need a temporary directory.
17
+ struct PathShimTests {
18
+ @ Test
19
+ func rescursiveDirectoryCreation ( ) {
20
20
try ! withTemporaryDirectory ( removeTreeOnDeinit: true ) { path in
21
21
// Create a directory under several ancestor directories.
22
22
let dirPath = path. appending ( components: " abc " , " def " , " ghi " , " mno " , " pqr " )
23
23
try ! makeDirectories ( dirPath)
24
24
25
25
// Check that we were able to actually create the directory.
26
- XCTAssertTrue ( localFileSystem. isDirectory ( dirPath) )
26
+ #expect ( localFileSystem. isDirectory ( dirPath) )
27
27
28
28
// Check that there's no error if we try to create the directory again.
29
- try ! makeDirectories ( dirPath)
29
+ #expect( throws: Never . self) {
30
+ try ! makeDirectories ( dirPath)
31
+ }
30
32
}
31
33
}
32
34
}
33
35
34
- class WalkTests : XCTestCase {
35
- func testNonRecursive( ) throws {
36
- #if os(Android)
36
+ struct WalkTests {
37
+ @Test
38
+ func nonRecursive( ) throws {
39
+ #if os(Android)
37
40
let root = " /system "
38
41
var expected : [ AbsolutePath ] = [
39
42
" \( root) /usr " ,
40
43
" \( root) /bin " ,
41
44
" \( root) /etc " ,
42
45
]
43
- #elseif os(Windows)
46
+ let expectedCount = 3
47
+ #elseif os(Windows)
44
48
let root = ProcessInfo . processInfo. environment [ " SystemRoot " ] !
45
49
var expected : [ AbsolutePath ] = [
46
50
" \( root) /System32 " ,
47
51
" \( root) /SysWOW64 " ,
48
52
]
49
- #else
53
+ let expectedCount = ( root as NSString ) . pathComponents. count + 2
54
+ #else
50
55
let root = " "
51
56
var expected : [ AbsolutePath ] = [
52
57
" /usr " ,
53
58
" /bin " ,
54
59
" /sbin " ,
55
60
]
56
- #endif
61
+ let expectedCount = 2
62
+ #endif
57
63
for x in try walk ( AbsolutePath ( validating: " \( root) / " ) , recursively: false ) {
58
64
if let i = expected. firstIndex ( of: x) {
59
65
expected. remove ( at: i)
60
66
}
61
- #if os(Android)
62
- XCTAssertEqual ( 3 , x. components. count)
63
- #elseif os(Windows)
64
- XCTAssertEqual ( ( root as NSString ) . pathComponents. count + 2 , x. components. count)
65
- #else
66
- XCTAssertEqual ( 2 , x. components. count)
67
- #endif
67
+ #expect( x. components. count == expectedCount, " Actual is not as expected " )
68
68
}
69
- XCTAssertEqual ( expected. count, 0 )
69
+ #expect ( expected. count == 0 )
70
70
}
71
71
72
- func testRecursive( ) {
72
+ @Test
73
+ func recursive( ) {
73
74
let root = AbsolutePath ( #file) . parentDirectory. parentDirectory. parentDirectory. parentDirectory
74
75
. appending ( component: " Sources " )
75
76
var expected = [
@@ -82,6 +83,6 @@ class WalkTests: XCTestCase {
82
83
expected. remove ( at: i)
83
84
}
84
85
}
85
- XCTAssertEqual ( expected, [ ] )
86
+ #expect ( expected == [ ] )
86
87
}
87
88
}
0 commit comments