@matheusbsbs / matheus-bagliano / commits / 4a45f7dd49
Fork 0

Use test_expect_success for test setups

Several tests did not use test_expect_success for their setup commands. Putting these start commands into the testing framework means both that errors during setup will be caught quickly and that non-error text will be suppressed without -v. Signed-off-by: Brian Gernhardt <brian@gernhardtsoftware.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Brian Gernhardt committed Mar 20, 2010 at 04:29 UTC 4a45f7dd49ba9a8943ad9b11fb7bed04f0cb4f15
5 files changed +70 -61
t/t3020-ls-files-error-unmatch.sh
+5 -3
@@ -11,9 +11,11 @@ line.
11 '
12 . ./test-lib.sh
13
14 -touch foo bar
15 -git update-index --add foo bar
16 -git commit -m "add foo bar"
14 +test_expect_success 'setup' '
15 + touch foo bar &&
16 + git update-index --add foo bar &&
17 + git commit -m "add foo bar"
18 +'
19
20 test_expect_success \
21 'git ls-files --error-unmatch should fail with unmatched path.' \
t/t3800-mktag.sh
+6 -4
@@ -22,10 +22,12 @@ check_verify_failure () {
22 ###########################################################
23 # first create a commit, so we have a valid object/type
24 # for the tag.
25 -echo Hello >A
26 -git update-index --add A
27 -git commit -m "Initial commit"
28 -head=$(git rev-parse --verify HEAD)
25 +test_expect_success 'setup' '
26 + echo Hello >A &&
27 + git update-index --add A &&
28 + git commit -m "Initial commit" &&
29 + head=$(git rev-parse --verify HEAD)
30 +'
31
32 ############################################################
33 # 1. length check
t/t4103-apply-binary.sh
+19 -17
@@ -20,23 +20,25 @@ EOF
20 cat file1 >file2
21 cat file1 >file4
22
23 -git update-index --add --remove file1 file2 file4
24 -git commit -m 'Initial Version' 2>/dev/null
25 -
26 -git checkout -b binary
27 -perl -pe 'y/x/\000/' <file1 >file3
28 -cat file3 >file4
29 -git add file2
30 -perl -pe 'y/\000/v/' <file3 >file1
31 -rm -f file2
32 -git update-index --add --remove file1 file2 file3 file4
33 -git commit -m 'Second Version'
34 -
35 -git diff-tree -p master binary >B.diff
36 -git diff-tree -p -C master binary >C.diff
37 -
38 -git diff-tree -p --binary master binary >BF.diff
39 -git diff-tree -p --binary -C master binary >CF.diff
23 +test_expect_success 'setup' "
24 + git update-index --add --remove file1 file2 file4 &&
25 + git commit -m 'Initial Version' 2>/dev/null &&
26 +
27 + git checkout -b binary &&
28 + perl -pe 'y/x/\000/' <file1 >file3 &&
29 + cat file3 >file4 &&
30 + git add file2 &&
31 + perl -pe 'y/\000/v/' <file3 >file1 &&
32 + rm -f file2 &&
33 + git update-index --add --remove file1 file2 file3 file4 &&
34 + git commit -m 'Second Version' &&
35 +
36 + git diff-tree -p master binary >B.diff &&
37 + git diff-tree -p -C master binary >C.diff &&
38 +
39 + git diff-tree -p --binary master binary >BF.diff &&
40 + git diff-tree -p --binary -C master binary >CF.diff
41 +"
42
43 test_expect_success 'stat binary diff -- should not fail.' \
44 'git checkout master
t/t4200-rerere.sh
+36 -34
@@ -8,40 +8,42 @@ test_description='git rerere
8
9 . ./test-lib.sh
10
11 -cat > a1 << EOF
12 -Some title
13 -==========
14 -Whether 'tis nobler in the mind to suffer
15 -The slings and arrows of outrageous fortune,
16 -Or to take arms against a sea of troubles,
17 -And by opposing end them? To die: to sleep;
18 -No more; and by a sleep to say we end
19 -The heart-ache and the thousand natural shocks
20 -That flesh is heir to, 'tis a consummation
21 -Devoutly to be wish'd.
22 -EOF
23 -
24 -git add a1
25 -git commit -q -a -m initial
26 -
27 -git checkout -b first
28 -cat >> a1 << EOF
29 -Some title
30 -==========
31 -To die, to sleep;
32 -To sleep: perchance to dream: ay, there's the rub;
33 -For in that sleep of death what dreams may come
34 -When we have shuffled off this mortal coil,
35 -Must give us pause: there's the respect
36 -That makes calamity of so long life;
37 -EOF
38 -git commit -q -a -m first
39 -
40 -git checkout -b second master
41 -git show first:a1 |
42 -sed -e 's/To die, t/To die! T/' -e 's/Some title/Some Title/' > a1
43 -echo "* END *" >>a1
44 -git commit -q -a -m second
11 +test_expect_success 'setup' "
12 + cat > a1 <<- EOF &&
13 + Some title
14 + ==========
15 + Whether 'tis nobler in the mind to suffer
16 + The slings and arrows of outrageous fortune,
17 + Or to take arms against a sea of troubles,
18 + And by opposing end them? To die: to sleep;
19 + No more; and by a sleep to say we end
20 + The heart-ache and the thousand natural shocks
21 + That flesh is heir to, 'tis a consummation
22 + Devoutly to be wish'd.
23 + EOF
24 +
25 + git add a1 &&
26 + git commit -q -a -m initial &&
27 +
28 + git checkout -b first &&
29 + cat >> a1 <<- EOF &&
30 + Some title
31 + ==========
32 + To die, to sleep;
33 + To sleep: perchance to dream: ay, there's the rub;
34 + For in that sleep of death what dreams may come
35 + When we have shuffled off this mortal coil,
36 + Must give us pause: there's the respect
37 + That makes calamity of so long life;
38 + EOF
39 + git commit -q -a -m first &&
40 +
41 + git checkout -b second master &&
42 + git show first:a1 |
43 + sed -e 's/To die, t/To die! T/' -e 's/Some title/Some Title/' > a1 &&
44 + echo '* END *' >>a1 &&
45 + git commit -q -a -m second
46 +"
47
48 test_expect_success 'nothing recorded without rerere' '
49 (rm -rf .git/rr-cache; git config rerere.enabled false) &&
t/t9501-gitweb-standalone-http-status.sh
+4 -3
@@ -15,9 +15,10 @@ code and message.'
15 # ----------------------------------------------------------------------
16 # snapshot settings
17
18 -test_commit \
19 - 'SnapshotTests' \
20 - 'i can has snapshot?'
18 +test_expect_success 'setup' "
19 + test_commit 'SnapshotTests' 'i can has snapshot?'
20 +"
21 +
22
23 cat >>gitweb_config.perl <<\EOF
24 $feature{'snapshot'}{'override'} = 0;