mirror of
https://github.com/lune-org/lune.git
synced 2024-12-12 13:00:37 +00:00
28 lines
838 B
Lua
28 lines
838 B
Lua
local process = require("@lune/process")
|
|
local stdio = require("@lune/stdio")
|
|
local task = require("@lune/task")
|
|
|
|
-- Spawning a child process should work, with options
|
|
|
|
local thread = task.delay(1, function()
|
|
stdio.ewrite("Spawning a process should take a reasonable amount of time\n")
|
|
task.wait(1)
|
|
process.exit(1)
|
|
end)
|
|
|
|
local IS_WINDOWS = process.os == "windows"
|
|
|
|
local result = process.spawn(
|
|
if IS_WINDOWS then "cmd" else "ls",
|
|
if IS_WINDOWS then { "/c", "dir" } else { "-a" }
|
|
)
|
|
|
|
task.cancel(thread)
|
|
|
|
assert(result.ok, "Failed to spawn child process")
|
|
|
|
assert(result.stderr == "", "Stderr was not empty")
|
|
assert(result.stdout ~= "", "Stdout was empty")
|
|
|
|
assert(string.find(result.stdout, "Cargo.toml") ~= nil, "Missing Cargo.toml in output")
|
|
assert(string.find(result.stdout, ".gitignore") ~= nil, "Missing .gitignore in output")
|