Skip to content

Commit f161b02

Browse files
authored
Test: Enable most AsyncProcessTests (#8500)
Enable all but 3 tests. Some AsyncProcessTests call to `cat` and `echo` commands. Update the executable to be called correctly on Windows via the `cmd.exe /c` command, where the `cat` equivalent is `type`, which displays the file contents. Also, many tests call a script. We created a batch file, which simply calls the associated script invoked by python. Only 3 tests remain skipped. - one failed assertion on Windows - two otheers appear to have caused `swift test` tp hang. Related to: #8433 rdar://148248105
1 parent 553f135 commit f161b02

File tree

10 files changed

+202
-129
lines changed

10 files changed

+202
-129
lines changed

Package.swift

+6
Original file line numberDiff line numberDiff line change
@@ -815,11 +815,17 @@ let package = Package(
815815
"Archiver/Inputs/invalid_archive.tar.gz",
816816
"Archiver/Inputs/invalid_archive.zip",
817817
"processInputs/long-stdout-stderr",
818+
"processInputs/long-stdout-stderr.bat",
818819
"processInputs/exit4",
820+
"processInputs/exit4.bat",
819821
"processInputs/simple-stdout-stderr",
822+
"processInputs/simple-stdout-stderr.bat",
820823
"processInputs/deadlock-if-blocking-io",
824+
"processInputs/deadlock-if-blocking-io.bat",
821825
"processInputs/echo",
826+
"processInputs/echo.bat",
822827
"processInputs/in-to-out",
828+
"processInputs/in-to-out.bat",
823829
]
824830
),
825831
.testTarget(

Sources/Basics/Concurrency/AsyncProcess.swift

+14
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,20 @@ package final class AsyncProcess {
387387
self.loggingHandler = loggingHandler ?? AsyncProcess.loggingHandler
388388
}
389389

390+
package convenience init(
391+
args: [String],
392+
environment: Environment = .current,
393+
outputRedirection: OutputRedirection = .collect,
394+
loggingHandler: LoggingHandler? = .none
395+
) {
396+
self.init(
397+
arguments: args,
398+
environment: environment,
399+
outputRedirection: outputRedirection,
400+
loggingHandler: loggingHandler
401+
)
402+
}
403+
390404
package convenience init(
391405
args: String...,
392406
environment: Environment = .current,
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
This source file is part of the Swift.org open source project
3+
4+
Copyright (c) 2014 - 2025 Apple Inc. and the Swift project authors
5+
Licensed under Apache License v2.0 with Runtime Library Exception
6+
7+
See http://swift.org/LICENSE.txt for license information
8+
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
9+
*/
10+
11+
public import Foundation
12+
13+
public enum OperatingSystem: Hashable, Sendable {
14+
case macOS
15+
case windows
16+
case linux
17+
case android
18+
case unknown
19+
}
20+
21+
extension ProcessInfo {
22+
#if os(macOS)
23+
public static let hostOperatingSystem = OperatingSystem.macOS
24+
#elseif os(Linux)
25+
public static let hostOperatingSystem = OperatingSystem.linux
26+
#elseif os(Windows)
27+
public static let hostOperatingSystem = OperatingSystem.windows
28+
#else
29+
public static let hostOperatingSystem = OperatingSystem.unknown
30+
#endif
31+
32+
#if os(Windows)
33+
public static let EOL = "\r\n"
34+
#else
35+
public static let EOL = "\n"
36+
#endif
37+
38+
#if os(Windows)
39+
public static let exeSuffix = ".exe"
40+
#else
41+
public static let exeSuffix = ""
42+
#endif
43+
44+
#if os(Windows)
45+
public static let batSuffix = ".bat"
46+
#else
47+
public static let batSuffix = ""
48+
#endif
49+
}

0 commit comments

Comments
 (0)