convert: modernize tests

Use `test_config` to set the config, check that files are empty with `test_must_be_empty`, compare files with `test_cmp`, and remove spaces after ">" and "<". Please note that the "rot13" filter configured in "setup" keeps using `git config` instead of `test_config` because subsequent tests might depend on it. Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Lars Schneider <larsxschneider@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Lars Schneider committed Oct 16, 2016 at 16:20 UTC ed54970324ec0be0f11e1c2af100ea8b1c01a05a
1 file changed +29 -29
t/t0021-conversion.sh
+29 -29
@@ -38,8 +38,8 @@ script='s/^\$Id: \([0-9a-f]*\) \$/\1/p'
38
39 test_expect_success check '
40
41 - cmp test.o test &&
42 - cmp test.o test.t &&
41 + test_cmp test.o test &&
42 + test_cmp test.o test.t &&
43
44 # ident should be stripped in the repository
45 git diff --raw --exit-code :test :test.i &&
@@ -47,10 +47,10 @@ test_expect_success check '
47 embedded=$(sed -ne "$script" test.i) &&
48 test "z$id" = "z$embedded" &&
49
50 - git cat-file blob :test.t > test.r &&
50 + git cat-file blob :test.t >test.r &&
51
52 - ./rot13.sh < test.o > test.t &&
53 - cmp test.r test.t
52 + ./rot13.sh <test.o >test.t &&
53 + test_cmp test.r test.t
54 '
55
56 # If an expanded ident ever gets into the repository, we want to make sure that
@@ -130,7 +130,7 @@ test_expect_success 'filter shell-escaped filenames' '
130
131 # delete the files and check them out again, using a smudge filter
132 # that will count the args and echo the command-line back to us
133 - git config filter.argc.smudge "sh ./argc.sh %f" &&
133 + test_config filter.argc.smudge "sh ./argc.sh %f" &&
134 rm "$normal" "$special" &&
135 git checkout -- "$normal" "$special" &&
136
@@ -141,7 +141,7 @@ test_expect_success 'filter shell-escaped filenames' '
141 test_cmp expect "$special" &&
142
143 # do the same thing, but with more args in the filter expression
144 - git config filter.argc.smudge "sh ./argc.sh %f --my-extra-arg" &&
144 + test_config filter.argc.smudge "sh ./argc.sh %f --my-extra-arg" &&
145 rm "$normal" "$special" &&
146 git checkout -- "$normal" "$special" &&
147
@@ -154,9 +154,9 @@ test_expect_success 'filter shell-escaped filenames' '
154 '
155
156 test_expect_success 'required filter should filter data' '
157 - git config filter.required.smudge ./rot13.sh &&
158 - git config filter.required.clean ./rot13.sh &&
159 - git config filter.required.required true &&
157 + test_config filter.required.smudge ./rot13.sh &&
158 + test_config filter.required.clean ./rot13.sh &&
159 + test_config filter.required.required true &&
160
161 echo "*.r filter=required" >.gitattributes &&
162
@@ -165,17 +165,17 @@ test_expect_success 'required filter should filter data' '
165
166 rm -f test.r &&
167 git checkout -- test.r &&
168 - cmp test.o test.r &&
168 + test_cmp test.o test.r &&
169
170 ./rot13.sh <test.o >expected &&
171 git cat-file blob :test.r >actual &&
172 - cmp expected actual
172 + test_cmp expected actual
173 '
174
175 test_expect_success 'required filter smudge failure' '
176 - git config filter.failsmudge.smudge false &&
177 - git config filter.failsmudge.clean cat &&
178 - git config filter.failsmudge.required true &&
176 + test_config filter.failsmudge.smudge false &&
177 + test_config filter.failsmudge.clean cat &&
178 + test_config filter.failsmudge.required true &&
179
180 echo "*.fs filter=failsmudge" >.gitattributes &&
181
@@ -186,9 +186,9 @@ test_expect_success 'required filter smudge failure' '
186 '
187
188 test_expect_success 'required filter clean failure' '
189 - git config filter.failclean.smudge cat &&
190 - git config filter.failclean.clean false &&
191 - git config filter.failclean.required true &&
189 + test_config filter.failclean.smudge cat &&
190 + test_config filter.failclean.clean false &&
191 + test_config filter.failclean.required true &&
192
193 echo "*.fc filter=failclean" >.gitattributes &&
194
@@ -197,8 +197,8 @@ test_expect_success 'required filter clean failure' '
197 '
198
199 test_expect_success 'filtering large input to small output should use little memory' '
200 - git config filter.devnull.clean "cat >/dev/null" &&
201 - git config filter.devnull.required true &&
200 + test_config filter.devnull.clean "cat >/dev/null" &&
201 + test_config filter.devnull.required true &&
202 for i in $(test_seq 1 30); do printf "%1048576d" 1; done >30MB &&
203 echo "30MB filter=devnull" >.gitattributes &&
204 GIT_MMAP_LIMIT=1m GIT_ALLOC_LIMIT=1m git add 30MB
@@ -207,7 +207,7 @@ test_expect_success 'filtering large input to small output should use little mem
207 test_expect_success 'filter that does not read is fine' '
208 test-genrandom foo $((128 * 1024 + 1)) >big &&
209 echo "big filter=epipe" >.gitattributes &&
210 - git config filter.epipe.clean "echo xyzzy" &&
210 + test_config filter.epipe.clean "echo xyzzy" &&
211 git add big &&
212 git cat-file blob :big >actual &&
213 echo xyzzy >expect &&
@@ -215,20 +215,20 @@ test_expect_success 'filter that does not read is fine' '
215 '
216
217 test_expect_success EXPENSIVE 'filter large file' '
218 - git config filter.largefile.smudge cat &&
219 - git config filter.largefile.clean cat &&
218 + test_config filter.largefile.smudge cat &&
219 + test_config filter.largefile.clean cat &&
220 for i in $(test_seq 1 2048); do printf "%1048576d" 1; done >2GB &&
221 echo "2GB filter=largefile" >.gitattributes &&
222 git add 2GB 2>err &&
223 - ! test -s err &&
223 + test_must_be_empty err &&
224 rm -f 2GB &&
225 git checkout -- 2GB 2>err &&
226 - ! test -s err
226 + test_must_be_empty err
227 '
228
229 test_expect_success "filter: clean empty file" '
230 - git config filter.in-repo-header.clean "echo cleaned && cat" &&
231 - git config filter.in-repo-header.smudge "sed 1d" &&
230 + test_config filter.in-repo-header.clean "echo cleaned && cat" &&
231 + test_config filter.in-repo-header.smudge "sed 1d" &&
232
233 echo "empty-in-worktree filter=in-repo-header" >>.gitattributes &&
234 >empty-in-worktree &&
@@ -240,8 +240,8 @@ test_expect_success "filter: clean empty file" '
240 '
241
242 test_expect_success "filter: smudge empty file" '
243 - git config filter.empty-in-repo.clean "cat >/dev/null" &&
244 - git config filter.empty-in-repo.smudge "echo smudged && cat" &&
243 + test_config filter.empty-in-repo.clean "cat >/dev/null" &&
244 + test_config filter.empty-in-repo.smudge "echo smudged && cat" &&
245
246 echo "empty-in-repo filter=empty-in-repo" >>.gitattributes &&
247 echo dead data walking >empty-in-repo &&