summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8ef1abe)
raw | patch | inline | side by side (parent: 8ef1abe)
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | |
Fri, 6 Aug 2010 21:19:23 +0000 (21:19 +0000) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Wed, 18 Aug 2010 19:42:04 +0000 (12:42 -0700) |
Change the test_have_prereq function in test-lib.sh to support a
comma-separated list of prerequisites. This is useful for tests that
need e.g. both POSIXPERM and SANITY.
The implementation was stolen from Junio C Hamano and Johannes Sixt,
the tests and documentation were not. See the "Tests in Cygwin" thread
in May 2009 for the originals:
http://thread.gmane.org/gmane.comp.version-control.git/116729/focus=118385
http://thread.gmane.org/gmane.comp.version-control.git/116729/focus=118434
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
comma-separated list of prerequisites. This is useful for tests that
need e.g. both POSIXPERM and SANITY.
The implementation was stolen from Junio C Hamano and Johannes Sixt,
the tests and documentation were not. See the "Tests in Cygwin" thread
in May 2009 for the originals:
http://thread.gmane.org/gmane.comp.version-control.git/116729/focus=118385
http://thread.gmane.org/gmane.comp.version-control.git/116729/focus=118434
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/README | patch | blob | history | |
t/t0000-basic.sh | patch | blob | history | |
t/test-lib.sh | patch | blob | history |
diff --git a/t/README b/t/README
index 0d1183c3e69904e9e3543d757f14f10c629e199b..d07b67af6cc044ba7b4d6fb3c58e7b9260ecd480 100644 (file)
--- a/t/README
+++ b/t/README
test_expect_success TTY 'git --paginate rev-list uses a pager' \
' ... '
+ You can also supply a comma-separated list of prerequisites, in the
+ rare case where your test depends on more than one:
+
+ test_expect_success PERL,PYTHON 'yo dawg' \
+ ' test $(perl -E 'print eval "1 +" . qx[python -c "print 2"]') == "4" '
+
- test_expect_failure [<prereq>] <message> <script>
This is NOT the opposite of test_expect_success, but is used
diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh
index f2c73369a5b93544ee837229da965d7efbdc45bf..2887677391e795c70c210368970df6ff6350fbd0 100755 (executable)
--- a/t/t0000-basic.sh
+++ b/t/t0000-basic.sh
exit 1
fi
+test_set_prereq HAVETHIS
+haveit=no
+test_expect_success HAVETHIS,HAVEIT 'test runs if prerequisites are satisfied' '
+ test_have_prereq HAVEIT &&
+ test_have_prereq HAVETHIS &&
+ haveit=yes
+'
+donthaveit=yes
+test_expect_success HAVEIT,DONTHAVEIT 'unmet prerequisites causes test to be skipped' '
+ donthaveit=no
+'
+if test $haveit$donthaveit != yesyes
+then
+ say "bug in test framework: multiple prerequisite tags do not work reliably"
+ exit 1
+fi
+
clean=no
test_expect_success 'tests clean up after themselves' '
test_when_finished clean=yes
diff --git a/t/test-lib.sh b/t/test-lib.sh
index 5467cc626b09b9fa02b07264e6e7a99c50b0ac8a..0b9969ccf7e8f45e68abd522c501ded2bb861492 100644 (file)
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
satisfied=" "
test_have_prereq () {
- case $satisfied in
- *" $1 "*)
- : yes, have it ;;
- *)
- ! : nope ;;
- esac
+ # prerequisites can be concatenated with ','
+ save_IFS=$IFS
+ IFS=,
+ set -- $*
+ IFS=$save_IFS
+ for prerequisite
+ do
+ case $satisfied in
+ *" $prerequisite "*)
+ : yes, have it ;;
+ *)
+ ! : nope ;;
+ esac
+ done
}
# You are not expected to call test_ok_ and test_failure_ directly, use