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 d17cf5f3a3 ("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 <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ævar Arnfjörð Bjarmason committed Aug 24, 2018 at 15:20 UTC b2fa7a2372f42af404a942a4691a5341af8868e9
3 files changed +9 -8
t/check-non-portable-shell.pl
+1
@@ -42,6 +42,7 @@ while (<>) {
42 /\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)';
43 /\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)';
44 /\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)';
46 /\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
47 /^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
48 err '"FOO=bar shell_func" assignment extends beyond "shell_func"';
t/t5552-skipping-fetch-negotiator.sh
+6 -6
@@ -46,7 +46,7 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc
46 test_commit -C server to_fetch &&
47
48 git init client &&
49 - for i in $(seq 7)
49 + for i in $(test_seq 7)
50 do
51 test_commit -C client c$i
52 done &&
@@ -89,7 +89,7 @@ test_expect_success 'when two skips collide, favor the larger one' '
89 test_commit -C server to_fetch &&
90
91 git init client &&
92 - for i in $(seq 11)
92 + for i in $(test_seq 11)
93 do
94 test_commit -C client c$i
95 done &&
@@ -168,14 +168,14 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC
168 test_commit -C server to_fetch &&
169
170 git init client &&
171 - for i in $(seq 8)
171 + for i in $(test_seq 8)
172 do
173 git -C client checkout --orphan b$i &&
174 test_commit -C client b$i.c0
175 done &&
176 - for j in $(seq 19)
176 + for j in $(test_seq 19)
177 do
178 - for i in $(seq 8)
178 + for i in $(test_seq 8)
179 do
180 git -C client checkout b$i &&
181 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
205
206 # fetch-pack should thus not send any more commits in the b1 branch, but
207 # 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)
209 do
210 have_not_sent b1.c$i
211 done &&
t/t5703-upload-pack-ref-in-want.sh
+2 -2
@@ -176,7 +176,7 @@ test_expect_success 'setup repos for change-while-negotiating test' '
176 git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" &&
177 cd "$LOCAL_PRISTINE" &&
178 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 &&
180
181 # Add novel commits to upstream
182 git checkout master &&
@@ -289,7 +289,7 @@ test_expect_success 'setup repos for fetching with ref-in-want tests' '
289 git clone "file://$REPO" "$LOCAL_PRISTINE" &&
290 cd "$LOCAL_PRISTINE" &&
291 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 &&
293
294 # Add novel commits to upstream
295 git checkout master &&