-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SubprocessStdoutTests on Windows (#3289)
The `echo` command isn't standalone in Windows, so it has to be called through `cmd.exe` for example. Interestingly the `echo abc >&2` prints a space at the end of line, while linux doesnt.. Pull request: #3289 --------- Co-authored-by: Tobias Roeser <[email protected]>
- Loading branch information
Showing
2 changed files
with
20 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,31 @@ | ||
import scala.util.Properties | ||
import mill._ | ||
|
||
|
||
def inheritInterleaved = T { | ||
for (i <- Range.inclusive(1, 9)) { | ||
println("print stdout" + i) | ||
os.proc("echo", "proc stdout" + i).call(stdout = os.Inherit) | ||
val echoCommandStdout = | ||
if (Properties.isWin) Seq("cmd.exe", "/C", s"echo proc stdout${i}") | ||
else Seq("echo", s"proc stdout${i}") | ||
os.proc(echoCommandStdout).call(stdout = os.Inherit) | ||
System.err.println("print stderr" + i) | ||
os.proc("bash", "-c", s"echo proc stderr${i} >&2").call(stderr = os.Inherit) | ||
val echoCommandStderr = | ||
if (Properties.isWin) Seq("cmd.exe", "/C", s"echo proc stderr${i}>&2") | ||
else Seq("bash", "-c", s"echo proc stderr${i} >&2") | ||
os.proc(echoCommandStderr).call(stderr = os.Inherit) | ||
} | ||
} | ||
|
||
def inheritRaw = T{ | ||
println("print stdoutRaw") | ||
os.proc("echo", "proc stdoutRaw").call(stdout = os.InheritRaw) | ||
val echoCommandStdoutRaw = | ||
if (Properties.isWin) Seq("cmd.exe", "/C", "echo proc stdoutRaw") | ||
else Seq("echo", "proc stdoutRaw") | ||
os.proc(echoCommandStdoutRaw).call(stdout = os.InheritRaw) | ||
System.err.println("print stderrRaw") | ||
os.proc("bash", "-c", "echo proc stderrRaw >&2").call(stderr = os.InheritRaw) | ||
val echoCommandStderrRaw = | ||
if (Properties.isWin) Seq("cmd.exe", "/C", "echo proc stderrRaw>&2") | ||
else Seq("bash", "-c", "echo proc stderrRaw >&2") | ||
os.proc(echoCommandStderrRaw).call(stderr = os.InheritRaw) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters