cc-libs/tools/trap-sandbox/test-integration/lua/full-boot.lua
2026-06-15 20:06:45 +02:00

31 lines
1.0 KiB
Lua

-- Full-boot e2e: replicate the real boot path (startup/boot.lua) closely enough
-- to prove the whole stack works end to end. Sets the sandbox.* settings, creates
-- the global event loop, runs the REAL servers/sandbox.lua daemon, then under
-- parallel waits for the connection and runs the REAL `sandbox health` program.
--
-- Args (via shell.run): url, secret ('' => none).
-- NOTE: shell.run drops empty-string args; the harness passes '-' for "no secret".
local args = { ... };
local url = args[1];
local secret = args[2];
settings.set('sandbox.url', url);
if secret and secret ~= '' and secret ~= '-' then
settings.set('sandbox.password', secret);
end
_G.bootEventLoop = require('/apis/eventloop')();
-- Start the real daemon (reads sandbox.url/sandbox.password, opens the WS).
shell.run('/servers/sandbox.lua');
parallel.waitForAny(
function() _G.bootEventLoop.runLoop(true); end,
function()
os.pullEvent('trapos_sandbox_connected');
shell.run('/programs/sandbox.lua', 'health');
end
);
os.shutdown();