9
9
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10
10
//
11
11
//===----------------------------------------------------------------------===//
12
-
13
12
@testable import Basics
14
13
import TSCTestSupport
15
- import XCTest
14
+ import Testing
16
15
17
- final class FileSystemTests : XCTestCase {
18
- func testStripFirstLevelComponent( ) throws {
16
+ struct FileSystemTests {
17
+ @Test
18
+ func stripFirstLevelComponent( ) throws {
19
19
let fileSystem = InMemoryFileSystem ( )
20
20
21
21
let rootPath = AbsolutePath ( " /root " )
@@ -35,29 +35,31 @@ final class FileSystemTests: XCTestCase {
35
35
36
36
do {
37
37
let contents = try fileSystem. getDirectoryContents ( . root)
38
- XCTAssertEqual ( contents. count, 1 )
38
+ #expect ( contents. count == 1 )
39
39
}
40
40
41
41
try fileSystem. stripFirstLevel ( of: . root)
42
42
43
43
do {
44
44
let contents = Set ( try fileSystem. getDirectoryContents ( . root) )
45
- XCTAssertEqual ( contents. count, totalDirectories + totalFiles)
45
+ #expect ( contents. count == totalDirectories + totalFiles)
46
46
47
47
for index in 0 ..< totalDirectories {
48
- XCTAssertTrue ( contents. contains ( " dir \( index) " ) )
48
+ #expect ( contents. contains ( " dir \( index) " ) )
49
49
}
50
50
for index in 0 ..< totalFiles {
51
- XCTAssertTrue ( contents. contains ( " file \( index) " ) )
51
+ #expect ( contents. contains ( " file \( index) " ) )
52
52
}
53
53
}
54
54
}
55
55
56
- func testStripFirstLevelComponentErrors( ) throws {
56
+ @Test
57
+ func stripFirstLevelComponentErrors( ) throws {
58
+ let functionUnderTest = " stripFirstLevel "
57
59
do {
58
60
let fileSystem = InMemoryFileSystem ( )
59
- XCTAssertThrowsError ( try fileSystem . stripFirstLevel ( of : . root ) , " expected error " ) { error in
60
- XCTAssertMatch ( ( error as? StringError ) ? . description , . contains ( " requires single top level directory " ) )
61
+ #expect ( throws : StringError ( " \( functionUnderTest ) requires single top level directory " ) ) {
62
+ try fileSystem . stripFirstLevel ( of : . root )
61
63
}
62
64
}
63
65
@@ -67,8 +69,8 @@ final class FileSystemTests: XCTestCase {
67
69
let path = AbsolutePath . root. appending ( " dir \( index) " )
68
70
try fileSystem. createDirectory ( path, recursive: false )
69
71
}
70
- XCTAssertThrowsError ( try fileSystem . stripFirstLevel ( of : . root ) , " expected error " ) { error in
71
- XCTAssertMatch ( ( error as? StringError ) ? . description , . contains ( " requires single top level directory " ) )
72
+ #expect ( throws : StringError ( " \( functionUnderTest ) requires single top level directory " ) ) {
73
+ try fileSystem . stripFirstLevel ( of : . root )
72
74
}
73
75
}
74
76
@@ -78,17 +80,17 @@ final class FileSystemTests: XCTestCase {
78
80
let path = AbsolutePath . root. appending ( " file \( index) " )
79
81
try fileSystem. writeFileContents ( path, string: " \( index) " )
80
82
}
81
- XCTAssertThrowsError ( try fileSystem . stripFirstLevel ( of : . root ) , " expected error " ) { error in
82
- XCTAssertMatch ( ( error as? StringError ) ? . description , . contains ( " requires single top level directory " ) )
83
+ #expect ( throws : StringError ( " \( functionUnderTest ) requires single top level directory " ) ) {
84
+ try fileSystem . stripFirstLevel ( of : . root )
83
85
}
84
86
}
85
87
86
88
do {
87
89
let fileSystem = InMemoryFileSystem ( )
88
90
let path = AbsolutePath . root. appending ( " file " )
89
91
try fileSystem. writeFileContents ( path, string: " " )
90
- XCTAssertThrowsError ( try fileSystem . stripFirstLevel ( of : . root ) , " expected error " ) { error in
91
- XCTAssertMatch ( ( error as? StringError ) ? . description , . contains ( " requires single top level directory " ) )
92
+ #expect ( throws : StringError ( " \( functionUnderTest ) requires single top level directory " ) ) {
93
+ try fileSystem . stripFirstLevel ( of : . root )
92
94
}
93
95
}
94
96
}
0 commit comments