aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2014-11-26 16:52:47 -0200
committerHisham Muhammad <hisham@gobolinux.org>2014-11-26 16:52:47 -0200
commit8bbf02e239ad62248f1b13af6fbc93ff84469831 (patch)
tree85b0d90d313e85fa6d54baacd638e12d0285e5a2
parent7a7c1245f89fc5c7fa4b6f4fe6b1dd7b5722a7e7 (diff)
downloadluarocks-8bbf02e239ad62248f1b13af6fbc93ff84469831.tar.gz
luarocks-8bbf02e239ad62248f1b13af6fbc93ff84469831.tar.bz2
luarocks-8bbf02e239ad62248f1b13af6fbc93ff84469831.zip
Make test suite detect crashes on tests that should fail gracefully.
-rw-r--r--src/luarocks/cfg.lua1
-rw-r--r--src/luarocks/command_line.lua2
-rwxr-xr-xtest/testing.sh15
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({
44 OK = 0, 44 OK = 0,
45 UNSPECIFIED = 1, 45 UNSPECIFIED = 1,
46 PERMISSIONDENIED = 2, 46 PERMISSIONDENIED = 2,
47 CRASH = 99
47},{ 48},{
48 __index = function(t, key) 49 __index = function(t, key)
49 local val = rawget(t, key) 50 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(...)
208 local xp, ok, err, exitcode = xpcall(function() return cmd.run(unpack(args)) end, function(err) 208 local xp, ok, err, exitcode = xpcall(function() return cmd.run(unpack(args)) end, function(err)
209 die(debug.traceback("LuaRocks "..cfg.program_version 209 die(debug.traceback("LuaRocks "..cfg.program_version
210 .." bug (please report at luarocks-developers@lists.sourceforge.net).\n" 210 .." bug (please report at luarocks-developers@lists.sourceforge.net).\n"
211 ..err, 2)) 211 ..err, 2), cfg.errorcodes.CRASH)
212 end) 212 end)
213 if xp and (not ok) then 213 if xp and (not ok) then
214 die(err, exitcode) 214 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() {
452 echo "-------------------------------------------" 452 echo "-------------------------------------------"
453 reset_environment 453 reset_environment
454 if $test 454 if $test
455 then echo "OK: Expected success." 455 then
456 else echo "FAIL: Unexpected failure."; exit 1 456 echo "OK: Expected success."
457 else
458 if [ $? = 99 ]
459 then echo "FAIL: Unexpected crash!"; exit 99
460 fi
461 echo "FAIL: Unexpected failure."; exit 1
457 fi 462 fi
458 done 463 done
459 grep "^fail_$1.*(" < $testing_dir/testing.sh | cut -d'(' -f1 | while read test 464 grep "^fail_$1.*(" < $testing_dir/testing.sh | cut -d'(' -f1 | while read test
@@ -464,7 +469,11 @@ run_tests() {
464 reset_environment 469 reset_environment
465 if $test 470 if $test
466 then echo "FAIL: Unexpected success."; exit 1 471 then echo "FAIL: Unexpected success."; exit 1
467 else echo "OK: Expected failure." 472 else
473 if [ $? = 99 ]
474 then echo "FAIL: Unexpected crash!"; exit 99
475 fi
476 echo "OK: Expected failure."
468 fi 477 fi
469 done 478 done
470} 479}