[PATCH 1/3] test-lib: tests can have multiple prerequisites

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

 



Treat the prereq argument to test_expect_success and
test_expect_failure as a space-separated list of prerequisites.

Signed-off-by: Jonathan Nieder <jrnieder@xxxxxxxxx>
---
Alas, I didn’t notice the thread with the almost identical patch [1]
before writing this one.

Since I am painting it, I prefer this way.  I find it intuitive and
can’t really see where the fuss about using some other coding style
came from.  So I would be very happy if someone who does understand
the fuss could come up with a comment to add to the commit message
about this. :)

 t/test-lib.sh |   17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/t/test-lib.sh b/t/test-lib.sh
index c582964..a53b6cf 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -315,12 +315,15 @@ test_set_prereq () {
 satisfied=" "
 
 test_have_prereq () {
-	case $satisfied in
-	*" $1 "*)
-		: yes, have it ;;
-	*)
-		! : nope ;;
-	esac
+	for prereq_to_test
+	do
+		case $satisfied in
+		*" $prereq_to_test "*)
+			: yes, have it ;;
+		*)
+			return 1 ;;
+		esac
+	done
 }
 
 # You are not expected to call test_ok_ and test_failure_ directly, use
@@ -370,7 +373,7 @@ test_skip () {
 		esac
 	done
 	if test -z "$to_skip" && test -n "$prereq" &&
-	   ! test_have_prereq "$prereq"
+	   ! test_have_prereq $prereq
 	then
 		to_skip=t
 	fi
-- 
1.7.1.rc1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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]