diff options
author | Hisham <hisham@gobolinux.org> | 2016-10-20 14:23:41 -0400 |
---|---|---|
committer | Hisham <hisham@gobolinux.org> | 2016-10-20 14:23:41 -0400 |
commit | 93f6b42794d864725fbe381425da7db9de95e766 (patch) | |
tree | a3c07ca56275c0482df741e2d1463c72d398909f | |
parent | b526f07e99af98ba42786e88c52636e52059b398 (diff) | |
parent | 1a9389f0687017430c84ade3252f46ac4b77a738 (diff) | |
download | luarocks-93f6b42794d864725fbe381425da7db9de95e766.tar.gz luarocks-93f6b42794d864725fbe381425da7db9de95e766.tar.bz2 luarocks-93f6b42794d864725fbe381425da7db9de95e766.zip |
Merge branch 'master' into luarocks-3
-rw-r--r-- | spec/install_spec.lua | 12 | ||||
-rw-r--r-- | src/luarocks/command_line.lua | 24 | ||||
-rw-r--r-- | src/luarocks/repos.lua | 12 |
3 files changed, 34 insertions, 14 deletions
diff --git a/spec/install_spec.lua b/spec/install_spec.lua index a00396fa..8d43ca2a 100644 --- a/spec/install_spec.lua +++ b/spec/install_spec.lua | |||
@@ -23,6 +23,8 @@ local extra_rocks = { | |||
23 | "/luafilesystem-1.6.3-1.src.rock", | 23 | "/luafilesystem-1.6.3-1.src.rock", |
24 | "/luacheck-0.7.3-1.src.rock", | 24 | "/luacheck-0.7.3-1.src.rock", |
25 | "/luacheck-0.8.0-1.src.rock", | 25 | "/luacheck-0.8.0-1.src.rock", |
26 | "/sailor-0.5-3.src.rock", | ||
27 | "/sailor-0.5-4.src.rock", | ||
26 | } | 28 | } |
27 | 29 | ||
28 | describe("LuaRocks install tests #blackbox #b_install", function() | 30 | describe("LuaRocks install tests #blackbox #b_install", function() |
@@ -118,6 +120,16 @@ describe("LuaRocks install tests #blackbox #b_install", function() | |||
118 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/luacheck_0_7_3_1-luacheck.lua")) | 120 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/luacheck_0_7_3_1-luacheck.lua")) |
119 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/bin/luacheck_0_7_3_1-luacheck"..test_env.wrapper_extension)) | 121 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/bin/luacheck_0_7_3_1-luacheck"..test_env.wrapper_extension)) |
120 | end) | 122 | end) |
123 | |||
124 | it('LuaRocks install - handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138', function() | ||
125 | assert.is_true(run.luarocks_bool("install sailor 0.5-3 --deps-mode=none")) | ||
126 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess")) | ||
127 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess~")) | ||
128 | |||
129 | assert.is_true(run.luarocks_bool("install sailor 0.5-4 --deps-mode=none")) | ||
130 | assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess")) | ||
131 | assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess~")) | ||
132 | end) | ||
121 | 133 | ||
122 | it("LuaRocks install only-deps of luasocket packed rock", function() | 134 | it("LuaRocks install only-deps of luasocket packed rock", function() |
123 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) | 135 | assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) |
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 936e9950..f7f6ccb6 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
@@ -2,6 +2,7 @@ | |||
2 | --- Functions for command-line scripts. | 2 | --- Functions for command-line scripts. |
3 | local command_line = {} | 3 | local command_line = {} |
4 | 4 | ||
5 | local pack = function(...) return {...}, select("#", ...) end | ||
5 | local unpack = unpack or table.unpack | 6 | local unpack = unpack or table.unpack |
6 | 7 | ||
7 | local util = require("luarocks.util") | 8 | local util = require("luarocks.util") |
@@ -13,17 +14,24 @@ local fs = require("luarocks.fs") | |||
13 | 14 | ||
14 | local program = util.this_program("luarocks") | 15 | local program = util.this_program("luarocks") |
15 | 16 | ||
17 | local function error_handler(err) | ||
18 | return debug.traceback("LuaRocks "..cfg.program_version.. | ||
19 | " bug (please report at https://github.com/keplerproject/luarocks/issues).\n"..err, 2) | ||
20 | end | ||
21 | |||
16 | --- Display an error message and exit. | 22 | --- Display an error message and exit. |
17 | -- @param message string: The error message. | 23 | -- @param message string: The error message. |
18 | -- @param exitcode number: the exitcode to use | 24 | -- @param exitcode number: the exitcode to use |
19 | local function die(message, exitcode) | 25 | local function die(message, exitcode) |
20 | assert(type(message) == "string") | 26 | assert(type(message) == "string") |
27 | util.printerr("\nError: "..message) | ||
21 | 28 | ||
22 | local ok, err = pcall(util.run_scheduled_functions) | 29 | local ok, err = xpcall(util.run_scheduled_functions, error_handler) |
23 | if not ok then | 30 | if not ok then |
24 | util.printerr("\nLuaRocks "..cfg.program_version.." internal bug (please report at https://github.com/keplerproject/luarocks/issues):\n"..err) | 31 | util.printerr("\nError: "..err) |
32 | exitcode = cfg.errorcodes.CRASH | ||
25 | end | 33 | end |
26 | util.printerr("\nError: "..message) | 34 | |
27 | os.exit(exitcode or cfg.errorcodes.UNSPECIFIED) | 35 | os.exit(exitcode or cfg.errorcodes.UNSPECIFIED) |
28 | end | 36 | end |
29 | 37 | ||
@@ -177,12 +185,10 @@ function command_line.run_command(...) | |||
177 | 185 | ||
178 | if commands[command] then | 186 | if commands[command] then |
179 | local cmd = require(commands[command]) | 187 | local cmd = require(commands[command]) |
180 | local xp, ok, err, exitcode = xpcall(function() return cmd.command(flags, unpack(nonflags)) end, function(err) | 188 | local call_ok, ok, err, exitcode = xpcall(function() return cmd.command(flags, unpack(nonflags)) end, error_handler) |
181 | die(debug.traceback("LuaRocks "..cfg.program_version | 189 | if not call_ok then |
182 | .." bug (please report at https://github.com/keplerproject/luarocks/issues).\n" | 190 | die(ok, cfg.errorcodes.CRASH) |
183 | ..err, 2), cfg.errorcodes.CRASH) | 191 | elseif not ok then |
184 | end) | ||
185 | if xp and (not ok) then | ||
186 | die(err, exitcode) | 192 | die(err, exitcode) |
187 | end | 193 | end |
188 | else | 194 | else |
diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 6de844d2..9616fe03 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua | |||
@@ -175,12 +175,14 @@ local function find_suffixed(file, suffix) | |||
175 | return filename | 175 | return filename |
176 | end | 176 | end |
177 | end | 177 | end |
178 | |||
179 | return nil, table.concat(filenames, ", ") .. " not found" | ||
178 | end | 180 | end |
179 | 181 | ||
180 | local function move_suffixed(from_file, to_file, suffix) | 182 | local function move_suffixed(from_file, to_file, suffix) |
181 | local suffixed_from_file = find_suffixed(from_file, suffix) | 183 | local suffixed_from_file, err = find_suffixed(from_file, suffix) |
182 | if not suffixed_from_file then | 184 | if not suffixed_from_file then |
183 | return nil, "File not found" | 185 | return nil, "Could not move " .. from_file .. " to " .. to_file .. ": " .. err |
184 | end | 186 | end |
185 | 187 | ||
186 | suffix = suffixed_from_file:sub(#from_file + 1) | 188 | suffix = suffixed_from_file:sub(#from_file + 1) |
@@ -189,14 +191,14 @@ local function move_suffixed(from_file, to_file, suffix) | |||
189 | end | 191 | end |
190 | 192 | ||
191 | local function delete_suffixed(file, suffix) | 193 | local function delete_suffixed(file, suffix) |
192 | local suffixed_file = find_suffixed(file, suffix) | 194 | local suffixed_file, err = find_suffixed(file, suffix) |
193 | if not suffixed_file then | 195 | if not suffixed_file then |
194 | return nil, "File not found", "not found" | 196 | return nil, "Could not remove " .. file .. ": " .. err, "not found" |
195 | end | 197 | end |
196 | 198 | ||
197 | fs.delete(suffixed_file) | 199 | fs.delete(suffixed_file) |
198 | if fs.exists(suffixed_file) then | 200 | if fs.exists(suffixed_file) then |
199 | return nil, "Failed deleting " .. suffixed_file, "fail" | 201 | return nil, "Failed deleting " .. suffixed_file .. ": file still exists", "fail" |
200 | end | 202 | end |
201 | 203 | ||
202 | return true | 204 | return true |