diff options
Diffstat (limited to 'spec/util/test_env.lua')
-rw-r--r-- | spec/util/test_env.lua | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index 6d8a962c..1d4e98d8 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua | |||
@@ -40,6 +40,10 @@ function test_env.exists(path) | |||
40 | return lfs.attributes(path, "mode") ~= nil | 40 | return lfs.attributes(path, "mode") ~= nil |
41 | end | 41 | end |
42 | 42 | ||
43 | function test_env.file_if_exists(path) | ||
44 | return lfs.attributes(path, "mode") and path | ||
45 | end | ||
46 | |||
43 | --- Quote argument for shell processing. Fixes paths on Windows. | 47 | --- Quote argument for shell processing. Fixes paths on Windows. |
44 | -- Adds double quotes and escapes. Based on function in fs/win32.lua. | 48 | -- Adds double quotes and escapes. Based on function in fs/win32.lua. |
45 | -- @param arg string: Unquoted argument. | 49 | -- @param arg string: Unquoted argument. |
@@ -251,7 +255,15 @@ function test_env.set_args() | |||
251 | end | 255 | end |
252 | end | 256 | end |
253 | end | 257 | end |
258 | print(test_env.TEST_TARGET_OS) | ||
259 | end | ||
260 | |||
261 | if test_env.TEST_TARGET_OS == "windows" then | ||
262 | test_env.lib_extension = "dll" | ||
263 | else | ||
264 | test_env.lib_extension = "so" | ||
254 | end | 265 | end |
266 | |||
255 | return true | 267 | return true |
256 | end | 268 | end |
257 | 269 | ||
@@ -394,12 +406,8 @@ local function create_env(testing_paths) | |||
394 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" | 406 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/" .. luaversion_short .. "/?.lua;" |
395 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" | 407 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.testing_sys_tree .. "/share/lua/".. luaversion_short .. "/?/init.lua;" |
396 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" | 408 | env_variables.LUA_PATH = env_variables.LUA_PATH .. testing_paths.src_dir .. "/?.lua;" |
397 | local lib_extension = "so" | 409 | env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. test_env.lib_extension .. ";" |
398 | if test_env.TEST_TARGET_OS == "windows" then | 410 | .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. test_env.lib_extension .. ";" |
399 | lib_extension = "dll" | ||
400 | end | ||
401 | env_variables.LUA_CPATH = testing_paths.testing_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. lib_extension .. ";" | ||
402 | .. testing_paths.testing_sys_tree .. "/lib/lua/" .. luaversion_short .. "/?." .. lib_extension .. ";" | ||
403 | env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;" | 411 | env_variables.PATH = os.getenv("PATH") .. ";" .. testing_paths.testing_tree .. "/bin;" .. testing_paths.testing_sys_tree .. "/bin;" |
404 | 412 | ||
405 | return env_variables | 413 | return env_variables |
@@ -584,8 +592,7 @@ function test_env.setup_specs(extra_rocks) | |||
584 | 592 | ||
585 | package.path = test_env.env_variables.LUA_PATH | 593 | package.path = test_env.env_variables.LUA_PATH |
586 | 594 | ||
587 | test_env.platform = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.core.cfg').arch)\"", false, test_env.env_variables) | 595 | test_env.platform = execute_output(test_env.testing_paths.lua .. " -e \"cfg = require('luarocks.core.cfg'); cfg.init(); print(cfg.arch)\"", false, test_env.env_variables) |
588 | test_env.lib_extension = execute_output(test_env.testing_paths.lua .. " -e \"print(require('luarocks.core.cfg').lib_extension)\"", false, test_env.env_variables) | ||
589 | test_env.wrapper_extension = test_env.TEST_TARGET_OS == "windows" and ".bat" or "" | 596 | test_env.wrapper_extension = test_env.TEST_TARGET_OS == "windows" and ".bat" or "" |
590 | test_env.md5sums = create_md5sums(test_env.testing_paths) | 597 | test_env.md5sums = create_md5sums(test_env.testing_paths) |
591 | test_env.setup_done = true | 598 | test_env.setup_done = true |
@@ -737,11 +744,21 @@ local function install_luarocks(install_env_vars) | |||
737 | 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)) | 744 | 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)) |
738 | assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/core/site_config* " .. testing_paths.src_dir .. "/luarocks/core")) | 745 | assert(execute_bool(testing_paths.win_tools .. "/cp " .. testing_paths.testing_lrprefix .. "/lua/luarocks/core/site_config* " .. testing_paths.src_dir .. "/luarocks/core")) |
739 | else | 746 | else |
740 | local configure_cmd = "./configure --with-lua=" .. testing_paths.luadir .. " --prefix=" .. testing_paths.testing_lrprefix | 747 | local incfile = test_env.file_if_exists(testing_paths.luadir .. "/include/lua.h") |
741 | assert(execute_bool(configure_cmd, false, install_env_vars)) | 748 | or test_env.file_if_exists(testing_paths.luadir .. "/include/lua/" .. test_env.lua_version .. "/lua.h") |
742 | assert(execute_bool("make clean", false, install_env_vars)) | 749 | or test_env.file_if_exists(testing_paths.luadir .. "/include/lua" .. test_env.lua_version .. "/lua.h") |
743 | assert(execute_bool("make src/luarocks/core/site_config_"..test_env.lua_version:gsub("%.", "_")..".lua", false, install_env_vars)) | 750 | local incdir = assert(incfile):gsub("/lua.h$", "") |
744 | assert(execute_bool("make dev", false, install_env_vars)) | 751 | |
752 | local lines = { | ||
753 | "return {", | ||
754 | ("SYSCONFDIR = %q,"):format(testing_paths.testing_lrprefix .. "/etc/luarocks"), | ||
755 | ("LUA_DIR = %q,"):format(testing_paths.luadir), | ||
756 | ("LUA_INCDIR = %q,"):format(incdir), | ||
757 | ("LUA_LIBDIR = %q,"):format(testing_paths.luadir .. "/lib"), | ||
758 | ("LUA_BINDIR = %q,"):format(testing_paths.luadir .. "/bin"), | ||
759 | "}", | ||
760 | } | ||
761 | test_env.write_file("src/luarocks/core/hardcoded.lua", table.concat(lines, "\n") .. "\n") | ||
745 | end | 762 | end |
746 | print("LuaRocks installed correctly!") | 763 | print("LuaRocks installed correctly!") |
747 | end | 764 | end |