mirror of
https://github.com/MihailRis/voxelcore.git
synced 2026-11-20 09:29:44 +00:00
add sub_instance.lua test
This commit is contained in:
parent
0340e2977e
commit
b888847722
1 changed files with 23 additions and 0 deletions
23
dev/tests/sub_instance.lua
Normal file
23
dev/tests/sub_instance.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
app.create_memory_device("memtest")
|
||||
|
||||
local script_path = "config:subprocess.lua"
|
||||
local log_path = "config:subprocess.log"
|
||||
|
||||
file.write(script_path, [[
|
||||
debug.log("hello from sub-instance")
|
||||
]])
|
||||
|
||||
local handle = app.start_background_instance(script_path, log_path)
|
||||
assert(handle >= 0)
|
||||
|
||||
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')
|
||||
assert(output and output:find("hello from sub-instance", 1, true) ~= nil)
|
||||
stdout:close()
|
||||
|
||||
file.remove(script_path)
|
||||
assert(not app.terminate_instance(handle))
|
||||
Loading…
Add table
Add a link
Reference in a new issue