From 53a16770d01b0235a33e8faa474b1b80dd00d029 Mon Sep 17 00:00:00 2001 From: Thomas Zoechling Date: Sun, 9 Jun 2024 10:59:13 +0200 Subject: [PATCH] Debug Linux test --- .../ZIPFoundation/Archive+MemoryFile.swift | 1 + Sources/ZIPFoundation/Archive.swift | 4 ++-- .../ZIPFoundationMemoryTests.swift | 19 +++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Sources/ZIPFoundation/Archive+MemoryFile.swift b/Sources/ZIPFoundation/Archive+MemoryFile.swift index e869f73b..08ae82a9 100644 --- a/Sources/ZIPFoundation/Archive+MemoryFile.swift +++ b/Sources/ZIPFoundation/Archive+MemoryFile.swift @@ -98,6 +98,7 @@ private func closeStub(_ cookie: UnsafeMutableRawPointer?) -> Int32 { } #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) || os(Android) + private func readStub(_ cookie: UnsafeMutableRawPointer?, _ bytePtr: UnsafeMutablePointer?, _ count: Int32) -> Int32 { diff --git a/Sources/ZIPFoundation/Archive.swift b/Sources/ZIPFoundation/Archive.swift index 89b71c11..53d3950b 100644 --- a/Sources/ZIPFoundation/Archive.swift +++ b/Sources/ZIPFoundation/Archive.swift @@ -176,7 +176,7 @@ public final class Archive: Sequence { setvbuf(self.archiveFile, nil, _IOFBF, Int(defaultPOSIXBufferSize)) } -#if swift(>=5.0) + #if swift(>=5.0) var memoryFile: MemoryFile? /// Initializes a new in-memory ZIP `Archive`. @@ -204,7 +204,7 @@ public final class Archive: Sequence { self.endOfCentralDirectoryRecord = config.endOfCentralDirectoryRecord self.zip64EndOfCentralDirectory = config.zip64EndOfCentralDirectory } -#endif + #endif deinit { fclose(self.archiveFile) diff --git a/Tests/ZIPFoundationTests/ZIPFoundationMemoryTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationMemoryTests.swift index 6f9dfd77..eb24b943 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationMemoryTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationMemoryTests.swift @@ -114,13 +114,13 @@ extension ZIPFoundationTests { let data = Data.makeRandomData(size: 1024) XCTAssertSwiftError(try Archive(data: data, accessMode: .read), throws: Archive.ArchiveError.missingEndOfCentralDirectoryRecord) -// let archive = self.memoryArchive(for: #function, mode: .create) -// let replacementArchive = self.memoryArchive(for: #function, mode: .read) -// replacementArchive.memoryFile = nil -// XCTAssertSwiftError( -// try archive.replaceCurrentArchive(with: replacementArchive), -// throws: Archive.ArchiveError.unwritableArchive -// ) + let archive = self.memoryArchive(for: #function, mode: .create) + let replacementArchive = self.memoryArchive(for: #function, mode: .read) + //replacementArchive.memoryFile = nil + XCTAssertSwiftError( + try archive.replaceCurrentArchive(with: replacementArchive), + throws: Archive.ArchiveError.unwritableArchive + ) } func testReadOnlyFile() { @@ -192,9 +192,8 @@ extension ZIPFoundationTests { sourceArchiveURL.appendPathExtension("zip") do { let data = mode == .create ? Data() : try Data(contentsOf: sourceArchiveURL) - let archive = try Archive(data: data, accessMode: mode, - pathEncoding: pathEncoding) - return archive + return try Archive(data: data, accessMode: mode, + pathEncoding: pathEncoding) } catch { XCTFail("Failed to open memory archive for '\(sourceArchiveURL.lastPathComponent)'") type(of: self).tearDown()