Skip to content

Commit c90f06e

Browse files
committed
Merge branch 'mk/test-seq'
Add a compatibility/utility function to the test framework. * mk/test-seq: tests: Introduce test_seq
2 parents d5ce335 + d17cf5f commit c90f06e

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

t/perf/perf-lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ test_perf () {
163163
else
164164
echo "perf $test_count - $1:"
165165
fi
166-
for i in $(seq 1 $GIT_PERF_REPEAT_COUNT); do
166+
for i in $(test_seq 1 $GIT_PERF_REPEAT_COUNT); do
167167
say >&3 "running: $2"
168168
if test_run_perf_ "$2"
169169
then

t/t5551-http-fetch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ test -n "$GIT_TEST_LONG" && test_set_prereq EXPENSIVE
114114
test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
115115
(
116116
cd "$HTTPD_DOCUMENT_ROOT_PATH/repo.git" &&
117-
for i in `seq 50000`
117+
for i in `test_seq 50000`
118118
do
119119
echo "commit refs/heads/too-many-refs"
120120
echo "mark :$i"

t/test-lib-functions.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,27 @@ test_cmp() {
572572
$GIT_TEST_CMP "$@"
573573
}
574574

575+
# Print a sequence of numbers or letters in increasing order. This is
576+
# similar to GNU seq(1), but the latter might not be available
577+
# everywhere (and does not do letters). It may be used like:
578+
#
579+
# for i in `test_seq 100`; do
580+
# for j in `test_seq 10 20`; do
581+
# for k in `test_seq a z`; do
582+
# echo $i-$j-$k
583+
# done
584+
# done
585+
# done
586+
587+
test_seq () {
588+
case $# in
589+
1) set 1 "$@" ;;
590+
2) ;;
591+
*) error "bug in the test script: not 1 or 2 parameters to test_seq" ;;
592+
esac
593+
"$PERL_PATH" -le 'print for $ARGV[0]..$ARGV[1]' -- "$@"
594+
}
595+
575596
# This function can be used to schedule some commands to be run
576597
# unconditionally at the end of the test to restore sanity:
577598
#

0 commit comments

Comments
 (0)