mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 17:39:46 +00:00
update sub_instance.lua test
This commit is contained in:
parent
6034c4933f
commit
0f954805e1
1 changed files with 9 additions and 1 deletions
|
|
@ -5,18 +5,26 @@ local log_path = "config:subprocess.log"
|
|||
|
||||
file.write(script_path, [[
|
||||
debug.log("hello from sub-instance")
|
||||
sleep(1)
|
||||
]])
|
||||
|
||||
local handle = app.start_background_instance(script_path, log_path)
|
||||
assert(handle >= 0)
|
||||
|
||||
local stdin = app.get_stdin_stream(handle)
|
||||
assert(stdin ~= nil)
|
||||
stdin:write_line("sub_instance_test")
|
||||
stdin:flush()
|
||||
|
||||
app.sleep_until(function() return not app.is_instance_alive(handle) end)
|
||||
assert(not app.is_instance_alive(handle))
|
||||
|
||||
local stdout = app.get_stdout_stream(handle)
|
||||
assert(stdout ~= nil)
|
||||
local output = table.concat(stdout:read(1e6), '\n')
|
||||
local output = table.concat(table.map(stdout:read(1e6), function(_, line) return "<sub>"..line end), '\n')
|
||||
print(output)
|
||||
assert(output and output:find("hello from sub-instance", 1, true) ~= nil)
|
||||
assert(output and output:find('stdin-cmd] unknown command "sub_instance_test"', 1, true) ~= nil)
|
||||
stdout:close()
|
||||
|
||||
file.remove(script_path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue