Thread (43 messages) flat view 43 messages, 3 authors, 2016-06-15

Re: [PATCHv2 4/6] t7510: exit for loop with test result

From: Michael J Gruber <hidden>
Date: 2016-06-15 23:01:37

Johannes Sixt venit, vidit, dixit 13.06.2014 15:21:
Am 6/13/2014 15:06, schrieb Michael J Gruber:
quoted
Johannes Sixt venit, vidit, dixit 13.06.2014 14:54:
quoted
Am 6/13/2014 14:33, schrieb Michael J Gruber:
quoted
.... with this loop, sorry:

for X in true false; do
     for Y in false true; do
       ($X && $Y || exit 1)
     done
     echo "$X/last inner $Y: $?"
done

gives

true/last inner true: 0
false/last inner true: 1

even though on both cases we have at least one failure of Y. (failure of
one subtest = failure of the test)
Place the loop(s) inside the subshell, and you observe termination on the
first failure, and a failure exit code of the subshell.

The change proposed in this patch should not be necessary. Something else
must be wrong with your tests.
I know I started this (or Jeff did, who knows ;) ), but we keep
confusing each other more and more:
quoted
Ah, here it is:
@@ -58,7 +58,7 @@ test_expect_success GPG 'show signatures' '
 	(
 		for commit in merge^2 fourth-unsigned sixth-unsigned seventh-unsigned
 		do
-			git show --pretty=short --show-signature $commit >actual &&
+			git show --pretty=short --show-signature $commit >actual || exit 1
 			grep "Good signature from" actual && exit 1
This is as in the original, it tests invalid signatures, so "Good
signature" should not be in the response.
quoted
 			! grep "BAD signature from" actual || exit 1
 			echo $commit OK

Notice the '&& exit 1'! It should be '|| exit 1', right?

-- Hannes
In other words, the original tests already had

grep foo && exit 1
! grep bar || exit 1

to test that we have neither foo nor bar. The reason is (supposedly) to
have this portion of the test mostly analogous to the previous one,
where we want foo and do want bar.

So this is completely unrelated.
I don't think so. What is the outcome of

	false &&  # simulate a regression
	grep foo && exit 1
	! grep bar || exit 1

assuming that the '! grep bar' happens to be true? Answer: The regression
is not diagnosed because the &&-chain is broken.

*That* is what I think you described earlier in this thread as "I put
something failing on the first line of the original version, and the test
succeeded."

-- Hannes
If you say that something I have said makes sense I'm happy, because I
can't confirm that myself right now. I'll take a break and look into a
rewrite of the form

a &&
b &&
test_must_fail c &&
d || exit 1

hoping that will make things both readable (by avoiding !) and concise
(by avoiding repeated exits).

Michael
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help