Skip to content

Commit a253651

Browse files
committed
Test: Enable most AsyncProcessTests
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. Depends on: #8495 Related to: #8433 rdar://148248105
1 parent 1cc14bd commit a253651

File tree

10 files changed

+158
-128
lines changed

10 files changed

+158
-128
lines changed

Package.swift

+6
Original file line numberDiff line numberDiff line change
@@ -795,11 +795,17 @@ let package = Package(
795795
"Archiver/Inputs/invalid_archive.tar.gz",
796796
"Archiver/Inputs/invalid_archive.zip",
797797
"processInputs/long-stdout-stderr",
798+
"processInputs/long-stdout-stderr.bat",
798799
"processInputs/exit4",
800+
"processInputs/exit4.bat",
799801
"processInputs/simple-stdout-stderr",
802+
"processInputs/simple-stdout-stderr.bat",
800803
"processInputs/deadlock-if-blocking-io",
804+
"processInputs/deadlock-if-blocking-io.bat",
801805
"processInputs/echo",
806+
"processInputs/echo.bat",
802807
"processInputs/in-to-out",
808+
"processInputs/in-to-out.bat",
803809
]
804810
),
805811
.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,

Sources/_InternalTestSupport/Process.swift

+6
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,10 @@ extension ProcessInfo {
4040
#else
4141
public static let exeSuffix = ""
4242
#endif
43+
44+
#if os(Windows)
45+
public static let batSuffix = ".bat"
46+
#else
47+
public static let batSuffix = ""
48+
#endif
4349
}

Tests/BasicsTests/AsyncProcessTests.swift

+121-128
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
python %~dp0deadlock-if-blocking-io
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
python %~dp0echo
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
EXIT /B 4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
python %~dp0in-to-out
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
python %~dp0long-stdout-stderr
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
@echo off
2+
python %~dp0simple-stdout-stderr

0 commit comments

Comments
 (0)