From 84b16cd8c67bff9144c59675af3f18a92b6f9757 Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Tue, 16 Feb 2010 17:01:38 -0500 Subject: [PATCH] sh: add new WVPASSRC and WVFAILRC commands. For testing the value of $?. --- sh/t/twvtest.sh | 2 ++ sh/wvtest.sh | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/sh/t/twvtest.sh b/sh/t/twvtest.sh index fbc709f..875dd53 100755 --- a/sh/t/twvtest.sh +++ b/sh/t/twvtest.sh @@ -9,6 +9,8 @@ WVFAIL false WVPASSEQ "$(ls | sort)" "$(ls)" WVPASSNE "5" "5 " WVPASSEQ "" "" +(echo nested test; true); WVPASSRC $? +(echo nested fail; false); WVFAILRC $? WVSTART another test WVPASS true diff --git a/sh/wvtest.sh b/sh/wvtest.sh index 36a1862..44f7d9e 100644 --- a/sh/wvtest.sh +++ b/sh/wvtest.sh @@ -99,6 +99,22 @@ WVPASSNE() } +WVPASSRC() +{ + RC=$? + _wvfind_caller + _wvcheck $(_wvgetrv [ $RC -eq 0 ]) "return code($RC) == 0" +} + + +WVFAILRC() +{ + RC=$? + _wvfind_caller + _wvcheck $(_wvgetrv [ $RC -ne 0 ]) "return code($RC) != 0" +} + + WVSTART() { echo >&2 -- 2.39.2