Skip to content
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
8 changes: 5 additions & 3 deletions Sources/Subprocess/Configuration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,11 @@ public struct Executable: Sendable, Hashable {
return .init(_config: .path(filePath))
}
/// Resolves the full executable path using the given environment.
public func resolveExecutablePath(in environment: Environment) throws(SubprocessError) -> FilePath {
let path = try self.resolveExecutablePath(withPathValue: environment.pathValue())
return FilePath(path)
public func resolveExecutablePath(in environment: Environment) async throws(SubprocessError) -> FilePath {
try await runOnBackgroundThread { () throws(SubprocessError) -> FilePath in
let path = try self.resolveExecutablePath(withPathValue: environment.pathValue())
return FilePath(path)
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions Tests/SubprocessTests/LinterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import SystemPackage
#endif
@testable import Subprocess

private func enableLintingTest() -> Bool {
private func enableLintingTest() async -> Bool {
guard CommandLine.arguments.first(where: { $0.contains("/.build/") }) != nil else {
return false
}
#if os(macOS)
// Use xcrun
do {
_ = try Executable.path("/usr/bin/xcrun")
_ = try await Executable.path("/usr/bin/xcrun")
.resolveExecutablePath(in: .inherit)
return true
} catch {
Expand All @@ -34,7 +34,7 @@ private func enableLintingTest() -> Bool {
#else
// Use swift-format directly
do {
_ = try Executable.name("swift-format")
_ = try await Executable.name("swift-format")
.resolveExecutablePath(in: .inherit)
return true
} catch {
Expand Down
6 changes: 4 additions & 2 deletions Tests/SubprocessTests/TestSupport.swift
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,10 @@ extension Trait where Self == ConditionTrait {
/// This test requires bash to run (instead of sh)
static var requiresBash: Self {
enabled(
if: (try? Executable.name("bash").resolveExecutablePath(in: .inherit)) != nil,
"This test requires bash (install `bash` package on Linux/BSD)"
"This test requires bash (install `bash` package on Linux/BSD)",
{
(try? await Executable.name("bash").resolveExecutablePath(in: .inherit)) != nil
}
)
}
}
12 changes: 8 additions & 4 deletions Tests/SubprocessTests/UnixTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ extension SubprocessUnixTests {
"This test requires root privileges"
),
.enabled(
if: (try? Executable.name("ps").resolveExecutablePath(in: .inherit)) != nil,
"This test requires ps (install procps package on Debian or RedHat Linux distros)"
"This test requires ps (install procps package on Debian or RedHat Linux distros)",
{
(try? await Executable.name("ps").resolveExecutablePath(in: .inherit)) != nil
}
)
)
func testSubprocessPlatformOptionsProcessGroupID() async throws {
Expand All @@ -145,8 +147,10 @@ extension SubprocessUnixTests {

@Test(
.enabled(
if: (try? Executable.name("ps").resolveExecutablePath(in: .inherit)) != nil,
"This test requires ps (install procps package on Debian or RedHat Linux distros)"
"This test requires ps (install procps package on Debian or RedHat Linux distros)",
{
(try? await Executable.name("ps").resolveExecutablePath(in: .inherit)) != nil
}
)
)
func testSubprocessPlatformOptionsCreateSession() async throws {
Expand Down
Loading