git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t1402: work around shell quoting issue on NetBSD
@ 2013-01-08 20:23 René Scharfe
  2013-01-08 20:39 ` Junio C Hamano
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: René Scharfe @ 2013-01-08 20:23 UTC (permalink / raw)
  To: git discussion list; +Cc: Junio C Hamano, Jonathan Nieder, Michael Haggerty

The test fails for me on NetBSD 6.0.1 and reports:

	ok 1 - ref name '' is invalid
	ok 2 - ref name '/' is invalid
	ok 3 - ref name '/' is invalid with options --allow-onelevel
	ok 4 - ref name '/' is invalid with options --normalize
	error: bug in the test script: not 2 or 3 parameters to test-expect-success

The alleged bug is in this line:

	invalid_ref NOT_MINGW '/' '--allow-onelevel --normalize'

invalid_ref() constructs a test case description using its last argument,
but the shell seems to split it up into two pieces if it contains a
space.  Minimal test case:

	# on NetBSD with /bin/sh
	$ a() { echo $#-$1-$2; }
	$ t="x"; a "${t:+$t}"
	1-x-
	$ t="x y"; a "${t:+$t}"
	2-x-y
	$ t="x y"; a "${t:+x y}"
	1-x y-

	# and with bash
	$ t="x y"; a "${t:+$t}"
	1-x y-
	$ t="x y"; a "${t:+x y}"
	1-x y-

This may be a bug in the shell, but here's a simple workaround: Construct
the description string first and store it in a variable, and then use
that to call test_expect_success().

Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
---
 t/t1402-check-ref-format.sh | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh
index 1ae4d87..1a5a5f3 100755
--- a/t/t1402-check-ref-format.sh
+++ b/t/t1402-check-ref-format.sh
@@ -11,7 +11,8 @@ valid_ref() {
 		prereq=$1
 		shift
 	esac
-	test_expect_success $prereq "ref name '$1' is valid${2:+ with options $2}" "
+	desc="ref name '$1' is valid${2:+ with options $2}"
+	test_expect_success $prereq "$desc" "
 		git check-ref-format $2 '$1'
 	"
 }
@@ -22,7 +23,8 @@ invalid_ref() {
 		prereq=$1
 		shift
 	esac
-	test_expect_success $prereq "ref name '$1' is invalid${2:+ with options $2}" "
+	desc="ref name '$1' is invalid${2:+ with options $2}"
+	test_expect_success $prereq "$desc" "
 		test_must_fail git check-ref-format $2 '$1'
 	"
 }
-- 
1.7.12

^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2013-01-10 21:25 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-08 20:23 [PATCH] t1402: work around shell quoting issue on NetBSD René Scharfe
2013-01-08 20:39 ` Junio C Hamano
2013-01-08 21:13   ` René Scharfe
2013-01-08 21:37     ` Junio C Hamano
2013-01-09 23:49       ` [PATCH] t0008: avoid brace expansion René Scharfe
2013-01-09 23:56         ` Adam Spiers
2013-01-10  0:18           ` Junio C Hamano
2013-01-10  0:22             ` Adam Spiers
2013-01-10 21:24             ` René Scharfe
2013-01-09  1:27 ` [PATCH] t1402: work around shell quoting issue on NetBSD Greg Troxel
2013-01-09  2:07 ` Greg Troxel

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).