Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit b619519

Browse files
committed
Merge branch 'sl/test-wc-l-line-count'
By Stefano Lattarini * sl/test-wc-l-line-count: tests: modernise style: more uses of test_line_count
2 parents 2347982 + 3fb0459 commit b619519

19 files changed

+65
-74
lines changed

t/t1410-reflog.sh

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ test_expect_success setup '
100100
101101
check_fsck &&
102102
103-
loglen=$(wc -l <.git/logs/refs/heads/master) &&
104-
test $loglen = 4
103+
test_line_count = 4 .git/logs/refs/heads/master
105104
'
106105

107106
test_expect_success rewind '
@@ -117,8 +116,7 @@ test_expect_success rewind '
117116
118117
check_have A B C D E F G H I J K L &&
119118
120-
loglen=$(wc -l <.git/logs/refs/heads/master) &&
121-
test $loglen = 5
119+
test_line_count = 5 .git/logs/refs/heads/master
122120
'
123121

124122
test_expect_success 'corrupt and check' '
@@ -136,8 +134,7 @@ test_expect_success 'reflog expire --dry-run should not touch reflog' '
136134
--stale-fix \
137135
--all &&
138136
139-
loglen=$(wc -l <.git/logs/refs/heads/master) &&
140-
test $loglen = 5 &&
137+
test_line_count = 5 .git/logs/refs/heads/master &&
141138
142139
check_fsck "missing blob $F"
143140
'
@@ -150,8 +147,7 @@ test_expect_success 'reflog expire' '
150147
--stale-fix \
151148
--all &&
152149
153-
loglen=$(wc -l <.git/logs/refs/heads/master) &&
154-
test $loglen = 2 &&
150+
test_line_count = 2 .git/logs/refs/heads/master &&
155151
156152
check_fsck "dangling commit $K"
157153
'
@@ -217,9 +213,7 @@ test_expect_success 'delete' '
217213
test_expect_success 'rewind2' '
218214
219215
test_tick && git reset --hard HEAD~2 &&
220-
loglen=$(wc -l <.git/logs/refs/heads/master) &&
221-
test $loglen = 4
222-
216+
test_line_count = 4 .git/logs/refs/heads/master
223217
'
224218

225219
test_expect_success '--expire=never' '
@@ -228,27 +222,23 @@ test_expect_success '--expire=never' '
228222
--expire=never \
229223
--expire-unreachable=never \
230224
--all &&
231-
loglen=$(wc -l <.git/logs/refs/heads/master) &&
232-
test $loglen = 4
233-
225+
test_line_count = 4 .git/logs/refs/heads/master
234226
'
235227

236228
test_expect_success 'gc.reflogexpire=never' '
237229
238230
git config gc.reflogexpire never &&
239231
git config gc.reflogexpireunreachable never &&
240232
git reflog expire --verbose --all &&
241-
loglen=$(wc -l <.git/logs/refs/heads/master) &&
242-
test $loglen = 4
233+
test_line_count = 4 .git/logs/refs/heads/master
243234
'
244235

245236
test_expect_success 'gc.reflogexpire=false' '
246237
247238
git config gc.reflogexpire false &&
248239
git config gc.reflogexpireunreachable false &&
249240
git reflog expire --verbose --all &&
250-
loglen=$(wc -l <.git/logs/refs/heads/master) &&
251-
test $loglen = 4 &&
241+
test_line_count = 4 .git/logs/refs/heads/master &&
252242
253243
git config --unset gc.reflogexpire &&
254244
git config --unset gc.reflogexpireunreachable

t/t2004-checkout-cache-temp.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ test_expect_success \
4040
rm -f path* .merge_* out .git/index &&
4141
git read-tree $t1 &&
4242
git checkout-index --temp -- path1 >out &&
43-
test $(wc -l <out) = 1 &&
43+
test_line_count = 1 out &&
4444
test $(cut "-d " -f2 out) = path1 &&
4545
p=$(cut "-d " -f1 out) &&
4646
test -f $p &&
@@ -51,7 +51,7 @@ test_expect_success \
5151
rm -f path* .merge_* out .git/index &&
5252
git read-tree $t1 &&
5353
git checkout-index -a --temp >out &&
54-
test $(wc -l <out) = 5 &&
54+
test_line_count = 5 out &&
5555
for f in path0 path1 path3 path4 asubdir/path5
5656
do
5757
test $(grep $f out | cut "-d " -f2) = $f &&
@@ -69,7 +69,7 @@ test_expect_success \
6969
'checkout one stage 2 to temporary file' '
7070
rm -f path* .merge_* out &&
7171
git checkout-index --stage=2 --temp -- path1 >out &&
72-
test $(wc -l <out) = 1 &&
72+
test_line_count = 1 out &&
7373
test $(cut "-d " -f2 out) = path1 &&
7474
p=$(cut "-d " -f1 out) &&
7575
test -f $p &&
@@ -79,7 +79,7 @@ test_expect_success \
7979
'checkout all stage 2 to temporary files' '
8080
rm -f path* .merge_* out &&
8181
git checkout-index --all --stage=2 --temp >out &&
82-
test $(wc -l <out) = 3 &&
82+
test_line_count = 3 out &&
8383
for f in path1 path2 path4
8484
do
8585
test $(grep $f out | cut "-d " -f2) = $f &&
@@ -92,13 +92,13 @@ test_expect_success \
9292
'checkout all stages/one file to nothing' '
9393
rm -f path* .merge_* out &&
9494
git checkout-index --stage=all --temp -- path0 >out &&
95-
test $(wc -l <out) = 0'
95+
test_line_count = 0 out'
9696

9797
test_expect_success \
9898
'checkout all stages/one file to temporary files' '
9999
rm -f path* .merge_* out &&
100100
git checkout-index --stage=all --temp -- path1 >out &&
101-
test $(wc -l <out) = 1 &&
101+
test_line_count = 1 out &&
102102
test $(cut "-d " -f2 out) = path1 &&
103103
cut "-d " -f1 out | (read s1 s2 s3 &&
104104
test -f $s1 &&
@@ -112,7 +112,7 @@ test_expect_success \
112112
'checkout some stages/one file to temporary files' '
113113
rm -f path* .merge_* out &&
114114
git checkout-index --stage=all --temp -- path2 >out &&
115-
test $(wc -l <out) = 1 &&
115+
test_line_count = 1 out &&
116116
test $(cut "-d " -f2 out) = path2 &&
117117
cut "-d " -f1 out | (read s1 s2 s3 &&
118118
test $s1 = . &&
@@ -125,7 +125,7 @@ test_expect_success \
125125
'checkout all stages/all files to temporary files' '
126126
rm -f path* .merge_* out &&
127127
git checkout-index -a --stage=all --temp >out &&
128-
test $(wc -l <out) = 5'
128+
test_line_count = 5 out'
129129

130130
test_expect_success \
131131
'-- path0: no entry' '
@@ -185,7 +185,7 @@ test_expect_success \
185185
'checkout --temp within subdir' '
186186
(cd asubdir &&
187187
git checkout-index -a --stage=all >out &&
188-
test $(wc -l <out) = 1 &&
188+
test_line_count = 1 out &&
189189
test $(grep path5 out | cut "-d " -f2) = path5 &&
190190
grep path5 out | cut "-d " -f1 | (read s1 s2 s3 &&
191191
test -f ../$s1 &&
@@ -203,7 +203,7 @@ t4=$(git write-tree) &&
203203
rm -f .git/index &&
204204
git read-tree $t4 &&
205205
git checkout-index --temp -a >out &&
206-
test $(wc -l <out) = 1 &&
206+
test_line_count = 1 out &&
207207
test $(cut "-d " -f2 out) = a &&
208208
p=$(cut "-d " -f1 out) &&
209209
test -f $p &&

t/t2030-unresolve-info.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ test_expect_success 'unmerge with plumbing' '
113113
prime_resolve_undo &&
114114
git update-index --unresolve fi/le &&
115115
git ls-files -u >actual &&
116-
test $(wc -l <actual) = 3
116+
test_line_count = 3 actual
117117
'
118118

119119
test_expect_success 'rerere and rerere forget' '

t/t3415-rebase-autosquash.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test_auto_fixup () {
3333
test_tick &&
3434
git rebase $2 -i HEAD^^^ &&
3535
git log --oneline >actual &&
36-
test 3 = $(wc -l <actual) &&
36+
test_line_count = 3 actual &&
3737
git diff --exit-code $1 &&
3838
test 1 = "$(git cat-file blob HEAD^:file1)" &&
3939
test 1 = $(git cat-file commit HEAD^ | grep first | wc -l)
@@ -62,7 +62,7 @@ test_auto_squash () {
6262
test_tick &&
6363
git rebase $2 -i HEAD^^^ &&
6464
git log --oneline >actual &&
65-
test 3 = $(wc -l <actual) &&
65+
test_line_count = 3 actual &&
6666
git diff --exit-code $1 &&
6767
test 1 = "$(git cat-file blob HEAD^:file1)" &&
6868
test 2 = $(git cat-file commit HEAD^ | grep first | wc -l)
@@ -90,7 +90,7 @@ test_expect_success 'misspelled auto squash' '
9090
test_tick &&
9191
git rebase --autosquash -i HEAD^^^ &&
9292
git log --oneline >actual &&
93-
test 4 = $(wc -l <actual) &&
93+
test_line_count = 4 actual &&
9494
git diff --exit-code final-missquash &&
9595
test 0 = $(git rev-list final-missquash...HEAD | wc -l)
9696
'
@@ -109,7 +109,7 @@ test_expect_success 'auto squash that matches 2 commits' '
109109
test_tick &&
110110
git rebase --autosquash -i HEAD~4 &&
111111
git log --oneline >actual &&
112-
test 4 = $(wc -l <actual) &&
112+
test_line_count = 4 actual &&
113113
git diff --exit-code final-multisquash &&
114114
test 1 = "$(git cat-file blob HEAD^^:file1)" &&
115115
test 2 = $(git cat-file commit HEAD^^ | grep first | wc -l) &&
@@ -130,7 +130,7 @@ test_expect_success 'auto squash that matches a commit after the squash' '
130130
test_tick &&
131131
git rebase --autosquash -i HEAD~4 &&
132132
git log --oneline >actual &&
133-
test 5 = $(wc -l <actual) &&
133+
test_line_count = 5 actual &&
134134
git diff --exit-code final-presquash &&
135135
test 0 = "$(git cat-file blob HEAD^^:file1)" &&
136136
test 1 = "$(git cat-file blob HEAD^:file1)" &&
@@ -147,7 +147,7 @@ test_expect_success 'auto squash that matches a sha1' '
147147
test_tick &&
148148
git rebase --autosquash -i HEAD^^^ &&
149149
git log --oneline >actual &&
150-
test 3 = $(wc -l <actual) &&
150+
test_line_count = 3 actual &&
151151
git diff --exit-code final-shasquash &&
152152
test 1 = "$(git cat-file blob HEAD^:file1)" &&
153153
test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
@@ -163,7 +163,7 @@ test_expect_success 'auto squash that matches longer sha1' '
163163
test_tick &&
164164
git rebase --autosquash -i HEAD^^^ &&
165165
git log --oneline >actual &&
166-
test 3 = $(wc -l <actual) &&
166+
test_line_count = 3 actual &&
167167
git diff --exit-code final-longshasquash &&
168168
test 1 = "$(git cat-file blob HEAD^:file1)" &&
169169
test 1 = $(git cat-file commit HEAD^ | grep squash | wc -l)
@@ -179,7 +179,7 @@ test_auto_commit_flags () {
179179
test_tick &&
180180
git rebase --autosquash -i HEAD^^^ &&
181181
git log --oneline >actual &&
182-
test 3 = $(wc -l <actual) &&
182+
test_line_count = 3 actual &&
183183
git diff --exit-code final-commit-$1 &&
184184
test 1 = "$(git cat-file blob HEAD^:file1)" &&
185185
test $2 = $(git cat-file commit HEAD^ | grep first | wc -l)

t/t3900-i18n-commit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ test_commit_autosquash_flags () {
160160
git config --unset-all i18n.commitencoding &&
161161
git rebase --autosquash -i HEAD^^^ &&
162162
git log --oneline >actual &&
163-
test 3 = $(wc -l <actual)
163+
test_line_count = 3 actual
164164
'
165165
}
166166

t/t4035-diff-quiet.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,65 +15,65 @@ test_expect_success 'setup' '
1515

1616
test_expect_success 'git diff-tree HEAD^ HEAD' '
1717
git diff-tree --quiet HEAD^ HEAD >cnt
18-
test $? = 1 && test $(wc -l <cnt) = 0
18+
test $? = 1 && test_line_count = 0 cnt
1919
'
2020
test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
2121
git diff-tree --quiet HEAD^ HEAD -- a >cnt
22-
test $? = 0 && test $(wc -l <cnt) = 0
22+
test $? = 0 && test_line_count = 0 cnt
2323
'
2424
test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
2525
git diff-tree --quiet HEAD^ HEAD -- b >cnt
26-
test $? = 1 && test $(wc -l <cnt) = 0
26+
test $? = 1 && test_line_count = 0 cnt
2727
'
2828
# this diff outputs one line: sha1 of the given head
2929
test_expect_success 'echo HEAD | git diff-tree --stdin' '
3030
echo $(git rev-parse HEAD) | git diff-tree --quiet --stdin >cnt
31-
test $? = 1 && test $(wc -l <cnt) = 1
31+
test $? = 1 && test_line_count = 1 cnt
3232
'
3333
test_expect_success 'git diff-tree HEAD HEAD' '
3434
git diff-tree --quiet HEAD HEAD >cnt
35-
test $? = 0 && test $(wc -l <cnt) = 0
35+
test $? = 0 && test_line_count = 0 cnt
3636
'
3737
test_expect_success 'git diff-files' '
3838
git diff-files --quiet >cnt
39-
test $? = 0 && test $(wc -l <cnt) = 0
39+
test $? = 0 && test_line_count = 0 cnt
4040
'
4141
test_expect_success 'git diff-index --cached HEAD' '
4242
git diff-index --quiet --cached HEAD >cnt
43-
test $? = 0 && test $(wc -l <cnt) = 0
43+
test $? = 0 && test_line_count = 0 cnt
4444
'
4545
test_expect_success 'git diff-index --cached HEAD^' '
4646
git diff-index --quiet --cached HEAD^ >cnt
47-
test $? = 1 && test $(wc -l <cnt) = 0
47+
test $? = 1 && test_line_count = 0 cnt
4848
'
4949
test_expect_success 'git diff-index --cached HEAD^' '
5050
echo text >>b &&
5151
echo 3 >c &&
5252
git add . && {
5353
git diff-index --quiet --cached HEAD^ >cnt
54-
test $? = 1 && test $(wc -l <cnt) = 0
54+
test $? = 1 && test_line_count = 0 cnt
5555
}
5656
'
5757
test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
5858
git commit -m "text in b" && {
5959
git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt
60-
test $? = 1 && test $(wc -l <cnt) = 0
60+
test $? = 1 && test_line_count = 0 cnt
6161
}
6262
'
6363
test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
6464
git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt
65-
test $? = 0 && test $(wc -l <cnt) = 0
65+
test $? = 0 && test_line_count = 0 cnt
6666
'
6767
test_expect_success 'git diff-files' '
6868
echo 3 >>c && {
6969
git diff-files --quiet >cnt
70-
test $? = 1 && test $(wc -l <cnt) = 0
70+
test $? = 1 && test_line_count = 0 cnt
7171
}
7272
'
7373
test_expect_success 'git diff-index --cached HEAD' '
7474
git update-index c && {
7575
git diff-index --quiet --cached HEAD >cnt
76-
test $? = 1 && test $(wc -l <cnt) = 0
76+
test $? = 1 && test_line_count = 0 cnt
7777
}
7878
'
7979

t/t5100-mailinfo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ test_expect_success 'respect NULs' '
6565
git mailsplit -d3 -o. "$TEST_DIRECTORY"/t5100/nul-plain &&
6666
test_cmp "$TEST_DIRECTORY"/t5100/nul-plain 001 &&
6767
(cat 001 | git mailinfo msg patch) &&
68-
test 4 = $(wc -l < patch)
68+
test_line_count = 4 patch
6969
7070
'
7171

t/t5700-clone-reference.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ test_expect_success 'cloning with reference (-l -s)' \
3434
cd "$base_dir"
3535

3636
test_expect_success 'existence of info/alternates' \
37-
'test `wc -l <C/.git/objects/info/alternates` = 2'
37+
'test_line_count = 2 C/.git/objects/info/alternates'
3838

3939
cd "$base_dir"
4040

@@ -63,7 +63,7 @@ test_expect_success 'fetched no objects' \
6363
cd "$base_dir"
6464

6565
test_expect_success 'existence of info/alternates' \
66-
'test `wc -l <D/.git/objects/info/alternates` = 1'
66+
'test_line_count = 1 D/.git/objects/info/alternates'
6767

6868
cd "$base_dir"
6969

t/t5710-info-alternate.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ reachable_via() {
1818

1919
test_valid_repo() {
2020
git fsck --full > fsck.log &&
21-
test `wc -l < fsck.log` = 0
21+
test_line_count = 0 fsck.log
2222
}
2323

2424
base_dir=`pwd`

0 commit comments

Comments
 (0)