diff options
| -rw-r--r-- | .busted | 5 | ||||
| -rw-r--r-- | test/test_environment.lua | 42 |
2 files changed, 18 insertions, 29 deletions
diff --git a/.busted b/.busted new file mode 100644 index 00000000..7c67e719 --- /dev/null +++ b/.busted | |||
| @@ -0,0 +1,5 @@ | |||
| 1 | return { | ||
| 2 | default = { | ||
| 3 | helper = "test/test_environment" | ||
| 4 | } | ||
| 5 | } | ||
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 |
