From d1ac6eaf54222d927edd56e2f84c4eef2149b346 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Thu, 20 Oct 2016 12:15:03 +0300 Subject: Add a test for sailor/sailorproject#138 --- spec/install_spec.lua | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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 = { "/luafilesystem-1.6.3-1.src.rock", "/luacheck-0.7.3-1.src.rock", "/luacheck-0.8.0-1.src.rock", + "/sailor-0.5-3.src.rock", + "/sailor-0.5-4.src.rock", } describe("LuaRocks install tests #blackbox #b_install", function() @@ -118,6 +120,16 @@ describe("LuaRocks install tests #blackbox #b_install", function() assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/luacheck_0_7_3_1-luacheck.lua")) assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/bin/luacheck_0_7_3_1-luacheck"..test_env.wrapper_extension)) end) + + it('LuaRocks install - handle non-Lua files in build.install.lua when upgrading sailorproject/sailor#138', function() + assert.is_true(run.luarocks_bool("install sailor 0.5-3 --deps-mode=none")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess~")) + + assert.is_true(run.luarocks_bool("install sailor 0.5-4 --deps-mode=none")) + assert.is.truthy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess")) + assert.is.falsy(lfs.attributes(testing_paths.testing_sys_tree .. "/share/lua/"..env_variables.LUA_VERSION.."/sailor/blank-app/.htaccess~")) + end) it("LuaRocks install only-deps of luasocket packed rock", function() assert.is_true(run.luarocks_bool("build --pack-binary-rock luasocket 3.0rc1-2")) -- cgit v1.2.3-55-g6feb From 20362f98249c1599c314562c8efb3a69bfd2017f Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Thu, 20 Oct 2016 13:22:18 +0300 Subject: Slightly improve error messages in deploy/remove --- src/luarocks/repos.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/luarocks/repos.lua b/src/luarocks/repos.lua index 161cdd8a..c5f157c4 100644 --- a/src/luarocks/repos.lua +++ b/src/luarocks/repos.lua @@ -174,12 +174,14 @@ local function find_suffixed(file, suffix) return filename end end + + return nil, table.concat(filenames, ", ") .. " not found" end local function move_suffixed(from_file, to_file, suffix) - local suffixed_from_file = find_suffixed(from_file, suffix) + local suffixed_from_file, err = find_suffixed(from_file, suffix) if not suffixed_from_file then - return nil, "File not found" + return nil, "Could not move " .. from_file .. " to " .. to_file .. ": " .. err end suffix = suffixed_from_file:sub(#from_file + 1) @@ -188,14 +190,14 @@ local function move_suffixed(from_file, to_file, suffix) end local function delete_suffixed(file, suffix) - local suffixed_file = find_suffixed(file, suffix) + local suffixed_file, err = find_suffixed(file, suffix) if not suffixed_file then - return nil, "File not found", "not found" + return nil, "Could not remove " .. file .. ": " .. err, "not found" end fs.delete(suffixed_file) if fs.exists(suffixed_file) then - return nil, "Failed deleting " .. suffixed_file, "fail" + return nil, "Failed deleting " .. suffixed_file .. ": file still exists", "fail" end return true -- cgit v1.2.3-55-g6feb From 1a9389f0687017430c84ade3252f46ac4b77a738 Mon Sep 17 00:00:00 2001 From: Peter Melnichenko Date: Thu, 20 Oct 2016 17:23:49 +0300 Subject: Show traceback for errors in scheduled functions --- src/luarocks/command_line.lua | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 1a8c0fe7..858e871f 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -2,6 +2,7 @@ --- Functions for command-line scripts. local command_line = {} +local pack = function(...) return {...}, select("#", ...) end local unpack = unpack or table.unpack local util = require("luarocks.util") @@ -13,17 +14,24 @@ local fs = require("luarocks.fs") local program = util.this_program("luarocks") +local function error_handler(err) + return debug.traceback("LuaRocks "..cfg.program_version.. + " bug (please report at https://github.com/keplerproject/luarocks/issues).\n"..err, 2) +end + --- Display an error message and exit. -- @param message string: The error message. -- @param exitcode number: the exitcode to use local function die(message, exitcode) assert(type(message) == "string") + util.printerr("\nError: "..message) - local ok, err = pcall(util.run_scheduled_functions) + local ok, err = xpcall(util.run_scheduled_functions, error_handler) if not ok then - util.printerr("\nLuaRocks "..cfg.program_version.." internal bug (please report at https://github.com/keplerproject/luarocks/issues):\n"..err) + util.printerr("\nError: "..err) + exitcode = cfg.errorcodes.CRASH end - util.printerr("\nError: "..message) + os.exit(exitcode or cfg.errorcodes.UNSPECIFIED) end @@ -177,12 +185,10 @@ function command_line.run_command(...) if commands[command] then local cmd = require(commands[command]) - local xp, ok, err, exitcode = xpcall(function() return cmd.command(flags, unpack(nonflags)) end, function(err) - die(debug.traceback("LuaRocks "..cfg.program_version - .." bug (please report at https://github.com/keplerproject/luarocks/issues).\n" - ..err, 2), cfg.errorcodes.CRASH) - end) - if xp and (not ok) then + local call_ok, ok, err, exitcode = xpcall(function() return cmd.command(flags, unpack(nonflags)) end, error_handler) + if not call_ok then + die(ok, cfg.errorcodes.CRASH) + elseif not ok then die(err, exitcode) end else -- cgit v1.2.3-55-g6feb