mirror of
https://github.com/lune-org/lune.git
synced 2025-05-04 10:43:57 +01:00
Try actually writing the stdin to stdout in powershell
This commit is contained in:
parent
27409f1bf4
commit
0954730646
1 changed files with 8 additions and 5 deletions
|
@ -2,12 +2,13 @@ local process = require("@lune/process")
|
||||||
|
|
||||||
local expected = "Hello from child process!"
|
local expected = "Hello from child process!"
|
||||||
|
|
||||||
-- NOTE: This requires "bash" to be installed even for Windows
|
|
||||||
-- users, testing a simple cat from stdin to stdout using pwsh
|
|
||||||
-- has unfortunately proved to be a significant challenge...
|
|
||||||
local options = { stdio = { stdin = expected } }
|
local options = { stdio = { stdin = expected } }
|
||||||
local result = if process.os == "windows"
|
local result = if process.os == "windows"
|
||||||
then process.exec("powershell", { "-Command", "[System.Console]::In.ReadToEnd()" }, options)
|
then process.exec(
|
||||||
|
"powershell",
|
||||||
|
{ "-Command", "[System.Console]::Write([System.Console]::In.ReadToEnd())" },
|
||||||
|
options
|
||||||
|
)
|
||||||
else process.exec("bash", { "-c", "cat" }, options)
|
else process.exec("bash", { "-c", "cat" }, options)
|
||||||
|
|
||||||
local resultStdout = result.stdout
|
local resultStdout = result.stdout
|
||||||
|
@ -15,5 +16,7 @@ resultStdout = string.gsub(resultStdout, "^%s+", "") -- Trim leading whitespace
|
||||||
resultStdout = string.gsub(resultStdout, "%s+$", "") -- Trim trailing whitespace
|
resultStdout = string.gsub(resultStdout, "%s+$", "") -- Trim trailing whitespace
|
||||||
assert(
|
assert(
|
||||||
resultStdout == expected,
|
resultStdout == expected,
|
||||||
"Stdin passing did not return proper output!" .. `\nExpected: {expected}` .. `\nReceived: {resultStdout}`
|
"Passing a string to stdin did not return the expected output!"
|
||||||
|
.. `\nExpected: {expected}`
|
||||||
|
.. `\nReceived: {resultStdout}`
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Reference in a new issue