[PATCH 2/6] test-lib: add ok=* support to test_might_fail

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add the same ok=* support to test_might_fail as its test_must_fail
sibling. This will be used to make it accept "sigpipe" failures.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
---
 t/t0000-basic.sh        |  5 +++++
 t/test-lib-functions.sh | 12 +++++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index f90c375fe9..fd6cb8d5d3 100755
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
@@ -1332,4 +1332,9 @@ test_expect_success 'test_might_fail is like test_must_fail ok=' '
 	test_might_fail git version
 '
 
+test_expect_success 'test_might_fail supports an ok=* option like test_must_fail' '
+	test_might_fail git version &&
+	test_might_fail ok=success git version
+'
+
 test_done
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 999982fe4a..e01761f7ba 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -918,7 +918,17 @@ test_must_fail () {
 # Accepts the same options as test_must_fail.
 
 test_might_fail () {
-	test_must_fail ok=success "$@" 2>&7
+	case "$1" in
+	ok=*)
+		_test_ok=success,${1#ok=}
+		shift
+		;;
+	*)
+		_test_ok=success
+		;;
+	esac
+
+	test_must_fail ok=$_test_ok "$@" 2>&7
 } 7>&2 2>&4
 
 # Similar to test_must_fail and test_might_fail, but check that a
-- 
2.29.2.222.g5d2a92d10f8




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux