Skip to content

Commit ed54970

Browse files
larsxschneidergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Lars Schneider <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 255f04d commit ed54970

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

t/t0021-conversion.sh

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ script='s/^\$Id: \([0-9a-f]*\) \$/\1/p'
3838

3939
test_expect_success check '
4040
41-
cmp test.o test &&
42-
cmp test.o test.t &&
41+
test_cmp test.o test &&
42+
test_cmp test.o test.t &&
4343
4444
# ident should be stripped in the repository
4545
git diff --raw --exit-code :test :test.i &&
4646
id=$(git rev-parse --verify :test) &&
4747
embedded=$(sed -ne "$script" test.i) &&
4848
test "z$id" = "z$embedded" &&
4949
50-
git cat-file blob :test.t > test.r &&
50+
git cat-file blob :test.t >test.r &&
5151
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
5454
'
5555

5656
# 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' '
130130
131131
# delete the files and check them out again, using a smudge filter
132132
# 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" &&
134134
rm "$normal" "$special" &&
135135
git checkout -- "$normal" "$special" &&
136136
@@ -141,7 +141,7 @@ test_expect_success 'filter shell-escaped filenames' '
141141
test_cmp expect "$special" &&
142142
143143
# 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" &&
145145
rm "$normal" "$special" &&
146146
git checkout -- "$normal" "$special" &&
147147
@@ -154,9 +154,9 @@ test_expect_success 'filter shell-escaped filenames' '
154154
'
155155

156156
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 &&
160160
161161
echo "*.r filter=required" >.gitattributes &&
162162
@@ -165,17 +165,17 @@ test_expect_success 'required filter should filter data' '
165165
166166
rm -f test.r &&
167167
git checkout -- test.r &&
168-
cmp test.o test.r &&
168+
test_cmp test.o test.r &&
169169
170170
./rot13.sh <test.o >expected &&
171171
git cat-file blob :test.r >actual &&
172-
cmp expected actual
172+
test_cmp expected actual
173173
'
174174

175175
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 &&
179179
180180
echo "*.fs filter=failsmudge" >.gitattributes &&
181181
@@ -186,9 +186,9 @@ test_expect_success 'required filter smudge failure' '
186186
'
187187

188188
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 &&
192192
193193
echo "*.fc filter=failclean" >.gitattributes &&
194194
@@ -197,8 +197,8 @@ test_expect_success 'required filter clean failure' '
197197
'
198198

199199
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 &&
202202
for i in $(test_seq 1 30); do printf "%1048576d" 1; done >30MB &&
203203
echo "30MB filter=devnull" >.gitattributes &&
204204
GIT_MMAP_LIMIT=1m GIT_ALLOC_LIMIT=1m git add 30MB
@@ -207,28 +207,28 @@ test_expect_success 'filtering large input to small output should use little mem
207207
test_expect_success 'filter that does not read is fine' '
208208
test-genrandom foo $((128 * 1024 + 1)) >big &&
209209
echo "big filter=epipe" >.gitattributes &&
210-
git config filter.epipe.clean "echo xyzzy" &&
210+
test_config filter.epipe.clean "echo xyzzy" &&
211211
git add big &&
212212
git cat-file blob :big >actual &&
213213
echo xyzzy >expect &&
214214
test_cmp expect actual
215215
'
216216

217217
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 &&
220220
for i in $(test_seq 1 2048); do printf "%1048576d" 1; done >2GB &&
221221
echo "2GB filter=largefile" >.gitattributes &&
222222
git add 2GB 2>err &&
223-
! test -s err &&
223+
test_must_be_empty err &&
224224
rm -f 2GB &&
225225
git checkout -- 2GB 2>err &&
226-
! test -s err
226+
test_must_be_empty err
227227
'
228228

229229
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" &&
232232
233233
echo "empty-in-worktree filter=in-repo-header" >>.gitattributes &&
234234
>empty-in-worktree &&
@@ -240,8 +240,8 @@ test_expect_success "filter: clean empty file" '
240240
'
241241

242242
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" &&
245245
246246
echo "empty-in-repo filter=empty-in-repo" >>.gitattributes &&
247247
echo dead data walking >empty-in-repo &&

0 commit comments

Comments
 (0)