forked from Kong/lua-resty-dns-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrbusted
executable file
·41 lines (30 loc) · 926 Bytes
/
rbusted
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env resty
local DEFAULT_RESTY_FLAGS="-c 4096"
if not os.getenv("BUSTED_RESPAWNED") then
-- initial run, so go update the environment
-- rebuild the invoked commandline, while inserting extra resty-flags
local resty_flags = DEFAULT_RESTY_FLAGS
local cmd = { "exec" }
for i = -1, #arg do
if arg[i]:sub(1, 12) == "RESTY_FLAGS=" then
resty_flags = arg[i]:sub(13, -1)
else
table.insert(cmd, "'" .. arg[i] .. "'")
end
end
if resty_flags then
table.insert(cmd, 3, resty_flags)
end
local _, _, rc = os.execute("export BUSTED_RESPAWNED=1; " .. table.concat(cmd, " "))
os.exit(rc)
end
-- remove openresty write guard on _G
setmetatable(_G, nil)
package.path = "?/init.lua;"..package.path
if ngx ~= nil then
ngx.exit = function() end
end
-- disable globals warning
setmetatable(_G, nil)
-- Busted command-line runner
require 'busted.runner'({ standalone = false })