t9300-fast-import: avoid 'exit' in test_expect_success snippets

Exiting from a for-loop early using '|| break' does not propagate the failure code, and for this reason, the tests used just 'exit'. But this ends the test script with 'FATAL: Unexpected exit code 1' in the case of a failed test. Fix this by moving the loop into a shell function, from which we can simply return early. While at it, modernize the style of the affected test cases. Signed-off-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed Apr 20, 2012 at 08:25 UTC 05880b02221dc8da136e9febfa7853ad822b1ee1
1 file changed +54 -34
t/t9300-fast-import.sh
+54 -34
@@ -24,6 +24,13 @@ head_c () {
24 ' - "$1"
25 }
26
27 +verify_packs () {
28 + for p in .git/objects/pack/*.pack
29 + do
30 + git verify-pack "$@" "$p" || return
31 + done
32 +}
33 +
34 file2_data='file2
35 second line of EOF'
36
@@ -105,9 +112,10 @@ test_expect_success \
112 'A: create pack from stdin' \
113 'git fast-import --export-marks=marks.out <input &&
114 git whatchanged master'
108 -test_expect_success \
109 - 'A: verify pack' \
110 - 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
115 +
116 +test_expect_success 'A: verify pack' '
117 + verify_packs
118 +'
119
120 cat >expect <<EOF
121 author $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
@@ -252,9 +260,11 @@ test_expect_success \
260 'A: verify marks import does not crash' \
261 'git fast-import --import-marks=marks.out <input &&
262 git whatchanged verify--import-marks'
255 -test_expect_success \
256 - 'A: verify pack' \
257 - 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
263 +
264 +test_expect_success 'A: verify pack' '
265 + verify_packs
266 +'
267 +
268 cat >expect <<EOF
269 :000000 100755 0000000000000000000000000000000000000000 7123f7f44e39be127c5eb701e5968176ee9d78b1 A copy-of-file2
270 EOF
@@ -514,9 +524,11 @@ test_expect_success \
524 'C: incremental import create pack from stdin' \
525 'git fast-import <input &&
526 git whatchanged branch'
517 -test_expect_success \
518 - 'C: verify pack' \
519 - 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
527 +
528 +test_expect_success 'C: verify pack' '
529 + verify_packs
530 +'
531 +
532 test_expect_success \
533 'C: validate reuse existing blob' \
534 'test $newf = `git rev-parse --verify branch:file2/newf` &&
@@ -572,9 +584,10 @@ test_expect_success \
584 'D: inline data in commit' \
585 'git fast-import <input &&
586 git whatchanged branch'
575 -test_expect_success \
576 - 'D: verify pack' \
577 - 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
587 +
588 +test_expect_success 'D: verify pack' '
589 + verify_packs
590 +'
591
592 cat >expect <<EOF
593 :000000 100755 0000000000000000000000000000000000000000 35a59026a33beac1569b1c7f66f3090ce9c09afc A newdir/exec.sh
@@ -618,9 +631,10 @@ test_expect_success 'E: rfc2822 date, --date-format=raw' '
631 test_expect_success \
632 'E: rfc2822 date, --date-format=rfc2822' \
633 'git fast-import --date-format=rfc2822 <input'
621 -test_expect_success \
622 - 'E: verify pack' \
623 - 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
634 +
635 +test_expect_success 'E: verify pack' '
636 + verify_packs
637 +'
638
639 cat >expect <<EOF
640 author $GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL> 1170778938 -0500
@@ -669,9 +683,10 @@ test_expect_success \
683 fi
684 fi
685 '
672 -test_expect_success \
673 - 'F: verify pack' \
674 - 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
686 +
687 +test_expect_success 'F: verify pack' '
688 + verify_packs
689 +'
690
691 cat >expect <<EOF
692 tree `git rev-parse branch~1^{tree}`
@@ -705,9 +720,11 @@ INPUT_END
720 test_expect_success \
721 'G: non-fast-forward update forced' \
722 'git fast-import --force <input'
708 -test_expect_success \
709 - 'G: verify pack' \
710 - 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
723 +
724 +test_expect_success 'G: verify pack' '
725 + verify_packs
726 +'
727 +
728 test_expect_success \
729 'G: branch changed, but logged' \
730 'test $old_branch != `git rev-parse --verify branch^0` &&
@@ -742,9 +759,10 @@ test_expect_success \
759 'H: deletall, add 1' \
760 'git fast-import <input &&
761 git whatchanged H'
745 -test_expect_success \
746 - 'H: verify pack' \
747 - 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
762 +
763 +test_expect_success 'H: verify pack' '
764 + verify_packs
765 +'
766
767 cat >expect <<EOF
768 :100755 000000 f1fb5da718392694d0076d677d6d0e364c79b0bc 0000000000000000000000000000000000000000 D file2/newf
@@ -1857,9 +1875,10 @@ test_expect_success \
1875 'Q: commit notes' \
1876 'git fast-import <input &&
1877 git whatchanged notes-test'
1860 -test_expect_success \
1861 - 'Q: verify pack' \
1862 - 'for p in .git/objects/pack/*.pack;do git verify-pack $p||exit;done'
1878 +
1879 +test_expect_success 'Q: verify pack' '
1880 + verify_packs
1881 +'
1882
1883 commit1=$(git rev-parse notes-test~2)
1884 commit2=$(git rev-parse notes-test^)
@@ -2616,13 +2635,14 @@ test_expect_success \
2635 'R: blob bigger than threshold' \
2636 'test_create_repo R &&
2637 git --git-dir=R/.git fast-import --big-file-threshold=1 <input'
2619 -test_expect_success \
2620 - 'R: verify created pack' \
2621 - ': >verify &&
2622 - for p in R/.git/objects/pack/*.pack;
2623 - do
2624 - git verify-pack -v $p >>verify || exit;
2625 - done'
2638 +
2639 +test_expect_success 'R: verify created pack' '
2640 + (
2641 + cd R &&
2642 + verify_packs -v > ../verify
2643 + )
2644 +'
2645 +
2646 test_expect_success \
2647 'R: verify written objects' \
2648 'git --git-dir=R/.git cat-file blob big-file:big1 >actual &&