@matheusbsbs / matheus-bagliano / commits / 1a994dc3d2
Fork 0

t1200: cleanup and modernize test style

Many parts of the tests in t1200 are run outside the test harness, circumventing the usefulness of -v and spewing messages to stdout when -v isn't used. Fix these problems by modernizing the test a bit. An extra test_done has existed since commit 6a74642 (git-commit --amend: two fixes., 2006-04-20) leading to the last 6 tests never being run. Remove it and teach the resolve merge test about fast-forward merges. Also fix the last test's incorrect find command and prune before checking for unpacked objects so we remove the unreachable conflict-marked blob. Finally, we remove the TODO notes, because fetch, push, and clone have their own tests since t1200 was introduced and we're not going to add them here 4 years later. Signed-off-by: Stephen Boyd <bebarino@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Stephen Boyd committed Nov 4, 2009 at 22:33 UTC 1a994dc3d258a1603752e0c472b072acc343a963
1 file changed +76 -58
t/t1200-tutorial.sh
+76 -58
@@ -7,14 +7,18 @@ test_description='A simple turial in the form of a test case'
7
8 . ./test-lib.sh
9
10 -echo "Hello World" > hello
11 -echo "Silly example" > example
10 +test_expect_success 'blob' '
11 + echo "Hello World" > hello &&
12 + echo "Silly example" > example &&
13
13 -git update-index --add hello example
14 + git update-index --add hello example &&
15
15 -test_expect_success 'blob' "test blob = \"$(git cat-file -t 557db03)\""
16 + test blob = "$(git cat-file -t 557db03)"
17 +'
18
17 -test_expect_success 'blob 557db03' "test \"Hello World\" = \"$(git cat-file blob 557db03)\""
19 +test_expect_success 'blob 557db03' '
20 + test "Hello World" = "$(git cat-file blob 557db03)"
21 +'
22
23 echo "It's a new day for git" >>hello
24 cat > diff.expect << EOF
@@ -26,25 +30,33 @@ index 557db03..263414f 100644
30 Hello World
31 +It's a new day for git
32 EOF
29 -git diff-files -p > diff.output
30 -test_expect_success 'git diff-files -p' 'cmp diff.expect diff.output'
31 -git diff > diff.output
32 -test_expect_success 'git diff' 'cmp diff.expect diff.output'
33 -
34 -tree=$(git write-tree 2>/dev/null)
33
36 -test_expect_success 'tree' "test 8988da15d077d4829fc51d8544c097def6644dbb = $tree"
34 +test_expect_success 'git diff-files -p' '
35 + git diff-files -p > diff.output &&
36 + cmp diff.expect diff.output
37 +'
38
38 -output="$(echo "Initial commit" | git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master)"
39 +test_expect_success 'git diff' '
40 + git diff > diff.output &&
41 + cmp diff.expect diff.output
42 +'
43
40 -git diff-index -p HEAD > diff.output
41 -test_expect_success 'git diff-index -p HEAD' 'cmp diff.expect diff.output'
44 +test_expect_success 'tree' '
45 + tree=$(git write-tree 2>/dev/null)
46 + test 8988da15d077d4829fc51d8544c097def6644dbb = $tree
47 +'
48
43 -git diff HEAD > diff.output
44 -test_expect_success 'git diff HEAD' 'cmp diff.expect diff.output'
49 +test_expect_success 'git diff-index -p HEAD' '
50 + echo "Initial commit" | \
51 + git commit-tree $(git write-tree) 2>&1 > .git/refs/heads/master &&
52 + git diff-index -p HEAD > diff.output &&
53 + cmp diff.expect diff.output
54 +'
55
46 -#rm hello
47 -#test_expect_success 'git read-tree --reset HEAD' "git read-tree --reset HEAD ; test \"hello: needs update\" = \"$(git update-index --refresh)\""
56 +test_expect_success 'git diff HEAD' '
57 + git diff HEAD > diff.output &&
58 + cmp diff.expect diff.output
59 +'
60
61 cat > whatchanged.expect << EOF
62 commit VARIABLE
@@ -69,39 +81,45 @@ index 0000000..557db03
81 +Hello World
82 EOF
83
72 -git whatchanged -p --root | \
73 - sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \
84 +test_expect_success 'git whatchanged -p --root' '
85 + git whatchanged -p --root | \
86 + sed -e "1s/^\(.\{7\}\).\{40\}/\1VARIABLE/" \
87 -e "2,3s/^\(.\{8\}\).*$/\1VARIABLE/" \
75 -> whatchanged.output
76 -test_expect_success 'git whatchanged -p --root' 'cmp whatchanged.expect whatchanged.output'
77 -
78 -git tag my-first-tag
79 -test_expect_success 'git tag my-first-tag' 'cmp .git/refs/heads/master .git/refs/tags/my-first-tag'
88 + > whatchanged.output &&
89 + cmp whatchanged.expect whatchanged.output
90 +'
91
81 -# TODO: test git clone
92 +test_expect_success 'git tag my-first-tag' '
93 + git tag my-first-tag &&
94 + cmp .git/refs/heads/master .git/refs/tags/my-first-tag
95 +'
96
83 -git checkout -b mybranch
84 -test_expect_success 'git checkout -b mybranch' 'cmp .git/refs/heads/master .git/refs/heads/mybranch'
97 +test_expect_success 'git checkout -b mybranch' '
98 + git checkout -b mybranch &&
99 + cmp .git/refs/heads/master .git/refs/heads/mybranch
100 +'
101
102 cat > branch.expect <<EOF
103 master
104 * mybranch
105 EOF
106
91 -git branch > branch.output
92 -test_expect_success 'git branch' 'cmp branch.expect branch.output'
107 +test_expect_success 'git branch' '
108 + git branch > branch.output &&
109 + cmp branch.expect branch.output
110 +'
111
94 -git checkout mybranch
95 -echo "Work, work, work" >>hello
96 -git commit -m 'Some work.' -i hello
112 +test_expect_success 'git resolve now fails' '
113 + git checkout mybranch &&
114 + echo "Work, work, work" >>hello &&
115 + git commit -m "Some work." -i hello &&
116
98 -git checkout master
117 + git checkout master &&
118
100 -echo "Play, play, play" >>hello
101 -echo "Lots of fun" >>example
102 -git commit -m 'Some fun.' -i hello example
119 + echo "Play, play, play" >>hello &&
120 + echo "Lots of fun" >>example &&
121 + git commit -m "Some fun." -i hello example &&
122
104 -test_expect_success 'git resolve now fails' '
123 test_must_fail git merge -m "Merge work in mybranch" mybranch
124 '
125
@@ -112,10 +130,6 @@ Play, play, play
130 Work, work, work
131 EOF
132
115 -git commit -m 'Merged "mybranch" changes.' -i hello
116 -
117 -test_done
118 -
133 cat > show-branch.expect << EOF
134 * [master] Merged "mybranch" changes.
135 ! [mybranch] Some work.
@@ -124,21 +138,26 @@ cat > show-branch.expect << EOF
138 *+ [mybranch] Some work.
139 EOF
140
127 -git show-branch --topo-order master mybranch > show-branch.output
128 -test_expect_success 'git show-branch' 'cmp show-branch.expect show-branch.output'
129 -
130 -git checkout mybranch
141 +test_expect_success 'git show-branch' '
142 + git commit -m "Merged \"mybranch\" changes." -i hello &&
143 + git show-branch --topo-order master mybranch > show-branch.output &&
144 + cmp show-branch.expect show-branch.output
145 +'
146
147 cat > resolve.expect << EOF
133 -Updating from VARIABLE to VARIABLE
148 +Updating VARIABLE..VARIABLE
149 +Fast forward (no commit created; -m option ignored)
150 example | 1 +
151 hello | 1 +
152 2 files changed, 2 insertions(+), 0 deletions(-)
153 EOF
154
139 -git merge -s "Merge upstream changes." master | \
140 - sed -e "1s/[0-9a-f]\{40\}/VARIABLE/g" >resolve.output
141 -test_expect_success 'git resolve' 'cmp resolve.expect resolve.output'
155 +test_expect_success 'git resolve' '
156 + git checkout mybranch &&
157 + git merge -m "Merge upstream changes." master | \
158 + sed -e "1s/[0-9a-f]\{7\}/VARIABLE/g" >resolve.output &&
159 + cmp resolve.expect resolve.output
160 +'
161
162 cat > show-branch2.expect << EOF
163 ! [master] Merged "mybranch" changes.
@@ -147,17 +166,16 @@ cat > show-branch2.expect << EOF
166 -- [master] Merged "mybranch" changes.
167 EOF
168
150 -git show-branch --topo-order master mybranch > show-branch2.output
151 -test_expect_success 'git show-branch' 'cmp show-branch2.expect show-branch2.output'
152 -
153 -# TODO: test git fetch
154 -
155 -# TODO: test git push
169 +test_expect_success 'git show-branch (part 2)' '
170 + git show-branch --topo-order master mybranch > show-branch2.output &&
171 + cmp show-branch2.expect show-branch2.output
172 +'
173
174 test_expect_success 'git repack' 'git repack'
175 test_expect_success 'git prune-packed' 'git prune-packed'
176 test_expect_success '-> only packed objects' '
160 - ! find -type f .git/objects/[0-9a-f][0-9a-f]
177 + git prune && # Remove conflict marked blobs
178 + ! find .git/objects/[0-9a-f][0-9a-f] -type f
179 '
180
181 test_done