Skip to content

Commit b2fa7a2

Browse files
avargitster
authored andcommitted
tests: fix and add lint for non-portable seq
The seq command is not in POSIX, and doesn't exist on e.g. OpenBSD. We've had the test_seq wrapper since d17cf5f ("tests: Introduce test_seq", 2012-08-04), but use of it keeps coming back, e.g. in the recently added "fetch negotiator" tests being added here. So let's also add a check to "make test-lint". The regex is aiming to capture the likes of $(seq ..) and "seq" as a stand-alone command, without capturing some existing cases where we e.g. have files called "seq", as \bseq\b would do. Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2a59a6e commit b2fa7a2

File tree

3 files changed

+9
-8
lines changed

3 files changed

+9
-8
lines changed

t/check-non-portable-shell.pl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ sub err {
4242
/\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)';
4343
/\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)';
4444
/\bhead\s+-c\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)';
45+
/(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)';
4546
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
4647
/^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
4748
err '"FOO=bar shell_func" assignment extends beyond "shell_func"';

t/t5552-skipping-fetch-negotiator.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc
4646
test_commit -C server to_fetch &&
4747
4848
git init client &&
49-
for i in $(seq 7)
49+
for i in $(test_seq 7)
5050
do
5151
test_commit -C client c$i
5252
done &&
@@ -89,7 +89,7 @@ test_expect_success 'when two skips collide, favor the larger one' '
8989
test_commit -C server to_fetch &&
9090
9191
git init client &&
92-
for i in $(seq 11)
92+
for i in $(test_seq 11)
9393
do
9494
test_commit -C client c$i
9595
done &&
@@ -168,14 +168,14 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC
168168
test_commit -C server to_fetch &&
169169
170170
git init client &&
171-
for i in $(seq 8)
171+
for i in $(test_seq 8)
172172
do
173173
git -C client checkout --orphan b$i &&
174174
test_commit -C client b$i.c0
175175
done &&
176-
for j in $(seq 19)
176+
for j in $(test_seq 19)
177177
do
178-
for i in $(seq 8)
178+
for i in $(test_seq 8)
179179
do
180180
git -C client checkout b$i &&
181181
test_commit -C client b$i.c$j
@@ -205,7 +205,7 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC
205205
206206
# fetch-pack should thus not send any more commits in the b1 branch, but
207207
# should still send the others (in this test, just check b2).
208-
for i in $(seq 0 8)
208+
for i in $(test_seq 0 8)
209209
do
210210
have_not_sent b1.c$i
211211
done &&

t/t5703-upload-pack-ref-in-want.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ test_expect_success 'setup repos for change-while-negotiating test' '
176176
git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" &&
177177
cd "$LOCAL_PRISTINE" &&
178178
git checkout -b side &&
179-
for i in $(seq 1 33); do test_commit s$i; done &&
179+
for i in $(test_seq 1 33); do test_commit s$i; done &&
180180
181181
# Add novel commits to upstream
182182
git checkout master &&
@@ -289,7 +289,7 @@ test_expect_success 'setup repos for fetching with ref-in-want tests' '
289289
git clone "file://$REPO" "$LOCAL_PRISTINE" &&
290290
cd "$LOCAL_PRISTINE" &&
291291
git checkout -b side &&
292-
for i in $(seq 1 33); do test_commit s$i; done &&
292+
for i in $(test_seq 1 33); do test_commit s$i; done &&
293293
294294
# Add novel commits to upstream
295295
git checkout master &&

0 commit comments

Comments
 (0)