diff options
| author | Hisham <hisham@gobolinux.org> | 2016-10-14 16:38:51 -0700 |
|---|---|---|
| committer | Hisham <hisham@gobolinux.org> | 2016-10-14 16:38:51 -0700 |
| commit | 075196e8b5d315888a8ae110fa9a18089044ae3b (patch) | |
| tree | eca3eb78c23f8d85dbe625564a2d66966d6281f1 /test | |
| parent | dbca97cdcc15e386554b2631a0ae7aca02500abf (diff) | |
| parent | 1fea0e3a0972bcc6b4319cd3d9e79834562486bc (diff) | |
| download | luarocks-075196e8b5d315888a8ae110fa9a18089044ae3b.tar.gz luarocks-075196e8b5d315888a8ae110fa9a18089044ae3b.tar.bz2 luarocks-075196e8b5d315888a8ae110fa9a18089044ae3b.zip | |
Merge branch 'master' into luarocks-3
Diffstat (limited to 'test')
| -rw-r--r-- | test/README.md | 11 | ||||
| -rw-r--r-- | test/test_environment.lua | 199 | ||||
| -rw-r--r-- | test/testing.bat | 9 |
3 files changed, 162 insertions, 57 deletions
diff --git a/test/README.md b/test/README.md index c374438f..5deaa175 100644 --- a/test/README.md +++ b/test/README.md | |||
| @@ -12,7 +12,7 @@ Test suite for LuaRocks project with Busted unit testing framework(http://olivin | |||
| 12 | 12 | ||
| 13 | 13 | ||
| 14 | ##Usage | 14 | ##Usage |
| 15 | Running of tests is based on basic Busted usage. *-Xhelper* flag is mandatory for inserting arguments into testing (primary black-box). Flag *--tags=* or *-t* is mandatory for specifying which tests will run. Mandatory *-Xhelper* flag always needs version of Lua or LuaJIT (e.g. *lua=5.2.4* or *luajit=2.0.3*). Start tests inside LuaRocks folder or specify with *-C* flag. | 15 | Running of tests is based on basic Busted usage. *-Xhelper* flag is mandatory for inserting arguments into testing (primary black-box). Flag *--tags=* or *-t* is mandatory for specifying which tests will run. Start tests inside LuaRocks folder or specify with *-C* flag. |
| 16 | 16 | ||
| 17 | **Arguments for Busted helper script** | 17 | **Arguments for Busted helper script** |
| 18 | 18 | ||
| @@ -22,7 +22,9 @@ OR | |||
| 22 | luajit=<version>, !mandatory! type your full version of LuaJIT (e.g. luajit=5.2.4) | 22 | luajit=<version>, !mandatory! type your full version of LuaJIT (e.g. luajit=5.2.4) |
| 23 | 23 | ||
| 24 | env=<type>, (default:"minimal") type what kind of environment to use ["minimal", "full"] | 24 | env=<type>, (default:"minimal") type what kind of environment to use ["minimal", "full"] |
| 25 | noreset, Don't reset environment after each test | ||
| 25 | clean, remove existing testing environment | 26 | clean, remove existing testing environment |
| 27 | appveyor, add just if running on TravisCI | ||
| 26 | travis, add just if running on TravisCI | 28 | travis, add just if running on TravisCI |
| 27 | os=<version>, type your OS ["linux", "os x", "windows"] | 29 | os=<version>, type your OS ["linux", "os x", "windows"] |
| 28 | ``` | 30 | ``` |
| @@ -35,6 +37,10 @@ os=<version>, type your OS ["linux", "os x", "windows"] | |||
| 35 | 37 | ||
| 36 | **ssh** - run all tests which require ssh | 38 | **ssh** - run all tests which require ssh |
| 37 | 39 | ||
| 40 | **mock** - run all tests which require mock LuaRocks server (upload tests) | ||
| 41 | |||
| 42 | **unix** - run all tests which are UNIX based, won't work on Windows systems | ||
| 43 | |||
| 38 | **w**\_*name-of-command* - whitebox testing of command | 44 | **w**\_*name-of-command* - whitebox testing of command |
| 39 | 45 | ||
| 40 | **b**\_*name-of-command* - blackbox testing of command | 46 | **b**\_*name-of-command* - blackbox testing of command |
| @@ -42,6 +48,9 @@ os=<version>, type your OS ["linux", "os x", "windows"] | |||
| 42 | for example: `b_install` or `w_help` | 48 | for example: `b_install` or `w_help` |
| 43 | 49 | ||
| 44 | ###Examples | 50 | ###Examples |
| 51 | To run all tests: | ||
| 52 | `busted` | ||
| 53 | |||
| 45 | To run white-box tests in LuaRocks directory type : | 54 | To run white-box tests in LuaRocks directory type : |
| 46 | 55 | ||
| 47 | `busted -t "whitebox"` | 56 | `busted -t "whitebox"` |
diff --git a/test/test_environment.lua b/test/test_environment.lua index c26c1e87..799e13ec 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
| @@ -17,6 +17,7 @@ ARGUMENTS | |||
| 17 | noreset Don't reset environment after each test | 17 | noreset Don't reset environment after each test |
| 18 | clean Remove existing testing environment. | 18 | clean Remove existing testing environment. |
| 19 | travis Add if running on TravisCI. | 19 | travis Add if running on TravisCI. |
| 20 | appveyor Add if running on Appveyor. | ||
| 20 | os=<type> Set OS ("linux", "osx", or "windows"). | 21 | os=<type> Set OS ("linux", "osx", or "windows"). |
| 21 | ]] | 22 | ]] |
| 22 | 23 | ||
| @@ -36,18 +37,54 @@ local function exists(path) | |||
| 36 | return lfs.attributes(path, "mode") ~= nil | 37 | return lfs.attributes(path, "mode") ~= nil |
| 37 | end | 38 | end |
| 38 | 39 | ||
| 39 | function test_env.quiet(commad) | 40 | --- Quote argument for shell processing. Fixes paths on Windows. |
| 41 | -- Adds double quotes and escapes. Based on function in fs/win32.lua. | ||
| 42 | -- @param arg string: Unquoted argument. | ||
| 43 | -- @return string: Quoted argument. | ||
| 44 | local function Q(arg) | ||
| 45 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 46 | local drive_letter = "[%.a-zA-Z]?:?[\\/]" | ||
| 47 | -- Quote DIR for Windows | ||
| 48 | if arg:match("^"..drive_letter) then | ||
| 49 | arg = arg:gsub("/", "\\") | ||
| 50 | end | ||
| 51 | |||
| 52 | if arg == "\\" then | ||
| 53 | return '\\' -- CHDIR needs special handling for root dir | ||
| 54 | end | ||
| 55 | |||
| 56 | return '"' .. arg .. '"' | ||
| 57 | else | ||
| 58 | return "'" .. arg:gsub("'", "'\\''") .. "'" | ||
| 59 | end | ||
| 60 | end | ||
| 61 | |||
| 62 | function test_env.quiet(command) | ||
| 40 | if not test_env.VERBOSE then | 63 | if not test_env.VERBOSE then |
| 41 | if test_env.TEST_TARGET_OS == "linux" or test_env.TEST_TARGET_OS == "osx" then | 64 | if test_env.TEST_TARGET_OS == "windows" then |
| 42 | return commad .. " 1> /dev/null 2> /dev/null" | 65 | return command .. " 1> NUL 2> NUL" |
| 43 | elseif test_env.TEST_TARGET_OS == "windows" then | 66 | else |
| 44 | return commad .. " 2> NUL 1> NUL" | 67 | return command .. " 1> /dev/null 2> /dev/null" |
| 45 | end | 68 | end |
| 46 | else | 69 | else |
| 47 | return command | 70 | return command |
| 48 | end | 71 | end |
| 49 | end | 72 | end |
| 50 | 73 | ||
| 74 | function test_env.copy(source, destination) | ||
| 75 | local r_source, err = io.open(source, "r") | ||
| 76 | local r_destination, err = io.open(destination, "w") | ||
| 77 | |||
| 78 | while true do | ||
| 79 | local block = r_source:read(8192) | ||
| 80 | if not block then break end | ||
| 81 | r_destination:write(block) | ||
| 82 | end | ||
| 83 | |||
| 84 | r_source:close() | ||
| 85 | r_destination:close() | ||
| 86 | end | ||
| 87 | |||
| 51 | --- Helper function for execute_bool and execute_output | 88 | --- Helper function for execute_bool and execute_output |
| 52 | -- @param command string: command to execute | 89 | -- @param command string: command to execute |
| 53 | -- @param print_command boolean: print command if 'true' | 90 | -- @param print_command boolean: print command if 'true' |
| @@ -61,27 +98,50 @@ function test_env.execute_helper(command, print_command, env_variables) | |||
| 61 | end | 98 | end |
| 62 | 99 | ||
| 63 | if env_variables then | 100 | if env_variables then |
| 64 | final_command = "export " | 101 | if test_env.TEST_TARGET_OS == "windows" then |
| 65 | for k,v in pairs(env_variables) do | 102 | for k,v in pairs(env_variables) do |
| 66 | final_command = final_command .. k .. "='" .. v .. "' " | 103 | final_command = final_command .. "set " .. k .. "=" .. v .. "&" |
| 104 | end | ||
| 105 | final_command = final_command:sub(1, -2) .. "&" | ||
| 106 | else | ||
| 107 | final_command = "export " | ||
| 108 | for k,v in pairs(env_variables) do | ||
| 109 | final_command = final_command .. k .. "='" .. v .. "' " | ||
| 110 | end | ||
| 111 | -- remove last space and add ';' to separate exporting variables from command | ||
| 112 | final_command = final_command:sub(1, -2) .. "; " | ||
| 67 | end | 113 | end |
| 68 | -- remove last space and add ';' to separate exporting variables from command | ||
| 69 | final_command = final_command:sub(1, -2) .. "; " | ||
| 70 | end | 114 | end |
| 71 | 115 | ||
| 72 | final_command = final_command .. command | 116 | final_command = final_command .. command .. " 2>&1" |
| 73 | 117 | ||
| 74 | return final_command | 118 | return final_command |
| 75 | end | 119 | end |
| 76 | 120 | ||
| 77 | --- Execute command and returns true/false | 121 | --- Execute command and returns true/false |
| 78 | -- In Lua5.1 os.execute returns numeric value, but in Lua5.2+ returns boolean | ||
| 79 | -- @return true/false boolean: status of the command execution | 122 | -- @return true/false boolean: status of the command execution |
| 80 | local function execute_bool(command, print_command, env_variables) | 123 | local function execute_bool(command, print_command, env_variables) |
| 81 | command = test_env.execute_helper(command, print_command, env_variables) | 124 | command = test_env.execute_helper(command, print_command, env_variables) |
| 82 | 125 | ||
| 83 | local ok = os.execute(command) | 126 | local redirect_filename |
| 84 | return ok == true or ok == 0 | 127 | local redirect = "" |
| 128 | if print_command ~= nil then | ||
| 129 | redirect_filename = test_env.testing_paths.luarocks_tmp.."/output.txt" | ||
| 130 | redirect = " > "..redirect_filename | ||
| 131 | end | ||
| 132 | local ok = os.execute(command .. redirect) | ||
| 133 | ok = (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean | ||
| 134 | if redirect ~= "" then | ||
| 135 | if not ok then | ||
| 136 | local fd = io.open(redirect_filename, "r") | ||
| 137 | if fd then | ||
| 138 | print(fd:read("*a")) | ||
| 139 | fd:close() | ||
| 140 | end | ||
| 141 | end | ||
| 142 | os.remove(redirect_filename) | ||
| 143 | end | ||
| 144 | return ok | ||
| 85 | end | 145 | end |
| 86 | 146 | ||
| 87 | --- Execute command and returns output of command | 147 | --- Execute command and returns output of command |
| @@ -109,6 +169,7 @@ end | |||
| 109 | function test_env.set_args() | 169 | function test_env.set_args() |
| 110 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables | 170 | -- if at least Lua/LuaJIT version argument was found on input start to parse other arguments to env. variables |
| 111 | test_env.TYPE_TEST_ENV = "minimal" | 171 | test_env.TYPE_TEST_ENV = "minimal" |
| 172 | test_env.OPENSSL_DIRS = "" | ||
| 112 | test_env.RESET_ENV = true | 173 | test_env.RESET_ENV = true |
| 113 | 174 | ||
| 114 | for _, argument in ipairs(arg) do | 175 | for _, argument in ipairs(arg) do |
| @@ -122,8 +183,15 @@ function test_env.set_args() | |||
| 122 | test_env.VERBOSE = true | 183 | test_env.VERBOSE = true |
| 123 | elseif argument == "travis" then | 184 | elseif argument == "travis" then |
| 124 | test_env.TRAVIS = true | 185 | test_env.TRAVIS = true |
| 186 | elseif argument == "appveyor" then | ||
| 187 | test_env.APPVEYOR = true | ||
| 188 | test_env.OPENSSL_DIRS = "OPENSSL_LIBDIR=C:\\OpenSSL-Win32\\lib OPENSSL_INCDIR=C:\\OpenSSL-Win32\\include" | ||
| 125 | elseif argument:find("^os=") then | 189 | elseif argument:find("^os=") then |
| 126 | test_env.TEST_TARGET_OS = argument:match("^os=(.*)$") | 190 | test_env.TEST_TARGET_OS = argument:match("^os=(.*)$") |
| 191 | elseif argument == "mingw" then | ||
| 192 | test_env.MINGW = true | ||
| 193 | elseif argument == "vs" then | ||
| 194 | test_env.MINGW = false | ||
| 127 | else | 195 | else |
| 128 | help() | 196 | help() |
| 129 | end | 197 | end |
| @@ -134,7 +202,7 @@ function test_env.set_args() | |||
| 134 | 202 | ||
| 135 | if execute_bool("sw_vers") then | 203 | if execute_bool("sw_vers") then |
| 136 | test_env.TEST_TARGET_OS = "osx" | 204 | test_env.TEST_TARGET_OS = "osx" |
| 137 | elseif execute_bool("uname -s") then | 205 | elseif execute_output("uname -s") == "Linux" then |
| 138 | test_env.TEST_TARGET_OS = "linux" | 206 | test_env.TEST_TARGET_OS = "linux" |
| 139 | else | 207 | else |
| 140 | test_env.TEST_TARGET_OS = "windows" | 208 | test_env.TEST_TARGET_OS = "windows" |
| @@ -143,6 +211,15 @@ function test_env.set_args() | |||
| 143 | return true | 211 | return true |
| 144 | end | 212 | end |
| 145 | 213 | ||
| 214 | local function copy_dir(source_path, target_path) | ||
| 215 | local testing_paths = test_env.testing_paths | ||
| 216 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 217 | execute_bool(testing_paths.win_tools .. "/cp -R ".. source_path .. "/. " .. target_path) | ||
| 218 | else | ||
| 219 | execute_bool("cp -a ".. source_path .. "/. " .. target_path) | ||
| 220 | end | ||
| 221 | end | ||
| 222 | |||
| 146 | --- Remove directory recursively | 223 | --- Remove directory recursively |
| 147 | -- @param path string: directory path to delete | 224 | -- @param path string: directory path to delete |
| 148 | function test_env.remove_dir(path) | 225 | function test_env.remove_dir(path) |
| @@ -159,7 +236,7 @@ function test_env.remove_dir(path) | |||
| 159 | end | 236 | end |
| 160 | end | 237 | end |
| 161 | end | 238 | end |
| 162 | os.remove(path) | 239 | lfs.rmdir(path) |
| 163 | end | 240 | end |
| 164 | 241 | ||
| 165 | --- Remove subdirectories of a directory that match a pattern | 242 | --- Remove subdirectories of a directory that match a pattern |
| @@ -205,13 +282,17 @@ end | |||
| 205 | -- @param save_path string: path to directory, where to download rocks/rockspecs | 282 | -- @param save_path string: path to directory, where to download rocks/rockspecs |
| 206 | -- @return make_manifest boolean: true if new rocks downloaded | 283 | -- @return make_manifest boolean: true if new rocks downloaded |
| 207 | local function download_rocks(urls, save_path) | 284 | local function download_rocks(urls, save_path) |
| 208 | local luarocks_repo = "https://luarocks.org" | 285 | local luarocks_repo = "https://www.luarocks.org" |
| 209 | local make_manifest = false | 286 | local make_manifest = false |
| 210 | 287 | ||
| 211 | for _, url in ipairs(urls) do | 288 | for _, url in ipairs(urls) do |
| 212 | -- check if already downloaded | 289 | -- check if already downloaded |
| 213 | if not exists(save_path .. url) then | 290 | if not exists(save_path .. url) then |
| 214 | execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. url) | 291 | if test_env.TEST_TARGET_OS == "windows" then |
| 292 | execute_bool(test_env.testing_paths.win_tools .. "/wget -cP " .. save_path .. " " .. luarocks_repo .. url .. " --no-check-certificate") | ||
| 293 | else | ||
| 294 | execute_bool("wget -cP " .. save_path .. " " .. luarocks_repo .. url) | ||
| 295 | end | ||
| 215 | make_manifest = true | 296 | make_manifest = true |
| 216 | end | 297 | end |
| 217 | end | 298 | end |
| @@ -235,9 +316,9 @@ local function hash_environment(path) | |||
| 235 | return execute_output("find " .. path .. " -printf \"%s %p\n\" | md5sum") | 316 | return execute_output("find " .. path .. " -printf \"%s %p\n\" | md5sum") |
| 236 | elseif test_env.TEST_TARGET_OS == "osx" then | 317 | elseif test_env.TEST_TARGET_OS == "osx" then |
| 237 | return execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5") | 318 | return execute_output("find " .. path .. " -type f -exec stat -f \"%z %N\" {} \\; | md5") |
| 238 | else | 319 | elseif test_env.TEST_TARGET_OS == "windows" then |
| 239 | -- TODO: Windows | 320 | return execute_output("\"" .. Q(test_env.testing_paths.win_tools .. "/find") .. " " .. Q(path) |
| 240 | return "" | 321 | .. " -printf \"%s %p\"\" > temp_sum.txt && certUtil -hashfile temp_sum.txt && del temp_sum.txt") |
| 241 | end | 322 | end |
| 242 | end | 323 | end |
| 243 | 324 | ||
| @@ -261,7 +342,7 @@ local function create_env(testing_paths) | |||
| 261 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" | 342 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" |
| 262 | env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" | 343 | env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" |
| 263 | .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" | 344 | .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?.so;" |
| 264 | env_variables.PATH = os.getenv("PATH") .. ":" .. testing_paths.testing_tree .. "/bin:" .. testing_paths.testing_sys_tree .. "/bin" | 345 | env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;" |
| 265 | 346 | ||
| 266 | return env_variables | 347 | return env_variables |
| 267 | end | 348 | end |
| @@ -278,13 +359,17 @@ local function create_md5sums(testing_paths) | |||
| 278 | end | 359 | end |
| 279 | 360 | ||
| 280 | local function make_run_function(cmd_name, exec_function, with_coverage, do_print) | 361 | local function make_run_function(cmd_name, exec_function, with_coverage, do_print) |
| 281 | local cmd_prefix = test_env.testing_paths.lua .. " " | 362 | local cmd_prefix = Q(test_env.testing_paths.lua) .. " " |
| 282 | 363 | ||
| 283 | if with_coverage then | 364 | if with_coverage then |
| 284 | cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testing_dir .. "/luacov.config')\" " | 365 | cmd_prefix = cmd_prefix .. "-e \"require('luacov.runner')('" .. test_env.testing_paths.testing_dir .. "/luacov.config')\" " |
| 285 | end | 366 | end |
| 286 | 367 | ||
| 287 | cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " | 368 | if test_env.TEST_TARGET_OS == "windows" then |
| 369 | cmd_prefix = cmd_prefix .. Q(test_env.testing_paths.testing_lrprefix .. "/" .. cmd_name .. ".lua") .. " " | ||
| 370 | else | ||
| 371 | cmd_prefix = cmd_prefix .. test_env.testing_paths.src_dir .. "/bin/" .. cmd_name .. " " | ||
| 372 | end | ||
| 288 | 373 | ||
| 289 | return function(cmd, new_vars) | 374 | return function(cmd, new_vars) |
| 290 | local temp_vars = {} | 375 | local temp_vars = {} |
| @@ -327,19 +412,23 @@ local function build_environment(rocks, env_variables) | |||
| 327 | lfs.mkdir(testing_paths.testing_tree) | 412 | lfs.mkdir(testing_paths.testing_tree) |
| 328 | lfs.mkdir(testing_paths.testing_sys_tree) | 413 | lfs.mkdir(testing_paths.testing_sys_tree) |
| 329 | 414 | ||
| 330 | test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_server) | 415 | test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_server)) |
| 331 | test_env.run.luarocks_admin_nocov("make_manifest " .. testing_paths.testing_cache) | 416 | test_env.run.luarocks_admin_nocov("make_manifest " .. Q(testing_paths.testing_cache)) |
| 332 | 417 | ||
| 333 | for _, rock in ipairs(rocks) do | 418 | for _, rock in ipairs(rocks) do |
| 334 | if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) then | 419 | if not test_env.run.luarocks_nocov("install --only-server=" .. testing_paths.testing_cache .. " --tree=" .. testing_paths.testing_sys_tree .. " " .. Q(rock), env_variables) then |
| 335 | test_env.run.luarocks_nocov("build --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) | 420 | test_env.run.luarocks_nocov("build --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock) .. "", env_variables) |
| 336 | test_env.run.luarocks_nocov("pack --tree=" .. testing_paths.testing_sys_tree .. " " .. rock, env_variables) | 421 | test_env.run.luarocks_nocov("pack --tree=" .. Q(testing_paths.testing_sys_tree) .. " " .. Q(rock), env_variables) |
| 337 | execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) | 422 | if test_env.TEST_TARGET_OS == "windows" then |
| 423 | execute_bool(testing_paths.win_tools .. "/mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) | ||
| 424 | else | ||
| 425 | execute_bool("mv " .. rock .. "-*.rock " .. testing_paths.testing_cache) | ||
| 426 | end | ||
| 338 | end | 427 | end |
| 339 | end | 428 | end |
| 340 | 429 | ||
| 341 | execute_bool("cp -a " .. testing_paths.testing_tree .. "/. " .. testing_paths.testing_tree_copy) | 430 | copy_dir(testing_paths.testing_tree, testing_paths.testing_tree_copy) |
| 342 | execute_bool("cp -a " .. testing_paths.testing_sys_tree .. "/. " .. testing_paths.testing_sys_tree_copy) | 431 | copy_dir(testing_paths.testing_sys_tree, testing_paths.testing_sys_tree_copy) |
| 343 | end | 432 | end |
| 344 | 433 | ||
| 345 | --- Reset testing environment | 434 | --- Reset testing environment |
| @@ -349,14 +438,13 @@ local function reset_environment(testing_paths, md5sums) | |||
| 349 | 438 | ||
| 350 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then | 439 | if testing_tree_md5 ~= md5sums.testing_tree_copy_md5 then |
| 351 | test_env.remove_dir(testing_paths.testing_tree) | 440 | test_env.remove_dir(testing_paths.testing_tree) |
| 352 | execute_bool("cp -a " .. testing_paths.testing_tree_copy .. "/. " .. testing_paths.testing_tree) | 441 | copy_dir(testing_paths.testing_tree_copy, testing_paths.testing_tree) |
| 353 | end | 442 | end |
| 354 | 443 | ||
| 355 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then | 444 | if testing_sys_tree_md5 ~= md5sums.testing_sys_tree_copy_md5 then |
| 356 | test_env.remove_dir(testing_paths.testing_sys_tree) | 445 | test_env.remove_dir(testing_paths.testing_sys_tree) |
| 357 | execute_bool("cp -a " .. testing_paths.testing_sys_tree_copy .. "/. " .. testing_paths.testing_sys_tree) | 446 | copy_dir(testing_paths.testing_sys_tree_copy, testing_paths.testing_sys_tree) |
| 358 | end | 447 | end |
| 359 | |||
| 360 | print("\n[ENVIRONMENT RESET]") | 448 | print("\n[ENVIRONMENT RESET]") |
| 361 | end | 449 | end |
| 362 | 450 | ||
| @@ -367,9 +455,18 @@ local function create_paths(luaversion_full) | |||
| 367 | testing_paths.luadir = cfg.variables.LUA_BINDIR:gsub("/bin/?$", "") | 455 | testing_paths.luadir = cfg.variables.LUA_BINDIR:gsub("/bin/?$", "") |
| 368 | testing_paths.lua = cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter | 456 | testing_paths.lua = cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter |
| 369 | 457 | ||
| 370 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" --windows? | 458 | if test_env.TEST_TARGET_OS == "windows" then |
| 459 | testing_paths.luarocks_tmp = os.getenv("TEMP") | ||
| 460 | else | ||
| 461 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" | ||
| 462 | end | ||
| 371 | 463 | ||
| 372 | testing_paths.luarocks_dir = lfs.currentdir() | 464 | testing_paths.luarocks_dir = lfs.currentdir() |
| 465 | |||
| 466 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 467 | testing_paths.luarocks_dir = testing_paths.luarocks_dir:gsub("\\","/") | ||
| 468 | end | ||
| 469 | |||
| 373 | testing_paths.testing_dir = testing_paths.luarocks_dir .. "/test" | 470 | testing_paths.testing_dir = testing_paths.luarocks_dir .. "/test" |
| 374 | testing_paths.src_dir = testing_paths.luarocks_dir .. "/src" | 471 | testing_paths.src_dir = testing_paths.luarocks_dir .. "/src" |
| 375 | testing_paths.testing_lrprefix = testing_paths.testing_dir .. "/testing_lrprefix-" .. luaversion_full | 472 | testing_paths.testing_lrprefix = testing_paths.testing_dir .. "/testing_lrprefix-" .. luaversion_full |
| @@ -380,6 +477,10 @@ local function create_paths(luaversion_full) | |||
| 380 | testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full | 477 | testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full |
| 381 | testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full | 478 | testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full |
| 382 | 479 | ||
| 480 | if test_env.TEST_TARGET_OS == "windows" then | ||
| 481 | testing_paths.win_tools = testing_paths.testing_lrprefix .. "/tools" | ||
| 482 | end | ||
| 483 | |||
| 383 | return testing_paths | 484 | return testing_paths |
| 384 | end | 485 | end |
| 385 | 486 | ||
| @@ -546,13 +647,19 @@ end | |||
| 546 | 647 | ||
| 547 | --- Install luarocks into testing prefix. | 648 | --- Install luarocks into testing prefix. |
| 548 | local function install_luarocks(install_env_vars) | 649 | local function install_luarocks(install_env_vars) |
| 549 | -- Configure LuaRocks testing environment | 650 | local testing_paths = test_env.testing_paths |
| 550 | title("Installing LuaRocks") | 651 | title("Installing LuaRocks") |
| 551 | local configure_cmd = "./configure --with-lua=" .. test_env.testing_paths.luadir .. " --prefix=" .. test_env.testing_paths.testing_lrprefix | 652 | if test_env.TEST_TARGET_OS == "windows" then |
| 552 | assert(execute_bool(test_env.quiet(configure_cmd), false, install_env_vars)) | 653 | local compiler_flag = test_env.MINGW and "/MW" or "" |
| 553 | assert(execute_bool(test_env.quiet("make clean"), false, install_env_vars)) | 654 | assert(execute_bool("install.bat /LUA " .. testing_paths.luadir .. " " .. compiler_flag .. " /P " .. testing_paths.testing_lrprefix .. " /NOREG /NOADMIN /F /Q /CONFIG " .. testing_paths.testing_lrprefix .. "/etc/luarocks", false, install_env_vars)) |
| 554 | assert(execute_bool(test_env.quiet("make src/luarocks/site_config.lua"), false, install_env_vars)) | 655 | assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/site_config* " .. testing_paths.src_dir .. "/luarocks/site_config.lua")) |
| 555 | assert(execute_bool(test_env.quiet("make dev"), false, install_env_vars)) | 656 | else |
| 657 | local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix | ||
| 658 | assert(execute_bool(configure_cmd, false, install_env_vars)) | ||
| 659 | assert(execute_bool("make clean", false, install_env_vars)) | ||
| 660 | assert(execute_bool("make src/luarocks/site_config.lua", false, install_env_vars)) | ||
| 661 | assert(execute_bool("make dev", false, install_env_vars)) | ||
| 662 | end | ||
| 556 | print("LuaRocks installed correctly!") | 663 | print("LuaRocks installed correctly!") |
| 557 | end | 664 | end |
| 558 | 665 | ||
| @@ -571,9 +678,7 @@ function test_env.main() | |||
| 571 | create_configs() | 678 | create_configs() |
| 572 | 679 | ||
| 573 | local install_env_vars = { | 680 | local install_env_vars = { |
| 574 | LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua", | 681 | LUAROCKS_CONFIG = test_env.testing_paths.testing_dir .. "/testing_config.lua" |
| 575 | LUA_PATH = "", | ||
| 576 | LUA_CPATH = "" | ||
| 577 | } | 682 | } |
| 578 | 683 | ||
| 579 | install_luarocks(install_env_vars) | 684 | install_luarocks(install_env_vars) |
diff --git a/test/testing.bat b/test/testing.bat deleted file mode 100644 index 7083678b..00000000 --- a/test/testing.bat +++ /dev/null | |||
| @@ -1,9 +0,0 @@ | |||
| 1 | @echo off | ||
| 2 | Setlocal EnableDelayedExpansion EnableExtensions | ||
| 3 | |||
| 4 | if not defined LUAROCKS_REPO set LUAROCKS_REPO=https://luarocks.org | ||
| 5 | |||
| 6 | appveyor DownloadFile %LUAROCKS_REPO%/stdlib-41.0.0-1.src.rock | ||
| 7 | luarocks build stdlib | ||
| 8 | |||
| 9 | endlocal | ||
