@matheusbsbs / matheus-bagliano / commits / 188c3827c1
Fork 0

Tests: use test_cmp instead of diff where possible

Several old tests were written before test_cmp was introduced, convert these to test_cmp. If were are at it, fix the order of the arguments where necessary to make expected come first, so the command shows how the test result deviates from the correct output. Signed-off-by: Miklos Vajna <vmiklos@frugalware.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Miklos Vajna committed Mar 16, 2009 at 21:18 UTC 188c3827c10f5a04588ef7af8b63a7b5dbcc38ed
7 files changed +24 -24
t/t0000-basic.sh
+4 -4
@@ -127,7 +127,7 @@ cat >expected <<\EOF
127 EOF
128 test_expect_success \
129 'validate git ls-files output for a known tree.' \
130 - 'diff current expected'
130 + 'test_cmp expected current'
131
132 test_expect_success \
133 'writing tree out with git write-tree.' \
@@ -147,7 +147,7 @@ cat >expected <<\EOF
147 EOF
148 test_expect_success \
149 'git ls-tree output for a known tree.' \
150 - 'diff current expected'
150 + 'test_cmp expected current'
151
152 # This changed in ls-tree pathspec change -- recursive does
153 # not show tree nodes anymore.
@@ -166,7 +166,7 @@ cat >expected <<\EOF
166 EOF
167 test_expect_success \
168 'git ls-tree -r output for a known tree.' \
169 - 'diff current expected'
169 + 'test_cmp expected current'
170
171 # But with -r -t we can have both.
172 test_expect_success \
@@ -187,7 +187,7 @@ cat >expected <<\EOF
187 EOF
188 test_expect_success \
189 'git ls-tree -r output for a known tree.' \
190 - 'diff current expected'
190 + 'test_cmp expected current'
191
192 test_expect_success \
193 'writing partial tree out with git write-tree --prefix.' \
t/t1100-commit-tree-options.sh
+1 -1
@@ -40,6 +40,6 @@ test_expect_success \
40
41 test_expect_success \
42 'compare commit' \
43 - 'diff expected commit'
43 + 'test_cmp expected commit'
44
45 test_done
t/t1400-update-ref.sh
+3 -3
@@ -137,7 +137,7 @@ $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150860 +0000
137 EOF
138 test_expect_success \
139 "verifying $m's log" \
140 - "diff expect .git/logs/$m"
140 + "test_cmp expect .git/logs/$m"
141 rm -rf .git/$m .git/logs expect
142
143 test_expect_success \
@@ -168,7 +168,7 @@ $B $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150980 +0000
168 EOF
169 test_expect_success \
170 "verifying $m's log" \
171 - 'diff expect .git/logs/$m'
171 + 'test_cmp expect .git/logs/$m'
172 rm -f .git/$m .git/logs/$m expect
173
174 git update-ref $m $D
@@ -272,7 +272,7 @@ $h_FIXED $h_MERGED $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117151100 +0000 c
272 EOF
273 test_expect_success \
274 'git commit logged updates' \
275 - "diff expect .git/logs/$m"
275 + "test_cmp expect .git/logs/$m"
276 unset h_TEST h_OTHER h_FIXED h_MERGED
277
278 test_expect_success \
t/t3000-ls-files-others.sh
+2 -2
@@ -42,7 +42,7 @@ test_expect_success \
42
43 test_expect_success \
44 'git ls-files --others should pick up symlinks.' \
45 - 'diff output expected1'
45 + 'test_cmp expected1 output'
46
47 test_expect_success \
48 'git ls-files --others --directory to show output.' \
@@ -51,6 +51,6 @@ test_expect_success \
51
52 test_expect_success \
53 'git ls-files --others --directory should not get confused.' \
54 - 'diff output expected2'
54 + 'test_cmp expected2 output'
55
56 test_done
t/t3010-ls-files-killed-modified.sh
+2 -2
@@ -75,7 +75,7 @@ EOF
75
76 test_expect_success \
77 'validate git ls-files -k output.' \
78 - 'diff .output .expected'
78 + 'test_cmp .expected .output'
79
80 test_expect_success \
81 'git ls-files -m to show modified files.' \
@@ -91,6 +91,6 @@ EOF
91
92 test_expect_success \
93 'validate git ls-files -m output.' \
94 - 'diff .output .expected'
94 + 'test_cmp .expected .output'
95
96 test_done
t/t5000-tar-tree.sh
+11 -11
@@ -76,7 +76,7 @@ test_expect_success \
76
77 test_expect_success \
78 'git archive vs. git tar-tree' \
79 - 'diff b.tar b2.tar'
79 + 'test_cmp b.tar b2.tar'
80
81 test_expect_success \
82 'git archive in a bare repo' \
@@ -96,12 +96,12 @@ test_expect_success \
96 "$TAR" xf b.tar -C extract a/a &&
97 test-chmtime -v +0 extract/a/a |cut -f 1 >b.mtime &&
98 echo "1117231200" >expected.mtime &&
99 - diff expected.mtime b.mtime'
99 + test_cmp expected.mtime b.mtime'
100
101 test_expect_success \
102 'git get-tar-commit-id' \
103 'git get-tar-commit-id <b.tar >b.commitid &&
104 - diff .git/$(git symbolic-ref HEAD) b.commitid'
104 + test_cmp .git/$(git symbolic-ref HEAD) b.commitid'
105
106 test_expect_success \
107 'extract tar archive' \
@@ -110,7 +110,7 @@ test_expect_success \
110 test_expect_success \
111 'validate filenames' \
112 '(cd b/a && find .) | sort >b.lst &&
113 - diff a.lst b.lst'
113 + test_cmp a.lst b.lst'
114
115 test_expect_success \
116 'validate file contents' \
@@ -127,7 +127,7 @@ test_expect_success \
127 test_expect_success \
128 'validate filenames with prefix' \
129 '(cd c/prefix/a && find .) | sort >c.lst &&
130 - diff a.lst c.lst'
130 + test_cmp a.lst c.lst'
131
132 test_expect_success \
133 'validate file contents with prefix' \
@@ -148,8 +148,8 @@ test_expect_success \
148 'validate substfile contents' \
149 'git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
150 >f/a/substfile1.expected &&
151 - diff f/a/substfile1.expected f/a/substfile1 &&
152 - diff a/substfile2 f/a/substfile2
151 + test_cmp f/a/substfile1.expected f/a/substfile1 &&
152 + test_cmp a/substfile2 f/a/substfile2
153 '
154
155 test_expect_success \
@@ -160,8 +160,8 @@ test_expect_success \
160 'validate substfile contents from archive with prefix' \
161 'git log --max-count=1 "--pretty=format:A${SUBSTFORMAT}O" HEAD \
162 >g/prefix/a/substfile1.expected &&
163 - diff g/prefix/a/substfile1.expected g/prefix/a/substfile1 &&
164 - diff a/substfile2 g/prefix/a/substfile2
163 + test_cmp g/prefix/a/substfile1.expected g/prefix/a/substfile1 &&
164 + test_cmp a/substfile2 g/prefix/a/substfile2
165 '
166
167 test_expect_success \
@@ -194,7 +194,7 @@ test_expect_success \
194 test_expect_success \
195 'validate filenames' \
196 '(cd d/a && find .) | sort >d.lst &&
197 - diff a.lst d.lst'
197 + test_cmp a.lst d.lst'
198
199 test_expect_success \
200 'validate file contents' \
@@ -211,7 +211,7 @@ test_expect_success \
211 test_expect_success \
212 'validate filenames with prefix' \
213 '(cd e/prefix/a && find .) | sort >e.lst &&
214 - diff a.lst e.lst'
214 + test_cmp a.lst e.lst'
215
216 test_expect_success \
217 'validate file contents with prefix' \
t/t9001-send-email.sh
+1 -1
@@ -88,7 +88,7 @@ cat >expected <<\EOF
88 EOF
89 test_expect_success \
90 'Verify commandline' \
91 - 'diff commandline1 expected'
91 + 'test_cmp expected commandline1'
92
93 cat >expected-show-all-headers <<\EOF
94 0001-Second.patch