diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2017-10-04 11:14:42 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-04 11:14:42 -0300 |
commit | 84b4fe99cac37850a97858e0b641043bd3178d8a (patch) | |
tree | b4578689091b8360aed71f531faf2513b7d41684 /test | |
parent | 100c18d048936b5a47f29f55e6ce8b24277fb70f (diff) | |
download | luarocks-84b4fe99cac37850a97858e0b641043bd3178d8a.tar.gz luarocks-84b4fe99cac37850a97858e0b641043bd3178d8a.tar.bz2 luarocks-84b4fe99cac37850a97858e0b641043bd3178d8a.zip |
Use versioned files only. (#734)
Let's take the opportunity of a new major version to make an important cleanup: getting rid of the error-prone unversioned configuration files. This drops support for:
* Unversioned config.lua -> use config-5.x.lua
* Unversioned luarocks/site_config.lua -> it always generates luarocks/core/site_config_5_x.lua
* Unversioned lib/luarocks/rocks -> it always uses lib/luarocks/rocks-5.x
Diffstat (limited to 'test')
-rw-r--r-- | test/test_environment.lua | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/test/test_environment.lua b/test/test_environment.lua index 6338da0a..56b394cd 100644 --- a/test/test_environment.lua +++ b/test/test_environment.lua | |||
@@ -12,13 +12,15 @@ REQUIREMENTS | |||
12 | USAGE | 12 | USAGE |
13 | busted [-Xhelper <arguments>] | 13 | busted [-Xhelper <arguments>] |
14 | ARGUMENTS | 14 | ARGUMENTS |
15 | env=<type> Set type of environment to use ("minimal" or "full", | 15 | env=<type> Set type of environment to use ("minimal" or "full", |
16 | default: "minimal"). | 16 | default: "minimal"). |
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 | appveyor Add if running on Appveyor. |
21 | os=<type> Set OS ("linux", "osx", or "windows"). | 21 | os=<type> Set OS ("linux", "osx", or "windows"). |
22 | lua_dir=<path> Path of Lua installation (default "/usr/local") | ||
23 | lua_interpreter=<lua> Name of the interpreter (default "lua") | ||
22 | ]] | 24 | ]] |
23 | 25 | ||
24 | local function help() | 26 | local function help() |
@@ -128,6 +130,7 @@ local function execute_bool(command, print_command, env_variables) | |||
128 | if print_command ~= nil then | 130 | if print_command ~= nil then |
129 | redirect_filename = test_env.testing_paths.luarocks_tmp.."/output.txt" | 131 | redirect_filename = test_env.testing_paths.luarocks_tmp.."/output.txt" |
130 | redirect = " > "..redirect_filename | 132 | redirect = " > "..redirect_filename |
133 | os.remove(redirect_filename) | ||
131 | end | 134 | end |
132 | local ok = os.execute(command .. redirect) | 135 | local ok = os.execute(command .. redirect) |
133 | ok = (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean | 136 | ok = (ok == true or ok == 0) -- normalize Lua 5.1 output to boolean |
@@ -160,8 +163,10 @@ end | |||
160 | function test_env.set_lua_version() | 163 | function test_env.set_lua_version() |
161 | if _G.jit then | 164 | if _G.jit then |
162 | test_env.LUAJIT_V = _G.jit.version:match("(2%.%d)%.%d") | 165 | test_env.LUAJIT_V = _G.jit.version:match("(2%.%d)%.%d") |
166 | test_env.lua_version = "5.1" | ||
163 | else | 167 | else |
164 | test_env.LUA_V = _VERSION:match("5%.%d") | 168 | test_env.LUA_V = _VERSION:match("5%.%d") |
169 | test_env.lua_version = test_env.LUA_V | ||
165 | end | 170 | end |
166 | end | 171 | end |
167 | 172 | ||
@@ -192,6 +197,10 @@ function test_env.set_args() | |||
192 | test_env.MINGW = true | 197 | test_env.MINGW = true |
193 | elseif argument == "vs" then | 198 | elseif argument == "vs" then |
194 | test_env.MINGW = false | 199 | test_env.MINGW = false |
200 | elseif argument:find("^lua_dir=") then | ||
201 | test_env.LUA_DIR = argument:match("^lua_dir=(.*)$") | ||
202 | elseif argument:find("^lua_interpreter=") then | ||
203 | test_env.LUA_INTERPRETER = argument:match("^lua_interpreter=(.*)$") | ||
195 | else | 204 | else |
196 | help() | 205 | help() |
197 | end | 206 | end |
@@ -338,7 +347,12 @@ local function create_env(testing_paths) | |||
338 | local env_variables = {} | 347 | local env_variables = {} |
339 | env_variables.LUA_VERSION = luaversion_short | 348 | env_variables.LUA_VERSION = luaversion_short |
340 | env_variables.LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config.lua" | 349 | env_variables.LUAROCKS_CONFIG = testing_paths.testing_dir .. "/testing_config.lua" |
341 | env_variables.LUA_PATH = testing_paths.testing_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" | 350 | if test_env.TEST_TARGET_OS == "windows" then |
351 | env_variables.LUA_PATH = testing_paths.testing_lrprefix .. "\\lua\\?.lua;" | ||
352 | else | ||
353 | env_variables.LUA_PATH = testing_paths.testing_lrprefix .. "/share/lua/" .. luaversion_short .. "/?.lua;" | ||
354 | end | ||
355 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" | ||
342 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" | 356 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" |
343 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" | 357 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" |
344 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" | 358 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" |
@@ -451,11 +465,10 @@ local function reset_environment(testing_paths, md5sums) | |||
451 | end | 465 | end |
452 | 466 | ||
453 | local function create_paths(luaversion_full) | 467 | local function create_paths(luaversion_full) |
454 | local cfg = require("luarocks.core.cfg") | ||
455 | 468 | ||
456 | local testing_paths = {} | 469 | local testing_paths = {} |
457 | testing_paths.luadir = cfg.variables.LUA_BINDIR:gsub("/bin/?$", "") | 470 | testing_paths.luadir = (test_env.LUA_DIR or "/usr/local") |
458 | testing_paths.lua = cfg.variables.LUA_BINDIR .. "/" .. cfg.lua_interpreter | 471 | testing_paths.lua = testing_paths.luadir .. "/bin/" .. (test_env.LUA_INTERPRETER or "lua") |
459 | 472 | ||
460 | if test_env.TEST_TARGET_OS == "windows" then | 473 | if test_env.TEST_TARGET_OS == "windows" then |
461 | testing_paths.luarocks_tmp = os.getenv("TEMP") | 474 | testing_paths.luarocks_tmp = os.getenv("TEMP") |
@@ -479,6 +492,9 @@ local function create_paths(luaversion_full) | |||
479 | testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full | 492 | testing_paths.testing_cache = testing_paths.testing_dir .. "/testing_cache-" .. luaversion_full |
480 | testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full | 493 | testing_paths.testing_server = testing_paths.testing_dir .. "/testing_server-" .. luaversion_full |
481 | 494 | ||
495 | testing_paths.testing_rocks = testing_paths.testing_tree .. "/lib/luarocks/rocks-" .. test_env.lua_version | ||
496 | testing_paths.testing_sys_rocks = testing_paths.testing_sys_tree .. "/lib/luarocks/rocks-" .. test_env.lua_version | ||
497 | |||
482 | if test_env.TEST_TARGET_OS == "windows" then | 498 | if test_env.TEST_TARGET_OS == "windows" then |
483 | testing_paths.win_tools = testing_paths.testing_lrprefix .. "/tools" | 499 | testing_paths.win_tools = testing_paths.testing_lrprefix .. "/tools" |
484 | end | 500 | end |
@@ -658,12 +674,12 @@ local function install_luarocks(install_env_vars) | |||
658 | if test_env.TEST_TARGET_OS == "windows" then | 674 | if test_env.TEST_TARGET_OS == "windows" then |
659 | local compiler_flag = test_env.MINGW and "/MW" or "" | 675 | local compiler_flag = test_env.MINGW and "/MW" or "" |
660 | 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)) | 676 | 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)) |
661 | assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/site_config* " .. testing_paths.src_dir .. "/luarocks/site_config.lua")) | 677 | assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/core/site_config* " .. testing_paths.src_dir .. "/luarocks/core")) |
662 | else | 678 | else |
663 | local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix | 679 | local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix |
664 | assert(execute_bool(configure_cmd, false, install_env_vars)) | 680 | assert(execute_bool(configure_cmd, false, install_env_vars)) |
665 | assert(execute_bool("make clean", false, install_env_vars)) | 681 | assert(execute_bool("make clean", false, install_env_vars)) |
666 | assert(execute_bool("make src/luarocks/site_config.lua", false, install_env_vars)) | 682 | assert(execute_bool("make src/luarocks/core/site_config_"..test_env.lua_version:gsub("%.", "_")..".lua", false, install_env_vars)) |
667 | assert(execute_bool("make dev", false, install_env_vars)) | 683 | assert(execute_bool("make dev", false, install_env_vars)) |
668 | end | 684 | end |
669 | print("LuaRocks installed correctly!") | 685 | print("LuaRocks installed correctly!") |