diff options
| author | Peter Melnichenko <mpeterval@gmail.com> | 2016-07-08 13:36:24 +0300 |
|---|---|---|
| committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-07-08 13:36:24 +0300 |
| commit | 54cf8ad4d527b0585f364b3d6cbe2c9eae58c3da (patch) | |
| tree | 9bc1946b2605353deae71aae71859227a2878e6c /test/test_environment.lua | |
| parent | fc7d6f7f6542c5eeef8d92ed717132caa45901c8 (diff) | |
| download | luarocks-54cf8ad4d527b0585f364b3d6cbe2c9eae58c3da.tar.gz luarocks-54cf8ad4d527b0585f364b3d6cbe2c9eae58c3da.tar.bz2 luarocks-54cf8ad4d527b0585f364b3d6cbe2c9eae58c3da.zip | |
Test suite: use test/test_environment as busted helper
When parsing test options, instead of directly looking
for '-Xhelper' in arguments and splitting the next arguments on commas
add .busted config to set test/test_environment as busted helper.
Then busted will do the splitting on its own and set global arg to
split options.
Diffstat (limited to 'test/test_environment.lua')
| -rw-r--r-- | test/test_environment.lua | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/test/test_environment.lua b/test/test_environment.lua index fad862ce..bde43163 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | local lfs = require("lfs") | 1 | local lfs = require("lfs") |
| 2 | local test_env = {} | 2 | local test_env = {} |
| 3 | local arg = arg or { ... } | 3 | local arg = arg |
| 4 | 4 | ||
| 5 | local function help() | 5 | local function help() |
| 6 | print("LuaRocks test-suite\n\n".. | 6 | print("LuaRocks test-suite\n\n".. |
| @@ -78,37 +78,21 @@ end | |||
| 78 | 78 | ||
| 79 | --- Set all arguments from input into global variables | 79 | --- Set all arguments from input into global variables |
| 80 | function test_env.set_args() | 80 | function test_env.set_args() |
| 81 | if arg[1] == nil then | ||
| 82 | help() | ||
| 83 | end | ||
| 84 | |||
| 85 | local helper_arg | ||
| 86 | |||
| 87 | for i=1, #arg do | ||
| 88 | if arg[i] == "-Xhelper" then | ||
| 89 | helper_arg = arg[i+1] | ||
| 90 | break | ||
| 91 | end | ||
| 92 | end | ||
| 93 | |||
| 94 | if not helper_arg then | ||
| 95 | help() | ||
| 96 | end | ||
| 97 | |||
| 98 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables | 81 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables |
| 99 | test_env.TYPE_TEST_ENV = "minimal" | 82 | test_env.TYPE_TEST_ENV = "minimal" |
| 100 | 83 | ||
| 101 | if helper_arg:find("env=") then | 84 | for _, argument in ipairs(arg) do |
| 102 | test_env.TYPE_TEST_ENV = helper_arg:gsub("(.*)env=([^%,]+)(.*)","%2") | 85 | if argument:find("^env=") then |
| 103 | end | 86 | test_env.TYPE_TEST_ENV = argument:match("^env=(.*)$") |
| 104 | if helper_arg:find("clean") then | 87 | elseif argument == "clean" then |
| 105 | test_env.TEST_ENV_CLEAN = true | 88 | test_env.TEST_ENV_CLEAN = true |
| 106 | end | 89 | elseif argument == "travis" then |
| 107 | if helper_arg:find("travis") then | 90 | test_env.TRAVIS = true |
| 108 | test_env.TRAVIS = true | 91 | elseif argument:find("^os=") then |
| 109 | end | 92 | test_env.TEST_TARGET_OS = argument:match("^os=(.*)$") |
| 110 | if helper_arg:find("os=") then | 93 | else |
| 111 | test_env.TEST_TARGET_OS = helper_arg:gsub("(.*)os=([^%,]+)(.*)","%2") | 94 | help() |
| 95 | end | ||
| 112 | end | 96 | end |
| 113 | 97 | ||
| 114 | if not test_env.TEST_TARGET_OS then | 98 | if not test_env.TEST_TARGET_OS then |
