busted
busted copied to clipboard
the comand line argument with space will be split when use --lua
I need to use resty to run busted, so i use the lua options in .busted configure file like this.
return {
default = {
lua = "spec/resty_runner.lua",
},
}
the spec/resty_runner file content is:
local RESTY_FLAGS = os.getenv("BUSTED_RESTY_FLAGS") or "-e 'setmetatable(_G, nil)'"
local json = require("cjson")
print(json.encode(arg))
-- rebuild the invoked commandline, while inserting extra resty-flags
local cmd = {
"exec",
arg[-1],
"--shdict='tapis_inner_cache 10m'",
"--shdict='app_cache 10m'",
"--shdict='local_cache_ipc 10m'",
RESTY_FLAGS,
}
for i, param in ipairs(arg) do
table.insert(cmd, "'" .. param .. "'")
end
local _, _, rc = os.execute(table.concat(cmd, " "))
os.exit(rc)
Then i run busted like this: busted '--filter' 'get_subscribe_anchors get success'
The arg on spec/resty_runner print
{"0":"spec\/resty_runner.lua","1":"\/usr\/local\/lib\/luarocks\/rocks-5.1\/busted\/2.1.1-1\/bin\/busted","2":"--ignore-lua","3":"--filter","4":"get_subscribe_anchors","5":"get","6":"success","-1":"\/usr\/bin\/resty"}`
The --filter option value become: "4":"get_subscribe_anchors","5":"get","6":"success"
But the true one is 'get_subscribe_anchors get success'
So, how to get the true option value with space in my spec/resty_runner?