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>
maint
Ævar Arnfjörð Bjarmason 2018-08-24 15:20:12 +00:00 committed by Junio C Hamano
parent 2a59a6ef20
commit b2fa7a2372
3 changed files with 9 additions and 8 deletions

View File

@ -42,6 +42,7 @@ while (<>) {
/\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)'; /\btest\s+[^=]*==/ and err '"test a == b" is not portable (use =)';
/\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)'; /\bwc -l.*"\s*=/ and err '`"$(wc -l)"` is not portable (use test_line_count)';
/\bhead\s+-c\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)'; /\bhead\s+-c\b/ and err 'head -c is not portable (use test_copy_bytes BYTES <file >out)';
/(?:\$\(seq|^\s*seq\b)/ and err 'seq is not portable (use test_seq)';
/\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)'; /\bexport\s+[A-Za-z0-9_]*=/ and err '"export FOO=bar" is not portable (use FOO=bar && export FOO)';
/^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and /^\s*([A-Z0-9_]+=(\w+|(["']).*?\3)\s+)+(\w+)/ and exists($func{$4}) and
err '"FOO=bar shell_func" assignment extends beyond "shell_func"'; err '"FOO=bar shell_func" assignment extends beyond "shell_func"';

View File

@ -46,7 +46,7 @@ test_expect_success 'commits with no parents are sent regardless of skip distanc
test_commit -C server to_fetch && test_commit -C server to_fetch &&


git init client && git init client &&
for i in $(seq 7) for i in $(test_seq 7)
do do
test_commit -C client c$i test_commit -C client c$i
done && done &&
@ -89,7 +89,7 @@ test_expect_success 'when two skips collide, favor the larger one' '
test_commit -C server to_fetch && test_commit -C server to_fetch &&


git init client && git init client &&
for i in $(seq 11) for i in $(test_seq 11)
do do
test_commit -C client c$i test_commit -C client c$i
done && done &&
@ -168,14 +168,14 @@ test_expect_success 'do not send "have" with ancestors of commits that server AC
test_commit -C server to_fetch && test_commit -C server to_fetch &&


git init client && git init client &&
for i in $(seq 8) for i in $(test_seq 8)
do do
git -C client checkout --orphan b$i && git -C client checkout --orphan b$i &&
test_commit -C client b$i.c0 test_commit -C client b$i.c0
done && done &&
for j in $(seq 19) for j in $(test_seq 19)
do do
for i in $(seq 8) for i in $(test_seq 8)
do do
git -C client checkout b$i && git -C client checkout b$i &&
test_commit -C client b$i.c$j 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


# fetch-pack should thus not send any more commits in the b1 branch, but # fetch-pack should thus not send any more commits in the b1 branch, but
# should still send the others (in this test, just check b2). # should still send the others (in this test, just check b2).
for i in $(seq 0 8) for i in $(test_seq 0 8)
do do
have_not_sent b1.c$i have_not_sent b1.c$i
done && done &&

View File

@ -176,7 +176,7 @@ test_expect_success 'setup repos for change-while-negotiating test' '
git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" && git clone "http://127.0.0.1:$LIB_HTTPD_PORT/smart/repo" "$LOCAL_PRISTINE" &&
cd "$LOCAL_PRISTINE" && cd "$LOCAL_PRISTINE" &&
git checkout -b side && git checkout -b side &&
for i in $(seq 1 33); do test_commit s$i; done && for i in $(test_seq 1 33); do test_commit s$i; done &&


# Add novel commits to upstream # Add novel commits to upstream
git checkout master && git checkout master &&
@ -289,7 +289,7 @@ test_expect_success 'setup repos for fetching with ref-in-want tests' '
git clone "file://$REPO" "$LOCAL_PRISTINE" && git clone "file://$REPO" "$LOCAL_PRISTINE" &&
cd "$LOCAL_PRISTINE" && cd "$LOCAL_PRISTINE" &&
git checkout -b side && git checkout -b side &&
for i in $(seq 1 33); do test_commit s$i; done && for i in $(test_seq 1 33); do test_commit s$i; done &&


# Add novel commits to upstream # Add novel commits to upstream
git checkout master && git checkout master &&