Thread (11 messages) flat view 11 messages, 4 authors, 2016-06-16

Re: [PATCH 3/6] t9107: use "return 1" instead of "exit 1"

From: Eric Sunshine <hidden>
Date: 2016-06-16 02:19:23

Possibly related (same subject, not in this thread)

On Fri, May 13, 2016 at 4:47 PM, Jeff King [off-list ref] wrote:
quoted hunk ↗ jump to hunk
When a test runs a loop, it cannot rely on the usual
&&-chaining to propagate a failure inside the loop; it needs
to break out with a failure signal. However, unless you are
in a subshell, doing so with "exit 1" will exit the entire
test script, not just the test snippet we are in (and cause
the harness to complain that test_done was never reached).
[...snip...]

Signed-off-by: Jeff King <redacted>
---
diff --git a/t/t9107-git-svn-migrate.sh b/t/t9107-git-svn-migrate.sh
@@ -70,30 +72,38 @@ test_expect_success 'initialize a multi-repository repo' '
 # refs should all be different, but the trees should all be the same:
-test_expect_success 'multi-fetch works on partial urls + paths' "
+test_expect_success 'multi-fetch works on partial urls + paths' '
+       refs="trunk a b tags/0.1 tags/0.2 tags/0.3" &&
        git svn multi-fetch &&
-       for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
-               git rev-parse --verify refs/remotes/origin/\$i^0 >> refs.out || exit 1;
-           done &&
-       test -z \"\$(sort < refs.out | uniq -d)\" &&
-       for i in trunk a b tags/0.1 tags/0.2 tags/0.3; do
-         for j in trunk a b tags/0.1 tags/0.2 tags/0.3; do
-               if test \$j != \$i; then continue; fi
-           test -z \"\$(git diff refs/remotes/origin/\$i \
-                                refs/remotes/origin/\$j)\" ||exit 1; done; done
-       "
+       for i in $refs
+       do
+               git rev-parse --verify refs/remotes/origin/$i^0 || return 1;
+       done >refs.out &&
+       test -z "$(sort <refs.out | uniq -d)" &&
+       >expect &&
What's this 'expect' file for? Is it leftover gunk from before you
settled on 'diff --exit-code'?
+       for i in $refs
+       do
+               for j in $refs
+               do
+                       git diff --exit-code refs/remotes/origin/$i refs/remotes/origin/$j ||
+                               return 1
+               done
+       done
+'
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help