@@ -19,51 +19,51 @@ import class TSCBasic.InMemoryFileSystem
19
19
import struct TSCBasic. FileSystemError
20
20
21
21
final class TarArchiverTests : XCTestCase {
22
- func testSuccess( ) throws {
23
- try testWithTemporaryDirectory { tmpdir in
22
+ func testSuccess( ) async throws {
23
+ try await testWithTemporaryDirectory { tmpdir in
24
24
let archiver = TarArchiver ( fileSystem: localFileSystem)
25
25
let inputArchivePath = AbsolutePath ( #file) . parentDirectory
26
26
. appending ( components: " Inputs " , " archive.tar.gz " )
27
- try archiver. extract ( from: inputArchivePath, to: tmpdir)
27
+ try await archiver. extract ( from: inputArchivePath, to: tmpdir)
28
28
let content = tmpdir. appending ( " file " )
29
29
XCTAssert ( localFileSystem. exists ( content) )
30
30
XCTAssertEqual ( ( try ? localFileSystem. readFileContents ( content) ) ? . cString, " Hello World! " )
31
31
}
32
32
}
33
33
34
- func testArchiveDoesntExist( ) {
34
+ func testArchiveDoesntExist( ) async {
35
35
let fileSystem = InMemoryFileSystem ( )
36
36
let archiver = TarArchiver ( fileSystem: fileSystem)
37
37
let archive = AbsolutePath ( " /archive.tar.gz " )
38
- XCTAssertThrowsError ( try archiver. extract ( from: archive, to: " / " ) ) { error in
38
+ await XCTAssertAsyncThrowsError ( try await archiver. extract ( from: archive, to: " / " ) ) { error in
39
39
XCTAssertEqual ( error as? FileSystemError , FileSystemError ( . noEntry, archive) )
40
40
}
41
41
}
42
42
43
- func testDestinationDoesntExist( ) throws {
43
+ func testDestinationDoesntExist( ) async throws {
44
44
let fileSystem = InMemoryFileSystem ( emptyFiles: " /archive.tar.gz " )
45
45
let archiver = TarArchiver ( fileSystem: fileSystem)
46
46
let destination = AbsolutePath ( " /destination " )
47
- XCTAssertThrowsError ( try archiver. extract ( from: " /archive.tar.gz " , to: destination) ) { error in
47
+ await XCTAssertAsyncThrowsError ( try await archiver. extract ( from: " /archive.tar.gz " , to: destination) ) { error in
48
48
XCTAssertEqual ( error as? FileSystemError , FileSystemError ( . notDirectory, destination) )
49
49
}
50
50
}
51
51
52
- func testDestinationIsFile( ) throws {
52
+ func testDestinationIsFile( ) async {
53
53
let fileSystem = InMemoryFileSystem ( emptyFiles: " /archive.tar.gz " , " /destination " )
54
54
let archiver = TarArchiver ( fileSystem: fileSystem)
55
55
let destination = AbsolutePath ( " /destination " )
56
- XCTAssertThrowsError ( try archiver. extract ( from: " /archive.tar.gz " , to: destination) ) { error in
56
+ await XCTAssertAsyncThrowsError ( try await archiver. extract ( from: " /archive.tar.gz " , to: destination) ) { error in
57
57
XCTAssertEqual ( error as? FileSystemError , FileSystemError ( . notDirectory, destination) )
58
58
}
59
59
}
60
60
61
- func testInvalidArchive( ) throws {
62
- try testWithTemporaryDirectory { tmpdir in
61
+ func testInvalidArchive( ) async throws {
62
+ try await testWithTemporaryDirectory { tmpdir in
63
63
let archiver = TarArchiver ( fileSystem: localFileSystem)
64
64
let inputArchivePath = AbsolutePath ( #file) . parentDirectory
65
65
. appending ( components: " Inputs " , " invalid_archive.tar.gz " )
66
- XCTAssertThrowsError ( try archiver. extract ( from: inputArchivePath, to: tmpdir) ) { error in
66
+ await XCTAssertAsyncThrowsError ( try await archiver. extract ( from: inputArchivePath, to: tmpdir) ) { error in
67
67
#if os(Linux)
68
68
XCTAssertMatch ( ( error as? StringError ) ? . description, . contains( " not in gzip format " ) )
69
69
#else
@@ -73,39 +73,39 @@ final class TarArchiverTests: XCTestCase {
73
73
}
74
74
}
75
75
76
- func testValidation( ) throws {
76
+ func testValidation( ) async throws {
77
77
// valid
78
- try testWithTemporaryDirectory { _ in
78
+ try await testWithTemporaryDirectory { _ in
79
79
let archiver = TarArchiver ( fileSystem: localFileSystem)
80
80
let path = AbsolutePath ( #file) . parentDirectory
81
81
. appending ( components: " Inputs " , " archive.tar.gz " )
82
- XCTAssertTrue ( try archiver. validate ( path: path) )
82
+ try await XCTAssertAsyncTrue ( try await archiver. validate ( path: path) )
83
83
}
84
84
// invalid
85
- try testWithTemporaryDirectory { _ in
85
+ try await testWithTemporaryDirectory { _ in
86
86
let archiver = TarArchiver ( fileSystem: localFileSystem)
87
87
let path = AbsolutePath ( #file) . parentDirectory
88
88
. appending ( components: " Inputs " , " invalid_archive.tar.gz " )
89
- XCTAssertFalse ( try archiver. validate ( path: path) )
89
+ try await XCTAssertAsyncFalse ( try await archiver. validate ( path: path) )
90
90
}
91
91
// error
92
- try testWithTemporaryDirectory { _ in
92
+ try await testWithTemporaryDirectory { _ in
93
93
let archiver = TarArchiver ( fileSystem: localFileSystem)
94
94
let path = AbsolutePath . root. appending ( " does_not_exist.tar.gz " )
95
- XCTAssertThrowsError ( try archiver. validate ( path: path) ) { error in
95
+ await XCTAssertAsyncThrowsError ( try await archiver. validate ( path: path) ) { error in
96
96
XCTAssertEqual ( error as? FileSystemError , FileSystemError ( . noEntry, path) )
97
97
}
98
98
}
99
99
}
100
100
101
- func testCompress( ) throws {
101
+ func testCompress( ) async throws {
102
102
#if os(Linux)
103
103
guard SPM_posix_spawn_file_actions_addchdir_np_supported ( ) else {
104
104
throw XCTSkip ( " working directory not supported on this platform " )
105
105
}
106
106
#endif
107
107
108
- try testWithTemporaryDirectory { tmpdir in
108
+ try await testWithTemporaryDirectory { tmpdir in
109
109
let archiver = TarArchiver ( fileSystem: localFileSystem)
110
110
111
111
let rootDir = tmpdir. appending ( component: UUID ( ) . uuidString)
@@ -122,12 +122,12 @@ final class TarArchiverTests: XCTestCase {
122
122
try localFileSystem. writeFileContents ( dir2. appending ( " file4.txt " ) , string: " Hello World 4! " )
123
123
124
124
let archivePath = tmpdir. appending ( component: UUID ( ) . uuidString + " .tar.gz " )
125
- try archiver. compress ( directory: rootDir, to: archivePath)
125
+ try await archiver. compress ( directory: rootDir, to: archivePath)
126
126
XCTAssertFileExists ( archivePath)
127
127
128
128
let extractRootDir = tmpdir. appending ( component: UUID ( ) . uuidString)
129
129
try localFileSystem. createDirectory ( extractRootDir)
130
- try archiver. extract ( from: archivePath, to: extractRootDir)
130
+ try await archiver. extract ( from: archivePath, to: extractRootDir)
131
131
try localFileSystem. stripFirstLevel ( of: extractRootDir)
132
132
133
133
XCTAssertFileExists ( extractRootDir. appending ( " file1.txt " ) )
0 commit comments