From 8bbf02e239ad62248f1b13af6fbc93ff84469831 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 26 Nov 2014 16:52:47 -0200 Subject: Make test suite detect crashes on tests that should fail gracefully. --- src/luarocks/cfg.lua | 1 + src/luarocks/command_line.lua | 2 +- test/testing.sh | 15 ++++++++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 9a992bae..2d02230b 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -44,6 +44,7 @@ cfg.errorcodes = setmetatable({ OK = 0, UNSPECIFIED = 1, PERMISSIONDENIED = 2, + CRASH = 99 },{ __index = function(t, key) local val = rawget(t, key) diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index cc2e1683..15b036b0 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -208,7 +208,7 @@ function command_line.run_command(...) local xp, ok, err, exitcode = xpcall(function() return cmd.run(unpack(args)) end, function(err) die(debug.traceback("LuaRocks "..cfg.program_version .." bug (please report at luarocks-developers@lists.sourceforge.net).\n" - ..err, 2)) + ..err, 2), cfg.errorcodes.CRASH) end) if xp and (not ok) then die(err, exitcode) diff --git a/test/testing.sh b/test/testing.sh index b0d95c35..dc7ba680 100755 --- a/test/testing.sh +++ b/test/testing.sh @@ -452,8 +452,13 @@ run_tests() { echo "-------------------------------------------" reset_environment if $test - then echo "OK: Expected success." - else echo "FAIL: Unexpected failure."; exit 1 + then + echo "OK: Expected success." + else + if [ $? = 99 ] + then echo "FAIL: Unexpected crash!"; exit 99 + fi + echo "FAIL: Unexpected failure."; exit 1 fi done grep "^fail_$1.*(" < $testing_dir/testing.sh | cut -d'(' -f1 | while read test @@ -464,7 +469,11 @@ run_tests() { reset_environment if $test then echo "FAIL: Unexpected success."; exit 1 - else echo "OK: Expected failure." + else + if [ $? = 99 ] + then echo "FAIL: Unexpected crash!"; exit 99 + fi + echo "OK: Expected failure." fi done } -- cgit v1.2.3-55-g6feb