mirror of
https://github.com/lune-org/lune.git
synced 2025-04-19 19:34:02 +01:00
fix: address todo comments
This commit is contained in:
parent
70583c6bf8
commit
a30380cba8
3 changed files with 3 additions and 34 deletions
|
@ -224,7 +224,6 @@ async fn process_spawn(
|
||||||
.expect("ExitCode receiver was unexpectedly dropped");
|
.expect("ExitCode receiver was unexpectedly dropped");
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: Remove the lua errors since we no longer accept stdio options for spawn
|
|
||||||
TableBuilder::new(lua)?
|
TableBuilder::new(lua)?
|
||||||
.with_value(
|
.with_value(
|
||||||
"stdout",
|
"stdout",
|
||||||
|
@ -232,9 +231,7 @@ async fn process_spawn(
|
||||||
stdout_rx
|
stdout_rx
|
||||||
.await
|
.await
|
||||||
.expect("Stdout sender unexpectedly dropped")
|
.expect("Stdout sender unexpectedly dropped")
|
||||||
.ok_or(LuaError::runtime(
|
.unwrap(),
|
||||||
"Cannot read from stdout when it is not piped",
|
|
||||||
))?,
|
|
||||||
),
|
),
|
||||||
)?
|
)?
|
||||||
.with_value(
|
.with_value(
|
||||||
|
@ -243,9 +240,7 @@ async fn process_spawn(
|
||||||
stderr_rx
|
stderr_rx
|
||||||
.await
|
.await
|
||||||
.expect("Stderr sender unexpectedly dropped")
|
.expect("Stderr sender unexpectedly dropped")
|
||||||
.ok_or(LuaError::runtime(
|
.unwrap(),
|
||||||
"Cannot read from stderr when it is not piped",
|
|
||||||
))?,
|
|
||||||
),
|
),
|
||||||
)?
|
)?
|
||||||
.with_value(
|
.with_value(
|
||||||
|
@ -284,10 +279,6 @@ async fn spawn_command(
|
||||||
let stderr = options.stdio.stderr;
|
let stderr = options.stdio.stderr;
|
||||||
let stdin = options.stdio.stdin.take();
|
let stdin = options.stdio.stdin.take();
|
||||||
|
|
||||||
// TODO: Have an stdin_kind which the user can supply as piped or not
|
|
||||||
// TODO: Maybe even revamp the stdout/stderr kinds? User should only use
|
|
||||||
// piped when they are sure they want to read the stdout. Currently we default
|
|
||||||
// to piped
|
|
||||||
let mut child = options
|
let mut child = options
|
||||||
.into_command(program, args)
|
.into_command(program, args)
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
|
|
22
test.lua
22
test.lua
|
@ -1,22 +0,0 @@
|
||||||
local process = require("@lune/process")
|
|
||||||
local stdio = require("@lune/stdio")
|
|
||||||
local task = require("@lune/task")
|
|
||||||
local child = process.spawn("echo", { "lsp" })
|
|
||||||
task.wait(1)
|
|
||||||
|
|
||||||
|
|
||||||
stdio.write(buffer.tostring(child.stdout:readToEnd()))
|
|
||||||
stdio.write(buffer.tostring(child.stdout:readToEnd()))
|
|
||||||
stdio.write(buffer.tostring(child.stdout:readToEnd()))
|
|
||||||
|
|
||||||
-- while true do
|
|
||||||
-- child.stdin:write("hello world")
|
|
||||||
-- local buf = child.stdout:read()
|
|
||||||
|
|
||||||
-- if buffer.len(buf) == 0 then
|
|
||||||
-- break
|
|
||||||
-- end
|
|
||||||
|
|
||||||
-- stdio.write(buffer.tostring(buf) .. "\n")
|
|
||||||
-- -- stdio.write(buffer.tostring(child.stderr:read() .. child.stderr:read() .. child.stderr:read() .. child.stderr:read()))
|
|
||||||
-- end
|
|
|
@ -13,6 +13,6 @@ for _ = 1, SAMPLES do
|
||||||
local delta = os.time() - start
|
local delta = os.time() - start
|
||||||
assert(
|
assert(
|
||||||
delta <= 1,
|
delta <= 1,
|
||||||
`Spawning a child process should not block the main thread, process.spawn took {delta}s to return it should return immediately`
|
`Spawning a child process should not block the main thread, process.spawn took {delta}s to return when it should return immediately`
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue