From efb95e0f4d4e026b63209c48f59e9c9ca59cb29c Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Mon, 30 May 2016 15:06:38 +0100 Subject: Ensure that supple works during gitano-setup to early-warn if something's odd --- bin/gitano-setup.in | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'bin') diff --git a/bin/gitano-setup.in b/bin/gitano-setup.in index 038276c..b39a6b5 100644 --- a/bin/gitano-setup.in +++ b/bin/gitano-setup.in @@ -62,6 +62,40 @@ end gitano.log.chat("Welcome to the Gitano setup process") +gitano.log.chat("Performing system checks") + +-- Check that Supple functions properly +local ok, msg = pcall(function() + gitano.log.chat("... Checking supple sandboxing") + local s = require 'supple' + local ok, a, b, c = s.host.run("return ...", "test", 12, 'hello', true) + if not ok then + gitano.log.chat("... Supple unable to run trivial sandboxed code") + os.exit(1) + end + if a ~= 12 or b ~= "hello" or c ~= true then + gitano.log.chat("... Supple unable to pass trivial values in and out") + os.exit(1) + end + local ok, v = s.host.run("local a = ...\nreturn a.banana", "test", {banana=14}) + if not ok then + gitano.log.chat("... Supple unable to run trivial sandboxed code") + os.exit(1) + end + if v ~= 14 then + gitano.log.chat("... Supple unable to communicate bidirectionally") + os.exit(1) + end +end) + +if not ok then + gitano.log.chat("... Unable to run supple test") + gitano.log.chat("... " .. tostring(msg)) + os.exit(1) +end + +gitano.log.chat("System checks out") + function get(key) return conf.settings[key] end -- cgit v1.2.1