Skip to content

Commit

Permalink
feat(busted) support for resty-cli options in custom busted binary
Browse files Browse the repository at this point in the history
This allows to pass a setting on the 'bin/busted' commandline that
sets flags on the underlying 'resty' executable running the
environment.
The default flags will be "-c 65000" to remove the dreaded "xxx
worker_connections are not enough" error message while running
the test suite.

Signed-off-by: Thibault Charbonnier <[email protected]>
  • Loading branch information
Tieske authored and thibaultcha committed Jan 20, 2018
1 parent 7451527 commit da53316
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions bin/busted
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/usr/bin/env resty

local DEFAULT_RESTY_FLAGS="-c 65000"

do
local lines = getmetatable(io.output()).lines

Expand Down Expand Up @@ -34,11 +36,22 @@ if not os.getenv("KONG_BUSTED_RESPAWNED") then
-- add cli recursion detection
table.insert(script, "export KONG_BUSTED_RESPAWNED=1")

-- rebuild the invoked commandline
-- rebuild the invoked commandline, while inserting extra resty-flags
local resty_flags = DEFAULT_RESTY_FLAGS
local cmd = { "exec" }
for i = 0, #arg do
table.insert(cmd, "'"..arg[i].."'")
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

table.insert(script, table.concat(cmd, " "))

-- recurse cli command, with proper variables (un)set for clean testing
Expand Down

0 comments on commit da53316

Please sign in to comment.