Skip to content

Revert "Avoid use of temp_await in PackageRegistryToolTests.swift" #7169

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions Sources/Basics/Archiver/Archiver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,6 @@ public protocol Archiver {
}

extension Archiver {
/// Asynchronously extracts the contents of an archive to a destination folder.
///
/// - Parameters:
/// - archivePath: The `AbsolutePath` to the archive to extract.
/// - destinationPath: The `AbsolutePath` to the directory to extract to.
public func extract(
from archivePath: AbsolutePath,
to destinationPath: AbsolutePath
Expand All @@ -85,31 +80,5 @@ extension Archiver {
try await safe_async {
self.validate(path: path, completion: $0)
}
}

/// Asynchronously compresses the contents of a directory to a destination archive.
///
/// - Parameters:
/// - directory: The `AbsolutePath` to the archive to extract.
/// - destinationPath: The `AbsolutePath` to the directory to extract to.
public func compress(
directory: AbsolutePath,
to destinationPath: AbsolutePath
) async throws {
try await withCheckedThrowingContinuation {
self.compress(directory: directory, to: destinationPath, completion: $0.resume(with:))
}
}

/// Asynchronously validates if a file is an archive.
///
/// - Parameters:
/// - path: The `AbsolutePath` to the archive to validate.
public func validate(
path: AbsolutePath
) async throws -> Bool {
try await withCheckedThrowingContinuation {
self.validate(path: path, completion: $0.resume(with:))
}
}
}
22 changes: 11 additions & 11 deletions Tests/CommandsTests/PackageRegistryToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ final class PackageRegistryToolTests: CommandsTestCase {

// TODO: Test example with login and password

func testArchiving() async throws {
func testArchiving() throws {
#if os(Linux)
// needed for archiving
guard SPM_posix_spawn_file_actions_addchdir_np_supported() else {
Expand All @@ -293,7 +293,7 @@ final class PackageRegistryToolTests: CommandsTestCase {
let metadataFilename = SwiftPackageRegistryTool.Publish.metadataFilename

// git repo
try await withTemporaryDirectory { temporaryDirectory in
try withTemporaryDirectory { temporaryDirectory in
let packageDirectory = temporaryDirectory.appending("MyPackage")
try localFileSystem.createDirectory(packageDirectory)

Expand All @@ -320,12 +320,12 @@ final class PackageRegistryToolTests: CommandsTestCase {
observabilityScope: observability.topScope
)

try await validatePackageArchive(at: archivePath)
try validatePackageArchive(at: archivePath)
XCTAssertTrue(archivePath.isDescendant(of: workingDirectory))
}

// not a git repo
try await withTemporaryDirectory { temporaryDirectory in
try withTemporaryDirectory { temporaryDirectory in
let packageDirectory = temporaryDirectory.appending("MyPackage")
try localFileSystem.createDirectory(packageDirectory)

Expand All @@ -350,11 +350,11 @@ final class PackageRegistryToolTests: CommandsTestCase {
observabilityScope: observability.topScope
)

try await validatePackageArchive(at: archivePath)
try validatePackageArchive(at: archivePath)
}

// canonical metadata location
try await withTemporaryDirectory { temporaryDirectory in
try withTemporaryDirectory { temporaryDirectory in
let packageDirectory = temporaryDirectory.appending("MyPackage")
try localFileSystem.createDirectory(packageDirectory)

Expand Down Expand Up @@ -385,17 +385,17 @@ final class PackageRegistryToolTests: CommandsTestCase {
observabilityScope: observability.topScope
)

let extractedPath = try await validatePackageArchive(at: archivePath)
let extractedPath = try validatePackageArchive(at: archivePath)
XCTAssertFileExists(extractedPath.appending(component: metadataFilename))
}

@discardableResult
func validatePackageArchive(at archivePath: AbsolutePath) async throws -> AbsolutePath {
func validatePackageArchive(at archivePath: AbsolutePath) throws -> AbsolutePath {
XCTAssertFileExists(archivePath)
let archiver = ZipArchiver(fileSystem: localFileSystem)
let extractPath = archivePath.parentDirectory.appending(component: UUID().uuidString)
try localFileSystem.createDirectory(extractPath)
try await archiver.extract(from: archivePath, to: extractPath)
try temp_await { archiver.extract(from: archivePath, to: extractPath, completion: $0) }
try localFileSystem.stripFirstLevel(of: extractPath)
XCTAssertFileExists(extractPath.appending("Package.swift"))
return extractPath
Expand Down Expand Up @@ -550,7 +550,7 @@ final class PackageRegistryToolTests: CommandsTestCase {
let archiver = ZipArchiver(fileSystem: localFileSystem)
let extractPath = archivePath.parentDirectory.appending(component: UUID().uuidString)
try localFileSystem.createDirectory(extractPath)
try await archiver.extract(from: archivePath, to: extractPath)
try temp_await { archiver.extract(from: archivePath, to: extractPath, completion: $0) }
try localFileSystem.stripFirstLevel(of: extractPath)

let manifestInArchive = try localFileSystem.readFileContents(extractPath.appending(manifestFile)).contents
Expand Down Expand Up @@ -963,7 +963,7 @@ final class PackageRegistryToolTests: CommandsTestCase {
let archiver = ZipArchiver(fileSystem: localFileSystem)
let extractPath = archivePath.parentDirectory.appending(component: UUID().uuidString)
try localFileSystem.createDirectory(extractPath)
try await archiver.extract(from: archivePath, to: extractPath)
try temp_await { archiver.extract(from: archivePath, to: extractPath, completion: $0) }
try localFileSystem.stripFirstLevel(of: extractPath)

let manifestSignature = try ManifestSignatureParser.parse(
Expand Down