Skip to contentSkip to conversation

t7300: fix broken && chains

PATCH In review Erik Elfström 3 participants 7 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 t7300: fix broken && chains

While we are here, remove some boilerplate by using test_commit.

---
 t/t7300-clean.sh | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
t/t7300-clean.sh +4 -12
index 27557d6..86ceb38 100755
@@ -432,9 +432,7 @@ test_expect_success 'nested git work tree' '
 	(
 		cd foo &&
 		git init &&
-		>hello.world
-		git add . &&
-		git commit -a -m nested
+		test_commit nested hello.world
 	) &&
 	(
 		cd bar &&
@@ -443,9 +441,7 @@ test_expect_success 'nested git work tree' '
 	(
 		cd baz/boo &&
 		git init &&
-		>deeper.world
-		git add . &&
-		git commit -a -m deeply.nested
+		test_commit deeply.nested deeper.world
 	) &&
 	git clean -f -d &&
 	test -f foo/.git/index &&
@@ -601,9 +597,7 @@ test_expect_success 'force removal of nested git work tree' '
 	(
 		cd foo &&
 		git init &&
-		>hello.world
-		git add . &&
-		git commit -a -m nested
+		test_commit nested hello.world
 	) &&
 	(
 		cd bar &&
@@ -612,9 +606,7 @@ test_expect_success 'force removal of nested git work tree' '
 	(
 		cd baz/boo &&
 		git init &&
-		>deeper.world
-		git add . &&
-		git commit -a -m deeply.nested
+		test_commit deeply.nested deeper.world
 	) &&
 	git clean -f -f -d &&
 	! test -d foo &&
Signature · 1 line
2.4.4.410.gd6567e3
#1 lore raw
Quoted 1 line · Erik Elfström

While we are here, remove some boilerplate by using test_commit.

Darn, I thought we were done finding these after flipping on GIT_TEST_CHAIN_LINT. :)

t/t7300-clean.sh test_expect_success 'nested git work tree' ' · line 436

Quoted 13 lines
t/t7300-clean.sh +1 -3
index 27557d6..86ceb38 100755
@@ -432,9 +432,7 @@ test_expect_success 'nested git work tree' '
 	(
 		cd foo &&
 		git init &&
-		>hello.world
-		git add . &&
-		git commit -a -m nested
+		test_commit nested hello.world
 	) &&

Unfortunately CHAIN_LINT cannot reach inside a nested subshell. I cannot think of a way to make it do so, and besides, that is also the way to override the &&-chain precedence. So I think it is not really possible to get better coverage here. And such cases as these are not really very interesting (e.g., here we exclude only minor minor setup steps from the &&-chain).

-Peff

#4 lore raw
In reply to Erik Elfström
Quoted 4 lines · Erik Elfström

While we are here, remove some boilerplate by using test_commit.

---

Many of the constructs we see here shows clearly that this is an ancient part of the codebase ;-), as we would be using the one parameter form of "git init" and more test_* helpers if we were writing this script in today's Git codebase. It may have been better if you didn't do "while we are here" and corrected only the &&-chain in patch 1/2 and then updated the style of the tests to take advantage of the newer facilities recent test-lib has in a separate patch 2/2, but this will do at least for now.

Will queue.

Thanks.

Quoted 51 lines
 t/t7300-clean.sh | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)
t/t7300-clean.sh +4 -12
index 27557d6..86ceb38 100755
@@ -432,9 +432,7 @@ test_expect_success 'nested git work tree' '
 	(
 		cd foo &&
 		git init &&
-		>hello.world
-		git add . &&
-		git commit -a -m nested
+		test_commit nested hello.world
 	) &&
 	(
 		cd bar &&
@@ -443,9 +441,7 @@ test_expect_success 'nested git work tree' '
 	(
 		cd baz/boo &&
 		git init &&
-		>deeper.world
-		git add . &&
-		git commit -a -m deeply.nested
+		test_commit deeply.nested deeper.world
 	) &&
 	git clean -f -d &&
 	test -f foo/.git/index &&
@@ -601,9 +597,7 @@ test_expect_success 'force removal of nested git work tree' '
 	(
 		cd foo &&
 		git init &&
-		>hello.world
-		git add . &&
-		git commit -a -m nested
+		test_commit nested hello.world
 	) &&
 	(
 		cd bar &&
@@ -612,9 +606,7 @@ test_expect_success 'force removal of nested git work tree' '
 	(
 		cd baz/boo &&
 		git init &&
-		>deeper.world
-		git add . &&
-		git commit -a -m deeply.nested
+		test_commit deeply.nested deeper.world
 	) &&
 	git clean -f -f -d &&
 	! test -d foo &&
#2 lore raw
In reply to Jeff King
Quoted 10 lines · Jeff King

On Sun, Aug 30, 2015 at 11:18:09AM +0200, Erik Elfström wrote:

Unfortunately CHAIN_LINT cannot reach inside a nested subshell. I cannot think of a way to make it do so, and besides, that is also the way to override the &&-chain precedence. So I think it is not really possible to get better coverage here. And such cases as these are not really very interesting (e.g., here we exclude only minor minor setup steps from the &&-chain).

-Peff

I actually hacked together an ugly script to check for more broken chains. It's not working very well and I haven't checked the output thoroughly but I did see quite a few broken chains. Many are of the (mostly harmless) form:

     (
        echo "100644 $o5 0    a"
        echo "100644 $o0 0    c"
        echo "160000 $c1 0    d"
    ) >expected &&

I'd estimate that there are hundreds of these (see t3030 for examples). I'm not sure if you care about these? As you say they are not really very interesting cases.

/Erik

#3 lore raw
Quoted 9 lines · erik elfström
     (
        echo "100644 $o5 0    a"
        echo "100644 $o0 0    c"
        echo "160000 $c1 0    d"
    ) >expected &&

I'd estimate that there are hundreds of these (see t3030 for examples). I'm not sure if you care about these? As you say they are not really very interesting cases.

I think patches for these are OK, but no, I don't consider it a high priority if they are harmless (IMHO the real value of the patches is that it removes the noise from the output of your script, so you can find any cases that _do_ matter).

-Peff

#5 lore raw
In reply to Junio C Hamano
Quoted 10 lines · Junio C Hamano

Many of the constructs we see here shows clearly that this is an ancient part of the codebase ;-), as we would be using the one parameter form of "git init" and more test_* helpers if we were writing this script in today's Git codebase. It may have been better if you didn't do "while we are here" and corrected only the &&-chain in patch 1/2 and then updated the style of the tests to take advantage of the newer facilities recent test-lib has in a separate patch 2/2, but this will do at least for now.

Quoted 3 lines

Will queue.

Thanks.

I can do a re-roll with the chain fix in the first patch and a more thorough modernization of t7300 in separate patches if you'd like? I almost went this way for v1 but decided to limit the scope for the first version.

(Forgot to include the list in my first reply, sorry... And forgot to turn off HTML in the second... sigh, sorry for the spam)

/Erik

#6 lore raw
Quoted 8 lines · erik elfström
Quoted 7 lines · Junio C Hamano

... It may have been
better if you didn't do "while we are here" and corrected only the &&-chain in patch 1/2 and then updated the style of the tests to take advantage of the newer facilities recent test-lib has in a separate patch 2/2, but this will do at least for now.

Quoted 8 lines
Quoted 3 lines

Will queue.

Thanks.

I can do a re-roll with the chain fix in the first patch and a more thorough modernization of t7300 in separate patches if you'd like? I almost went this way for v1 but decided to limit the scope for the first version.

I'd say it is too much work for something that we already have reviewed and queued ;-) Let's have this patch as-is.

Modernization and clean-up from time to time is a good thing to do, but we only have limited review bandwidth, so let's not overdo it.

Thanks.