git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Brandon Casey <casey@nrlssc.navy.mil>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH] t9301-fast-export: move unset of config variable into its own test function
Date: Fri, 22 Aug 2008 01:23:39 -0700	[thread overview]
Message-ID: <7v7ia9bgqc.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <7vbpzlbgyl.fsf@gitster.siamese.dyndns.org> (Junio C. Hamano's message of "Fri, 22 Aug 2008 01:18:42 -0700")

Junio C Hamano <gitster@pobox.com> writes:

> For this particular case, what we are interested in testing is not that
> "config --unset" exits with 0 status.  We are however interested in making
> sure that i18n.commitencoding is not set when the body of #12 runs.
>
> So I think a more appropriate change would be something like this for this
> particular case.

Having said that, we may want to have an easier way to exclude certain
classes of pieces, and also encourage test writers to group pieces that
are related to these classes together.

For example, this introduces a new environment you can set,
GIT_SKIP_TEST_CLASS, which is a space separated list of classes of
features that you would want to exclude from the test.
test_expect_success/failure can now take an optional "class token" as the
first parameter (they traditionally took only two parameters, but with
class token, they take three).

This example defines I18N class, and lets you exclude the one you were
manually excluding with "GIT_SKIP_TESTS=t9301.4"


 t/t9301-fast-export.sh |    2 +-
 t/test-lib.sh          |   50 ++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 45 insertions(+), 7 deletions(-)

diff --git i/t/t9301-fast-export.sh w/t/t9301-fast-export.sh
index 2ce2aff..361e8dc 100755
--- i/t/t9301-fast-export.sh
+++ w/t/t9301-fast-export.sh
@@ -63,7 +63,7 @@ test_expect_success 'fast-export master~2..master' '
 
 '
 
-test_expect_success 'iso-8859-1' '
+test_expect_success I18N 'iso-8859-1' '
 
 	git config i18n.commitencoding ISO-8859-1 &&
 	# use author and committer name in ISO-8859-1 to match it.
diff --git i/t/test-lib.sh w/t/test-lib.sh
index e2b106c..88d6d50 100644
--- i/t/test-lib.sh
+++ w/t/test-lib.sh
@@ -232,22 +232,44 @@ test_run_ () {
 	return 0
 }
 
+# space sparated list of skippable test classes
+GIT_SKIPPABLE_TEST_CLASSES='I18N'
+
 test_skip () {
 	this_test=$(expr "./$0" : '.*/\(t[0-9]*\)-[^/]*$')
 	this_test="$this_test.$(expr "$test_count" + 1)"
+
 	to_skip=
-	for skp in $GIT_SKIP_TESTS
-	do
-		case "$this_test" in
-		$skp)
+	if test -n "$test_class"
+	then
+		case " $GIT_SKIPPABLE_TEST_CLASSES " in
+		*" $test_class "*) ;; # ok
+		*)
+			say_color error "'$test_class' is not a skippable test class"
+			error "Skippable are $GIT_SKIPPABLE_TEST_CLASSES"
+		esac
+		case " $GIT_SKIP_TEST_CLASS " in
+		*" $test_class "*)
 			to_skip=t
+			test_class="($test_class) "
 		esac
-	done
+	fi
+	if test -z "$to_skip"
+	then
+		for skp in $GIT_SKIP_TESTS
+		do
+			case "$this_test" in
+			$skp)
+				to_skip=t
+				break
+			esac
+		done
+	fi
 	case "$to_skip" in
 	t)
 		say_color skip >&3 "skipping test: $@"
 		test_count=$(expr "$test_count" + 1)
-		say_color skip "skip $test_count: $1"
+		say_color skip "skip $test_count: $test_class$1"
 		: true
 		;;
 	*)
@@ -257,6 +279,10 @@ test_skip () {
 }
 
 test_expect_failure () {
+	case $# in
+	2)	test_class= ;;
+	3)	test_class=$1; shift ;;
+	esac
 	test "$#" = 2 ||
 	error "bug in the test script: not 2 parameters to test-expect-failure"
 	if ! test_skip "$@"
@@ -274,6 +300,10 @@ test_expect_failure () {
 }
 
 test_expect_success () {
+	case $# in
+	2)	test_class= ;;
+	3)	test_class=$1; shift ;;
+	esac
 	test "$#" = 2 ||
 	error "bug in the test script: not 2 parameters to test-expect-success"
 	if ! test_skip "$@"
@@ -291,6 +321,10 @@ test_expect_success () {
 }
 
 test_expect_code () {
+	case $# in
+	3)	test_class= ;;
+	4)	test_class=$1; shift ;;
+	esac
 	test "$#" = 3 ||
 	error "bug in the test script: not 3 parameters to test-expect-code"
 	if ! test_skip "$@"
@@ -316,6 +350,10 @@ test_expect_code () {
 # Usage: test_external description command arguments...
 # Example: test_external 'Perl API' perl ../path/to/test.pl
 test_external () {
+	case $# in
+	3)	test_class= ;;
+	4)	test_class=$1; shift ;;
+	esac
 	test "$#" -eq 3 ||
 	error >&5 "bug in the test script: not 3 parameters to test_external"
 	descr="$1"

  reply	other threads:[~2008-08-22  8:24 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-18 22:55 [FYI] How I compile on IRIX 6.5 with the MIPSpro compiler and ksh Brandon Casey
2008-08-18 23:02 ` [PATCH] Makefile: add section for SGI IRIX Brandon Casey
2008-08-18 23:05 ` [PATCH] git-compat-util.h: adjust for SGI IRIX 6.5 Brandon Casey
2008-08-18 23:09 ` [PATCH] unpack-trees.c: work around run-time array initialization flaw on " Brandon Casey
2008-08-18 23:14 ` [PATCH] templates/Makefile: work around SGI install which assumes / if ROOT not defined Brandon Casey
2008-08-18 23:37   ` Junio C Hamano
2008-08-19  0:52     ` Brandon Casey
2008-08-22  0:31     ` [PATCH] templates/Makefile: install is unnecessary, just use mkdir -p Brandon Casey
2008-08-18 23:16 ` [PATCH] test-lib.sh: work around ksh's trap shortcomings Brandon Casey
2008-08-18 23:48   ` Junio C Hamano
2008-08-19  0:06     ` Brandon Casey
2008-08-19  7:39       ` Junio C Hamano
2008-08-19 14:59         ` Brandon Casey
2008-08-19  1:27     ` Brandon Casey
2008-08-20  0:19       ` Brandon Casey
2008-08-20 11:36         ` Mike Ralphson
2008-08-18 23:17 ` [PATCH] t1002-read-tree-m-u-2way.sh: use 'git diff -U0' rather than 'diff -U0' Brandon Casey
2008-08-18 23:20 ` [PATCH] t9301-fast-export.sh: don't unset config variable while we're skipping test 4 Brandon Casey
2008-08-19  0:32   ` Junio C Hamano
2008-08-19  0:39     ` Brandon Casey
2008-08-22  0:48     ` [PATCH] t9301-fast-export: move unset of config variable into its own test function Brandon Casey
2008-08-22  8:18       ` Junio C Hamano
2008-08-22  8:23         ` Junio C Hamano [this message]
2008-08-22  9:02           ` Johannes Sixt
2008-08-22 21:11             ` Junio C Hamano
2008-08-18 23:51 ` [FYI] How I compile on IRIX 6.5 with the MIPSpro compiler and ksh Brandon Casey
2008-08-19  1:18   ` Boyd Lynn Gerber
2008-08-19  1:25     ` Brandon Casey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v7ia9bgqc.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=casey@nrlssc.navy.mil \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).