1
local test_env = require("test/test_environment")
1
local test_env = require("spec.util.test_env")
2
2
local run = test_env.run
4
4
test_env.unload_luarocks()
6
describe("LuaRocks path tests #blackbox #b_path", function()
6
describe("LuaRocks path tests #integration", function()
7
7
before_each(function()
8
8
test_env.setup_specs()
11
it("LuaRocks path", function()
12
local output = run.luarocks("path")
13
assert.match("LUA_PATH=", output)
14
assert.match("LUA_CPATH=", output)
17
if _VERSION:match("[23]") then
18
local v = _VERSION:gsub("Lua (%d+)%.(%d+)", "%1_%2")
20
it("LuaRocks path with LUA_PATH_"..v, function()
21
local output = run.luarocks("path", {
22
["LUA_PATH_"..v] = package.path,
24
assert.match("LUA_PATH_"..v.."=", output)
27
it("LuaRocks path with LUA_CPATH_"..v, function()
28
local output = run.luarocks("path", {
29
["LUA_CPATH_"..v] = package.cpath,
31
assert.match("LUA_CPATH_"..v.."=", output)
34
it("LuaRocks path with LUA_PATH_"..v.." and LUA_CPATH_"..v, function()
35
local output = run.luarocks("path", {
36
["LUA_PATH_"..v] = package.path,
37
["LUA_CPATH_"..v] = package.cpath,
39
assert.match("LUA_PATH_"..v.."=", output)
40
assert.match("LUA_CPATH_"..v.."=", output)
11
45
it("LuaRocks path bin", function()
12
46
assert.is_true(run.luarocks_bool("path --bin"))
23
57
it("LuaRocks path with tree", function()
24
58
assert.is_true(run.luarocks_bool("path --tree=lua_modules"))
61
it("LuaRocks path with project-tree", function()
62
local path1 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?%.lua"
63
local path2 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?/init%.lua"
65
local path = run.luarocks("path --project-tree=foo")
66
assert.truthy(path:find("foo" .. path1))
67
assert.truthy(path:find("foo" .. path2))
69
path = run.luarocks("path --project-tree=foo --tree=bar")
70
assert.falsy(path:find("foo" .. path1))
71
assert.falsy(path:find("foo" .. path2))
72
assert.truthy(path:find("bar" .. path1))
73
assert.truthy(path:find("bar" .. path2))