diff options
author | FYP <its.fyp@gmail.com> | 2018-10-21 20:46:36 +0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-10-29 19:21:40 -0300 |
commit | 0c534c71465474b92710a2951bf15370fcc8c663 (patch) | |
tree | 4997ff7d01c747432e1a9b53518d533e3b12357b | |
parent | 8b60d7440ce6f215c7ea480950e4df5d190992f0 (diff) | |
download | luarocks-0c534c71465474b92710a2951bf15370fcc8c663.tar.gz luarocks-0c534c71465474b92710a2951bf15370fcc8c663.tar.bz2 luarocks-0c534c71465474b92710a2951bf15370fcc8c663.zip |
cmd: fix setting up deployment paths from a tree
(Amended with a regression test.)
Co-authored-by: Hisham Muhammad <hisham@gobolinux.org>
-rw-r--r-- | spec/config_spec.lua | 17 | ||||
-rw-r--r-- | src/luarocks/cmd.lua | 10 |
2 files changed, 22 insertions, 5 deletions
diff --git a/spec/config_spec.lua b/spec/config_spec.lua index f415909d..defc1d2f 100644 --- a/spec/config_spec.lua +++ b/spec/config_spec.lua | |||
@@ -3,6 +3,7 @@ local lfs = require("lfs") | |||
3 | local run = test_env.run | 3 | local run = test_env.run |
4 | local testing_paths = test_env.testing_paths | 4 | local testing_paths = test_env.testing_paths |
5 | local env_variables = test_env.env_variables | 5 | local env_variables = test_env.env_variables |
6 | local write_file = test_env.write_file | ||
6 | local hardcoded | 7 | local hardcoded |
7 | 8 | ||
8 | test_env.unload_luarocks() | 9 | test_env.unload_luarocks() |
@@ -52,6 +53,22 @@ describe("LuaRocks config tests #integration", function() | |||
52 | local output = run.luarocks("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"}) | 53 | local output = run.luarocks("config --user-config", {LUAROCKS_CONFIG = "missing_file.lua"}) |
53 | assert.truthy(output:match("Warning")) | 54 | assert.truthy(output:match("Warning")) |
54 | end) | 55 | end) |
56 | |||
57 | it("LuaRocks config with --tree respects custom config", function() | ||
58 | write_file("my_config.lua", [[ | ||
59 | rocks_trees = { | ||
60 | { | ||
61 | name = "system", | ||
62 | root = "/example/tree", | ||
63 | lua_dir = "/example/luadir", | ||
64 | }, | ||
65 | } | ||
66 | ]], finally) | ||
67 | local output = run.luarocks("config", {LUAROCKS_CONFIG = "my_config.lua"}) | ||
68 | assert.match([[deploy_lua_dir = "/example/luadir"]], output) | ||
69 | output = run.luarocks("config --tree=system", {LUAROCKS_CONFIG = "my_config.lua"}) | ||
70 | assert.match([[deploy_lua_dir = "/example/luadir"]], output) | ||
71 | end) | ||
55 | end) | 72 | end) |
56 | 73 | ||
57 | describe("LuaRocks config - more complex tests", function() | 74 | describe("LuaRocks config - more complex tests", function() |
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index fc98e45f..996900ff 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -150,10 +150,10 @@ end | |||
150 | 150 | ||
151 | local process_tree_flags | 151 | local process_tree_flags |
152 | do | 152 | do |
153 | local function replace_tree(flags, tree) | 153 | local function replace_tree(flags, root, tree) |
154 | tree = dir.normalize(tree) | 154 | root = dir.normalize(root) |
155 | flags["tree"] = tree | 155 | flags["tree"] = root |
156 | path.use_tree(tree) | 156 | path.use_tree(tree or root) |
157 | end | 157 | end |
158 | 158 | ||
159 | local function find_project_dir() | 159 | local function find_project_dir() |
@@ -195,7 +195,7 @@ do | |||
195 | if not tree.root then | 195 | if not tree.root then |
196 | return nil, "Configuration error: tree '"..tree.name.."' has no 'root' field." | 196 | return nil, "Configuration error: tree '"..tree.name.."' has no 'root' field." |
197 | end | 197 | end |
198 | replace_tree(flags, tree.root) | 198 | replace_tree(flags, tree.root, tree) |
199 | named = true | 199 | named = true |
200 | break | 200 | break |
201 | end | 201 | end |