aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2018-06-25 13:08:53 -0300
committerHisham Muhammad <hisham@gobolinux.org>2018-07-01 15:51:36 -0300
commit38f2a05e41221827e89e8811cdc6a47a881184e8 (patch)
treea3a000cab8d5dc2689e4f18d7d737a0b642ad557 /spec
parentf056938237f82845e9d3b4924cac483a4bbb7b20 (diff)
downloadluarocks-38f2a05e41221827e89e8811cdc6a47a881184e8.tar.gz
luarocks-38f2a05e41221827e89e8811cdc6a47a881184e8.tar.bz2
luarocks-38f2a05e41221827e89e8811cdc6a47a881184e8.zip
Tests: improve hardcoded defaults
Diffstat (limited to 'spec')
-rw-r--r--spec/util/test_env.lua40
1 files changed, 28 insertions, 12 deletions
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua
index 0491f90f..fc292607 100644
--- a/spec/util/test_env.lua
+++ b/spec/util/test_env.lua
@@ -526,15 +526,35 @@ local function create_paths(luaversion_full)
526 if test_env.TEST_TARGET_OS == "windows" then 526 if test_env.TEST_TARGET_OS == "windows" then
527 testing_paths.luadir = (test_env.LUA_DIR or os.getenv("ProgramFiles(x86)").."/LuaRocks") 527 testing_paths.luadir = (test_env.LUA_DIR or os.getenv("ProgramFiles(x86)").."/LuaRocks")
528 testing_paths.luarocks_tmp = os.getenv("TEMP") 528 testing_paths.luarocks_tmp = os.getenv("TEMP")
529 testing_paths.lua_interpreter = test_env.LUA_INTERPRETER or "lua.exe"
529 else 530 else
530 testing_paths.luadir = (test_env.LUA_DIR or "/usr/local") 531 testing_paths.luadir = (test_env.LUA_DIR or "/usr/local")
531 testing_paths.luarocks_tmp = "/tmp/luarocks_testing" 532 testing_paths.luarocks_tmp = "/tmp/luarocks_testing"
533 testing_paths.lua_interpreter = test_env.LUA_INTERPRETER or "lua"
532 end 534 end
533 535
534 testing_paths.lua = test_env.file_if_exists(testing_paths.luadir .. "/bin/" .. (test_env.LUA_INTERPRETER or "lua")) 536 local bindirs = {
535 or test_env.file_if_exists(testing_paths.luadir .. "/" .. (test_env.LUA_INTERPRETER or "lua")) 537 testing_paths.luadir .. "/bin",
538 testing_paths.luadir,
539 }
540 for _, bindir in ipairs(bindirs) do
541 local lua = bindir .. "/" .. testing_paths.lua_interpreter
542 if test_env.exists(lua) then
543 testing_paths.lua_bindir = bindir
544 testing_paths.lua = lua
545 break
546 end
547 end
536 assert(testing_paths.lua, "Lua interpreter not found! Run `busted -Xhelper help` for options") 548 assert(testing_paths.lua, "Lua interpreter not found! Run `busted -Xhelper help` for options")
537 549
550 local incfile = test_env.file_if_exists(testing_paths.luadir .. "/include/lua/" .. test_env.lua_version .. "/lua.h")
551 or test_env.file_if_exists(testing_paths.luadir .. "/include/lua" .. test_env.lua_version .. "/lua.h")
552 or test_env.file_if_exists(testing_paths.luadir .. "/include/lua.h")
553 testing_paths.lua_incdir = assert(incfile, "Lua header lua.h not found!"):gsub("/lua.h$", "")
554
555 testing_paths.lua_libdir = test_env.file_if_exists(testing_paths.luadir .. "/lib")
556 or test_env.file_if_exists(testing_paths.luadir)
557
538 local base_dir = lfs.currentdir() 558 local base_dir = lfs.currentdir()
539 559
540 if test_env.TEST_TARGET_OS == "windows" then 560 if test_env.TEST_TARGET_OS == "windows" then
@@ -746,25 +766,21 @@ local function setup_luarocks()
746 local testing_paths = test_env.testing_paths 766 local testing_paths = test_env.testing_paths
747 title("Setting up LuaRocks") 767 title("Setting up LuaRocks")
748 768
749 local incfile = test_env.file_if_exists(testing_paths.luadir .. "/include/lua/" .. test_env.lua_version .. "/lua.h")
750 or test_env.file_if_exists(testing_paths.luadir .. "/include/lua" .. test_env.lua_version .. "/lua.h")
751 or test_env.file_if_exists(testing_paths.luadir .. "/include/lua.h")
752 local incdir = assert(incfile):gsub("/lua.h$", "")
753
754 local lines = { 769 local lines = {
755 "return {", 770 "return {",
756 ("SYSCONFDIR = %q,"):format(testing_paths.testing_lrprefix .. "/etc/luarocks"), 771 ("SYSCONFDIR = %q,"):format(testing_paths.testing_lrprefix .. "/etc/luarocks"),
757 ("LUA_DIR = %q,"):format(testing_paths.luadir), 772 ("LUA_DIR = %q,"):format(testing_paths.luadir),
758 ("LUA_INCDIR = %q,"):format(incdir), 773 ("LUA_INCDIR = %q,"):format(testing_paths.lua_incdir),
759 ("LUA_LIBDIR = %q,"):format(testing_paths.luadir .. "/lib"), 774 ("LUA_LIBDIR = %q,"):format(testing_paths.lua_libdir),
760 ("LUA_BINDIR = %q,"):format(testing_paths.luadir .. "/bin"), 775 ("LUA_BINDIR = %q,"):format(testing_paths.lua_bindir),
776 ("LUA_INTERPRETER = %q,"):format(testing_paths.lua_interpreter),
761 } 777 }
762 778
763 if test_env.TEST_TARGET_OS == "windows" then 779 if test_env.TEST_TARGET_OS == "windows" then
764 if test_env.MINGW then 780 if test_env.MINGW then
765 table.insert(lines, [[SYSTEM = "MINGW"]]) 781 table.insert(lines, [[SYSTEM = "MINGW",]])
766 else 782 else
767 table.insert(lines, [[SYSTEM = "WindowsNT"]]) 783 table.insert(lines, [[SYSTEM = "WindowsNT",]])
768 end 784 end
769 table.insert(lines, ("WIN_TOOLS = %q,"):format(testing_paths.win_tools)) 785 table.insert(lines, ("WIN_TOOLS = %q,"):format(testing_paths.win_tools))
770 end 786 end