[asterisk-commits] mnicholson: testsuite/asterisk/trunk r462 - in /asterisk/trunk/asttest: lib/l...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Jul 8 12:36:20 CDT 2010
Author: mnicholson
Date: Thu Jul 8 12:36:16 2010
New Revision: 462
URL: http://svnview.digium.com/svn/testsuite?view=rev&rev=462
Log:
Reimplemented test.check() to match the implementation used in most of the tests. It can now check the return value of a function that return's a result and error message.
Also added more verbose output for the test_testlib self test.
Removed:
asterisk/trunk/asttest/self-tests/test_testlib/tests/check_false/
asterisk/trunk/asttest/self-tests/test_testlib/tests/check_true/
Modified:
asterisk/trunk/asttest/lib/lua/testlib.lua
asterisk/trunk/asttest/self-tests/test_testlib/test.lua
Modified: asterisk/trunk/asttest/lib/lua/testlib.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/lib/lua/testlib.lua?view=diff&rev=462&r1=461&r2=462
==============================================================================
--- asterisk/trunk/asttest/lib/lua/testlib.lua (original)
+++ asterisk/trunk/asttest/lib/lua/testlib.lua Thu Jul 8 12:36:16 2010
@@ -84,9 +84,13 @@
end
_G.fail_if = fail_if
--- fail if condition is false using message as the reason
-function check(condition, message)
- fail_if(not condition, message)
+-- check the return value of a function printing the given message in the event
+-- of an error
+function check(message, r, err)
+ if not r then
+ error(message .. ": " .. tostring(err))
+ end
+ return r, err
end
_G.check = check
Modified: asterisk/trunk/asttest/self-tests/test_testlib/test.lua
URL: http://svnview.digium.com/svn/testsuite/asterisk/trunk/asttest/self-tests/test_testlib/test.lua?view=diff&rev=462&r1=461&r2=462
==============================================================================
--- asterisk/trunk/asttest/self-tests/test_testlib/test.lua (original)
+++ asterisk/trunk/asttest/self-tests/test_testlib/test.lua Thu Jul 8 12:36:16 2010
@@ -5,12 +5,10 @@
a = asttest.run("tests")
-fail_if(a.results["fail_if_true"] ~= "fail")
-fail_if(a.results["fail_if_false"] ~= "pass")
-fail_if(a.results["check_true"] ~= "pass")
-fail_if(a.results["check_false"] ~= "fail")
-fail_if(a.results["fail"] ~= "fail")
-fail_if(a.results["pass"] ~= "pass")
-fail_if(a.results["skip"] ~= "skip")
-fail_if(a.results["error"] ~= "error")
+fail_if(a.results["fail_if_true"] ~= "fail", "fail_if(true) did nto cause a failure")
+fail_if(a.results["fail_if_false"] ~= "pass", "fail_if(false) test failed, it should have passed")
+fail_if(a.results["fail"] ~= "fail", "fail() did not cause a failure")
+fail_if(a.results["pass"] ~= "pass", "pass() did not pass")
+fail_if(a.results["skip"] ~= "skip", "skip() did not skip")
+fail_if(a.results["error"] ~= "error", "error() did not result in an error")
More information about the asterisk-commits
mailing list