Subject: Re: [PATCHv3 0/5]rev-list and friends: --min-parents, --max-parents

From: Jonathan Nieder <[email-masked]>
Date: Thu, 24 Mar 2011 04:42:31 -0500

Michael J Gruber wrote:

> What's the simplest way to run the tests so that they catch
> non-POSIXisms?

In theory: use posh from <git://git.debian.org/users/clint/posh.git>.

In practice, testing with dash seems to work well for catching these.
dash tends to be less buggy but more forgiving because some people
(like me :)) use it day-to-day.

> I thought it's considered bad style to mix setup and actual test?
> Personally, I don't care either way. I just didn't want to have these 12
> extra commits in the initial setup (forcing me to adjust all tests).

Other test frameworks (inspired by JUnit?) like to separate errors
from set-up, tear-down, and the meat of the tests, but the git's test
suite doesn't do that.  Its goal is to test git rather than to track
bugs in the harness.

Still, many scripts include a test that sets up some state to be
shared by later tests.  This way, if git is severely broken (e.g., it
segfaults), then even the setup will fail; and meanwhile, it means it
is still possible to safely skip other individual tests with
GIT_SKIP_TESTS.

Anyway, I shouldn't have included such a tiny nit with the brace
expansion fix.  Sorry about that.  Here's a more minimal patch.

-- 8< --
Subject: tests: avoid nonportable {foo,bar} glob

Unlike bash and ksh, dash and busybox ash do not support brace
expansion (as in 'echo {hello,world}').  So when dash is sh,
t6009.13 (set up dodecapus) ends up passing a string beginning with
"root{1,2," to "git merge" verbatim and the test fails.

Fix it by introducing a variable to hold the list of parents for
the dodecapus and populating it in a more low-tech way.

Signed-off-by: Jonathan Nieder <[email-masked]>
---
 t/t6009-rev-list-parent.sh |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/t/t6009-rev-list-parent.sh b/t/t6009-rev-list-parent.sh
index fc89d6d..b30834d 100755
--- a/t/t6009-rev-list-parent.sh
+++ b/t/t6009-rev-list-parent.sh
@@ -114,14 +114,16 @@ test_expect_success 'rev-list override and infinities' '
 
 test_expect_success 'set up dodecapus' '
 
+	roots= &&
 	for i in 1 2 3 4 5 6 7 8 9 10 11
 	do
 		git checkout -b root$i five || return
 		test_commit $i || return
+		roots="$roots root$i" || return
 	done &&
 	git checkout master &&
 	test_tick &&
-	git merge -m dodecapus root{1,2,3,4,5,6,7,8,9,10,11} &&
+	git merge -m dodecapus $roots &&
 	git tag dodecapus
 '
 
-- 
1.7.4.1