diff options
-rw-r--r-- | spec/util/test_env.lua | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/spec/util/test_env.lua b/spec/util/test_env.lua index 8705a695..ca520459 100644 --- a/spec/util/test_env.lua +++ b/spec/util/test_env.lua | |||
@@ -641,36 +641,53 @@ local function reset_environment(testing_paths, md5sums) | |||
641 | end | 641 | end |
642 | end | 642 | end |
643 | 643 | ||
644 | local function found_interpreter(testing_paths, luadir, lua_bindir) | ||
645 | local location = lua_bindir .. "/" .. testing_paths.lua_interpreter | ||
646 | if test_env.exists(location) then | ||
647 | testing_paths.lua_bindir = lua_bindir | ||
648 | testing_paths.luadir = luadir | ||
649 | testing_paths.lua = location | ||
650 | return true | ||
651 | end | ||
652 | end | ||
653 | |||
644 | local function create_paths(luaversion_full) | 654 | local function create_paths(luaversion_full) |
645 | 655 | ||
646 | local testing_paths = {} | 656 | local testing_paths = {} |
657 | local try_dirs | ||
658 | |||
647 | if test_env.TEST_TARGET_OS == "windows" then | 659 | if test_env.TEST_TARGET_OS == "windows" then |
648 | testing_paths.luadir = (test_env.LUA_DIR or os.getenv("ProgramFiles(x86)").."/LuaRocks") | 660 | try_dirs = { os.getenv("ProgramFiles(x86)").."/LuaRocks" } |
649 | testing_paths.luarocks_tmp = os.getenv("TEMP") | 661 | testing_paths.luarocks_tmp = os.getenv("TEMP") |
650 | testing_paths.lua_interpreter = test_env.LUA_INTERPRETER or "lua.exe" | 662 | testing_paths.lua_interpreter = "lua.exe" |
651 | else | 663 | else |
652 | testing_paths.luadir = (test_env.LUA_DIR or "/usr/local") | 664 | try_dirs = { "/usr/local", "/usr" } |
653 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" | 665 | testing_paths.luarocks_tmp = "/tmp/luarocks_testing" |
654 | testing_paths.lua_interpreter = test_env.LUA_INTERPRETER or "lua" | 666 | testing_paths.lua_interpreter = "lua" |
655 | end | 667 | end |
656 | 668 | ||
657 | local locations | 669 | if test_env.LUA_DIR then |
658 | if testing_paths.lua_interpreter:match("[/\\]") then | 670 | table.insert(try_dirs, 1, test_env.LUA_DIR) |
659 | locations = { testing_paths.lua_interpreter } | 671 | end |
660 | else | 672 | |
661 | locations = { | 673 | if test_env.LUA_INTERPRETER then |
662 | testing_paths.luadir .. "/bin/" .. testing_paths.lua_interpreter, | 674 | testing_paths.lua_interpreter = test_env.LUA_INTERPRETER |
663 | testing_paths.luadir .. "/" .. testing_paths.lua_interpreter, | ||
664 | } | ||
665 | end | 675 | end |
666 | 676 | ||
667 | for _, location in ipairs(locations) do | 677 | local bindir, interp = testing_paths.lua_interpreter:match("^(.-)[/\\]([^/\\]*)$") |
668 | if test_env.exists(location) then | 678 | if bindir and interp then |
669 | testing_paths.lua_bindir = location:match("(.*)[/\\][^/\\]*$") | 679 | testing_paths.lua_interpreter = interp |
670 | testing_paths.lua = location | 680 | try_dirs = { bindir } |
681 | end | ||
682 | |||
683 | for _, try_dir in ipairs(try_dirs) do | ||
684 | if found_interpreter(testing_paths, try_dir, try_dir) | ||
685 | or found_interpreter(testing_paths, try_dir, try_dir .. "/bin") | ||
686 | then | ||
671 | break | 687 | break |
672 | end | 688 | end |
673 | end | 689 | end |
690 | |||
674 | assert(testing_paths.lua, "Lua interpreter not found! Run `busted -Xhelper help` for options") | 691 | assert(testing_paths.lua, "Lua interpreter not found! Run `busted -Xhelper help` for options") |
675 | 692 | ||
676 | local base_dir = lfs.currentdir() | 693 | local base_dir = lfs.currentdir() |