mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
Fix panic when spawning a program that does not exist
This commit is contained in:
parent
1fd17ca0b3
commit
adc74f47c0
3 changed files with 9 additions and 4 deletions
|
@ -145,10 +145,7 @@ async fn process_spawn(
|
||||||
lua: &Lua,
|
lua: &Lua,
|
||||||
(program, args, options): (String, Option<Vec<String>>, ProcessSpawnOptions),
|
(program, args, options): (String, Option<Vec<String>>, ProcessSpawnOptions),
|
||||||
) -> LuaResult<LuaTable> {
|
) -> LuaResult<LuaTable> {
|
||||||
let res = lua
|
let res = lua.spawn(spawn_command(program, args, options)).await?;
|
||||||
.spawn(spawn_command(program, args, options))
|
|
||||||
.await
|
|
||||||
.expect("Failed to receive result of spawned process");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
NOTE: If an exit code was not given by the child process,
|
NOTE: If an exit code was not given by the child process,
|
||||||
|
|
|
@ -140,6 +140,7 @@ create_tests! {
|
||||||
process_spawn_async: "process/spawn/async",
|
process_spawn_async: "process/spawn/async",
|
||||||
process_spawn_basic: "process/spawn/basic",
|
process_spawn_basic: "process/spawn/basic",
|
||||||
process_spawn_cwd: "process/spawn/cwd",
|
process_spawn_cwd: "process/spawn/cwd",
|
||||||
|
process_spawn_no_panic: "process/spawn/no_panic",
|
||||||
process_spawn_shell: "process/spawn/shell",
|
process_spawn_shell: "process/spawn/shell",
|
||||||
process_spawn_stdin: "process/spawn/stdin",
|
process_spawn_stdin: "process/spawn/stdin",
|
||||||
process_spawn_stdio: "process/spawn/stdio",
|
process_spawn_stdio: "process/spawn/stdio",
|
||||||
|
|
7
tests/process/spawn/no_panic.luau
Normal file
7
tests/process/spawn/no_panic.luau
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
local process = require("@lune/process")
|
||||||
|
|
||||||
|
-- Spawning a child process for a non-existent
|
||||||
|
-- program should not panic, but should error
|
||||||
|
|
||||||
|
local success = pcall(process.spawn, "someProgramThatDoesNotExist")
|
||||||
|
assert(not success, "Spawned a non-existent program")
|
Loading…
Reference in a new issue