testprogs:subunit.sh: Add function for expected failures.
authorAndrew Kroeger <andrew@id10ts.net>
Tue, 8 Sep 2009 21:01:26 +0000 (16:01 -0500)
committerMatthias Dieter Wallnöfer <mwallnoefer@yahoo.de>
Wed, 9 Sep 2009 23:09:56 +0000 (01:09 +0200)
The testit_expect_failure() function is like the testit() function, with
reversed error detection logic.  This reversal only affects the pass/fail logic
and logging - the original return code from the command is still returned to the
calling script.

testprogs/blackbox/subunit.sh

index cee8cf6f459155538340af98e125372dadcafce8..e16aee76caa7aaa21f3980768485a2f22985348c 100755 (executable)
@@ -65,3 +65,18 @@ testit () {
        fi
        return $status
 }
        fi
        return $status
 }
+
+testit_expect_failure () {
+       name="$1"
+       shift
+       cmdline="$*"
+       subunit_start_test "$name"
+       output=`$cmdline 2>&1`
+       status=$?
+       if [ x$status = x0 ]; then
+               echo "$output" | subunit_fail_test "$name"
+       else
+               subunit_pass_test "$name"
+       fi
+       return $status
+}