зеркало из https://github.com/microsoft/git.git
tests: Introduce test_seq
Jeff King wrote:
The seq command is GNU-ism, and is missing at least in older BSD
releases and their derivatives, not to mention antique
commercial Unixes.
We already purged it in b3431bc
(Don't use seq in tests, not
everyone has it, 2007-05-02), but a few new instances have crept
in. They went unnoticed because they are in scripts that are not
run by default.
Replace them with test_seq that is implemented with a Perl snippet
(proposed by Jeff). This is better than inlining this snippet
everywhere it's needed because it's easier to read and it's easier
to change the implementation (e.g. to C) if we ever decide to remove
Perl from the test suite.
Note that test_seq is not a complete replacement for seq(1). It
just has what we need now, in addition that it makes it possible for
us to do something like "test_seq a m" if we wanted to in the
future.
There are also many places that do `for i in 1 2 3 ...` but I'm not sure
if it's worth converting them to test_seq. That would introduce running
more processes of Perl.
Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Acked-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Родитель
0e4c8822e9
Коммит
d17cf5f3a3
|
@ -163,7 +163,7 @@ test_perf () {
|
|||
else
|
||||
echo "perf $test_count - $1:"
|
||||
fi
|
||||
for i in $(seq 1 $GIT_PERF_REPEAT_COUNT); do
|
||||
for i in $(test_seq 1 $GIT_PERF_REPEAT_COUNT); do
|
||||
say >&3 "running: $2"
|
||||
if test_run_perf_ "$2"
|
||||
then
|
||||
|
|
|
@ -114,7 +114,7 @@ test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
|
|||
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
|
||||
(
|
||||
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
|
||||
for i in `seq 50000`
|
||||
for i in `test_seq 50000`
|
||||
do
|
||||
echo "commit refs/heads/too-many-refs"
|
||||
echo "mark :$i"
|
||||
|
|
|
@ -530,6 +530,27 @@ test_cmp() {
|
|||
$GIT_TEST_CMP "$@"
|
||||
}
|
||||
|
||||
# Print a sequence of numbers or letters in increasing order. This is
|
||||
# similar to GNU seq(1), but the latter might not be available
|
||||
# everywhere (and does not do letters). It may be used like:
|
||||
#
|
||||
# for i in `test_seq 100`; do
|
||||
# for j in `test_seq 10 20`; do
|
||||
# for k in `test_seq a z`; do
|
||||
# echo $i-$j-$k
|
||||
# done
|
||||
# done
|
||||
# done
|
||||
|
||||
test_seq () {
|
||||
case $# in
|
||||
1) set 1 "$@" ;;
|
||||
2) ;;
|
||||
*) error "bug in the test script: not 1 or 2 parameters to test_seq" ;;
|
||||
esac
|
||||
"$PERL_PATH" -le 'print for $ARGV[0]..$ARGV[1]' -- "$@"
|
||||
}
|
||||
|
||||
# This function can be used to schedule some commands to be run
|
||||
# unconditionally at the end of the test to restore sanity:
|
||||
#
|
||||
|
|
Загрузка…
Ссылка в новой задаче