summaryrefslogtreecommitdiff
path: root/testing/gitano-test-tool.in
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@gmail.com>2016-12-18 16:53:07 +0000
committerRichard Maw <richard.maw@gmail.com>2016-12-18 16:53:07 +0000
commit3d0a66f439f849fe5e6e3a20b6197145a45d9b9f (patch)
tree3cfd0615de90d296fc04de0a4b3c923e934dd7e9 /testing/gitano-test-tool.in
parent54da504203734e7ee4f1acb7d1da98a70fed8e86 (diff)
downloadgitano-3d0a66f439f849fe5e6e3a20b6197145a45d9b9f.tar.gz
testing: Run lighttpd during http tests
Diffstat (limited to 'testing/gitano-test-tool.in')
-rw-r--r--testing/gitano-test-tool.in39
1 files changed, 39 insertions, 0 deletions
diff --git a/testing/gitano-test-tool.in b/testing/gitano-test-tool.in
index 4056935..a5154b9 100644
--- a/testing/gitano-test-tool.in
+++ b/testing/gitano-test-tool.in
@@ -189,9 +189,48 @@ function cmd_setupstandard(owning_user, master_key, bypass_key)
exe = gitano.config.lib_bin_path() .. "/gitano-setup",
env = { HOME = user_home(owning_user) }
}
+ if os.getenv("GTT_PROTO") == "http" then
+ -- setup lighttpd
+ local pid_file = basedir .. "lighttpd.pid"
+ local port_file = basedir .. "lighttpd.port"
+ local docroot = basedir .. "docroot"
+ local lighttpd_conf = basedir .. "lighttpd.conf"
+ local port = tonumber(os.getenv("HTTP_FIRST_TEST_PORT")) or 8080
+ local how, why
+ for repetition=1, 10 do
+ local fh = io.open(lighttpd_conf, "w+")
+ fh:write(('server.modules = ( "mod_cgi" )\n'))
+ fh:write(('server.pid-file = %q\n'):format(pid_file))
+ fh:write(('server.document-root = %q\n'):format(docroot))
+ fh:write(('server.port = %d\n'):format(port))
+ fh:close()
+ local proc = sp.spawn_simple {
+ "lighttpd", "-f", lighttpd_conf,
+ }
+ how, why = proc:wait()
+ port = port + 1
+ if how == "exit" and why == 0 then
+ break
+ end
+ end
+ if how == -1 then
+ unix_assert(how, why)
+ end
+ if how ~= "exit" or why ~= 0 then
+ io.stderr:write("Failed to spawn lighttpd server after 10 retries: "
+ .. how .. ":" .. tostring(why) .. "\n")
+ os.exit(1)
+ end
+ end
end
function cmd_teardownstandard()
+ if os.getenv("GTT_PROTO") == "http" then
+ local pid_file = basedir .. "lighttpd.pid"
+ run_program {
+ "pkill", "-9", "-F", pid_file,
+ }
+ end
end
function cmd_cloneviassh(user, key, repo, localname, ...)