|
From: lacton <la...@us...> - 2008-03-22 09:13:54
|
Update of /cvsroot/shunit/ShUnit In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv32449 Modified Files: README shUnit shUnitTest Added Files: shuStartWithMoreThanOneArgumentTest Log Message: [add] error message if shuStart is called with more than one argument. Index: README =================================================================== RCS file: /cvsroot/shunit/ShUnit/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README 19 Mar 2008 21:30:43 -0000 1.1 --- README 22 Mar 2008 09:13:48 -0000 1.2 *************** *** 80,85 **** * Added automatic detection of test functions. You no longer need to call shuRegTest for each test function. Just call shuStart with no argument, ! and ShUnit will automatically register all functions that starts with 'Test'. * Fixed failure handling. If a test function contained both successes and failures, it would fail or succeed depending on the assertions' positions --- 80,87 ---- * Added automatic detection of test functions. You no longer need to call shuRegTest for each test function. Just call shuStart with no argument, ! and ShUnit will automatically register all functions that start with 'Test'. + * Added a LICENCE file. + * Added an error message if shuStart is called with more than one argument. * Fixed failure handling. If a test function contained both successes and failures, it would fail or succeed depending on the assertions' positions Index: shUnitTest =================================================================== RCS file: /cvsroot/shunit/ShUnit/shUnitTest,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** shUnitTest 16 Mar 2008 19:15:29 -0000 1.19 --- shUnitTest 22 Mar 2008 09:13:49 -0000 1.20 *************** *** 162,165 **** --- 162,178 ---- } + TestShuStartCalledWithMoreThanOneArgument() { + stdout=`./shuStartWithMoreThanOneArgumentTest 2>/dev/null` + stderr=`./shuStartWithMoreThanOneArgumentTest 2>&1 >/dev/null` + + shuDeny "Exit code should be KO" $? + + test "" == "$stdout" + shuAssert "Standard output should be empty" $? + + test "shuStart: invalid number of arguments -- 2" == "$stderr" + shuAssert "Error message" $? + } + InitFunction() { shuRegTest TestIntentionalFailure *************** *** 174,177 **** --- 187,191 ---- shuRegTest TestOneDenyFailureAndOneDenySuccessMeanFailure shuRegTest TestAutoSuite + shuRegTest TestShuStartCalledWithMoreThanOneArgument } Index: shUnit =================================================================== RCS file: /cvsroot/shunit/ShUnit/shUnit,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** shUnit 19 Mar 2008 21:30:43 -0000 1.23 --- shUnit 22 Mar 2008 09:13:49 -0000 1.24 *************** *** 71,82 **** strInitFunction="${1}" ! if [ $# -eq 1 ] then - eval ${strInitFunction} - else for test_function in `shuGetDeclaredFunctions | grep "^Test"` do shuRegTest "$test_function" done fi --- 71,86 ---- strInitFunction="${1}" ! if [ $# -eq 0 ] then for test_function in `shuGetDeclaredFunctions | grep "^Test"` do shuRegTest "$test_function" done + elif [ $# -eq 1 ] + then + eval ${strInitFunction} + else + echo "shuStart: invalid number of arguments -- $#" >&2 + return 1 fi --- NEW FILE: shuStartWithMoreThanOneArgumentTest --- #! /usr/bin/env sh # # This dummy test script tries to call shuStart with more than one argument.. # It is called by shUnitTest as part of the framework's regression test. # # # find the shUnit file using the command as a reference # inherit() { d=`expr ${0} : '\([a-zA-Z/._-]*\/\)'` test `expr "$d" : '[./]'` -eq 0 && d="./$d" . ${d}${1} } inherit shUnit Test1() { shuAssert "Always true" 0 } Suite1() { shuRegTest Test1 } Suite2() { shuRegTest Test1 } ### Main shuStart Suite1 Suite2 |