Skip to content

Test: Enable most AsyncProcessTests #8500

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
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
6 changes: 6 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -795,11 +795,17 @@ let package = Package(
"Archiver/Inputs/invalid_archive.tar.gz",
"Archiver/Inputs/invalid_archive.zip",
"processInputs/long-stdout-stderr",
"processInputs/long-stdout-stderr.bat",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be simpler to call python on the python file on all platforms? ["python3", "long-stdout-stderr"]?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would require adding a host dependency on the test, and we are unable to guarantee that python will be installed on the host.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the bat scripts run python. And python is a dependency of the Swift package (for lldb).

"processInputs/exit4",
"processInputs/exit4.bat",
"processInputs/simple-stdout-stderr",
"processInputs/simple-stdout-stderr.bat",
"processInputs/deadlock-if-blocking-io",
"processInputs/deadlock-if-blocking-io.bat",
"processInputs/echo",
"processInputs/echo.bat",
"processInputs/in-to-out",
"processInputs/in-to-out.bat",
]
),
.testTarget(
Expand Down
14 changes: 14 additions & 0 deletions Sources/Basics/Concurrency/AsyncProcess.swift
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,20 @@ package final class AsyncProcess {
self.loggingHandler = loggingHandler ?? AsyncProcess.loggingHandler
}

package convenience init(
args: [String],
environment: Environment = .current,
outputRedirection: OutputRedirection = .collect,
loggingHandler: LoggingHandler? = .none
) {
self.init(
arguments: args,
environment: environment,
outputRedirection: outputRedirection,
loggingHandler: loggingHandler
)
}

package convenience init(
args: String...,
environment: Environment = .current,
Expand Down
49 changes: 49 additions & 0 deletions Sources/_InternalTestSupport/Process.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
This source file is part of the Swift.org open source project

Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception

See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/

public import Foundation

public enum OperatingSystem: Hashable, Sendable {
case macOS
case windows
case linux
case android
case unknown
}

extension ProcessInfo {
#if os(macOS)
public static let hostOperatingSystem = OperatingSystem.macOS
#elseif os(Linux)
public static let hostOperatingSystem = OperatingSystem.linux
#elseif os(Windows)
public static let hostOperatingSystem = OperatingSystem.windows
#else
public static let hostOperatingSystem = OperatingSystem.unknown
#endif

#if os(Windows)
public static let EOL = "\r\n"
#else
public static let EOL = "\n"
#endif

#if os(Windows)
public static let exeSuffix = ".exe"
#else
public static let exeSuffix = ""
#endif

#if os(Windows)
public static let batSuffix = ".bat"
#else
public static let batSuffix = ""
#endif
}
Loading