99// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
1010//
1111//===----------------------------------------------------------------------===//
12-
1312@testable import Basics
1413import TSCTestSupport
15- import XCTest
14+ import Testing
1615
17- final class FileSystemTests : XCTestCase {
18- func testStripFirstLevelComponent( ) throws {
16+ struct FileSystemTests {
17+ @Test
18+ func stripFirstLevelComponent( ) throws {
1919 let fileSystem = InMemoryFileSystem ( )
2020
2121 let rootPath = AbsolutePath ( " /root " )
@@ -35,29 +35,31 @@ final class FileSystemTests: XCTestCase {
3535
3636 do {
3737 let contents = try fileSystem. getDirectoryContents ( . root)
38- XCTAssertEqual ( contents. count, 1 )
38+ #expect ( contents. count == 1 )
3939 }
4040
4141 try fileSystem. stripFirstLevel ( of: . root)
4242
4343 do {
4444 let contents = Set ( try fileSystem. getDirectoryContents ( . root) )
45- XCTAssertEqual ( contents. count, totalDirectories + totalFiles)
45+ #expect ( contents. count == totalDirectories + totalFiles)
4646
4747 for index in 0 ..< totalDirectories {
48- XCTAssertTrue ( contents. contains ( " dir \( index) " ) )
48+ #expect ( contents. contains ( " dir \( index) " ) )
4949 }
5050 for index in 0 ..< totalFiles {
51- XCTAssertTrue ( contents. contains ( " file \( index) " ) )
51+ #expect ( contents. contains ( " file \( index) " ) )
5252 }
5353 }
5454 }
5555
56- func testStripFirstLevelComponentErrors( ) throws {
56+ @Test
57+ func stripFirstLevelComponentErrors( ) throws {
58+ let functionUnderTest = " stripFirstLevel "
5759 do {
5860 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 )
6163 }
6264 }
6365
@@ -67,8 +69,8 @@ final class FileSystemTests: XCTestCase {
6769 let path = AbsolutePath . root. appending ( " dir \( index) " )
6870 try fileSystem. createDirectory ( path, recursive: false )
6971 }
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 )
7274 }
7375 }
7476
@@ -78,17 +80,17 @@ final class FileSystemTests: XCTestCase {
7880 let path = AbsolutePath . root. appending ( " file \( index) " )
7981 try fileSystem. writeFileContents ( path, string: " \( index) " )
8082 }
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 )
8385 }
8486 }
8587
8688 do {
8789 let fileSystem = InMemoryFileSystem ( )
8890 let path = AbsolutePath . root. appending ( " file " )
8991 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 )
9294 }
9395 }
9496 }
0 commit comments