1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
local test_env = require("spec.util.test_env")
local run = test_env.run
test_env.unload_luarocks()
describe("luarocks path #integration", function()
before_each(function()
test_env.setup_specs()
end)
it("runs", function()
local output = run.luarocks("path")
assert.match("LUA_PATH=", output)
assert.match("LUA_CPATH=", output)
end)
if _VERSION:match("[23]") then
local v = _VERSION:gsub("Lua (%d+)%.(%d+)", "%1_%2")
it("with LUA_PATH_"..v, function()
local output = run.luarocks("path", {
["LUA_PATH_"..v] = package.path,
})
assert.match("LUA_PATH_"..v.."=", output)
end)
it("with LUA_CPATH_"..v, function()
local output = run.luarocks("path", {
["LUA_CPATH_"..v] = package.cpath,
})
assert.match("LUA_CPATH_"..v.."=", output)
end)
it("with LUA_PATH_"..v.." and LUA_CPATH_"..v, function()
local output = run.luarocks("path", {
["LUA_PATH_"..v] = package.path,
["LUA_CPATH_"..v] = package.cpath,
})
assert.match("LUA_PATH_"..v.."=", output)
assert.match("LUA_CPATH_"..v.."=", output)
end)
end
it("--bin", function()
assert.is_true(run.luarocks_bool("path --bin"))
end)
it("--lr-path", function()
assert.is_true(run.luarocks_bool("path --lr-path"))
end)
it("--lr-cpath", function()
assert.is_true(run.luarocks_bool("path --lr-cpath"))
end)
it("--tree", function()
assert.is_true(run.luarocks_bool("path --tree=lua_modules"))
end)
it("--project-tree", function()
local path1 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?%.lua"
local path2 = "/share/lua/5%." .. test_env.lua_version:sub(3, 3) .. "/%?/init%.lua"
local path = run.luarocks("path --project-tree=foo")
assert.truthy(path:find("foo" .. path1))
assert.truthy(path:find("foo" .. path2))
path = run.luarocks("path --project-tree=foo --tree=bar")
assert.falsy(path:find("foo" .. path1))
assert.falsy(path:find("foo" .. path2))
assert.truthy(path:find("bar" .. path1))
assert.truthy(path:find("bar" .. path2))
end)
end)
|