summaryrefslogtreecommitdiff
path: root/t/test-lib-functions.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-08-22 18:51:37 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-08-22 18:51:38 (GMT)
commitc90f06efd84ef0ace0c92509a8bfa1bb1d8b05a8 (patch)
treed780f6142b8e57a1f023757da338dcd663b69aaf /t/test-lib-functions.sh
parentd5ce335270c3ec4f6ab0e7c021aa92e1d3469139 (diff)
parentd17cf5f3a32f07bf8a6b8fb014abfa8e87fd7075 (diff)
downloadgit-c90f06efd84ef0ace0c92509a8bfa1bb1d8b05a8.zip
git-c90f06efd84ef0ace0c92509a8bfa1bb1d8b05a8.tar.gz
git-c90f06efd84ef0ace0c92509a8bfa1bb1d8b05a8.tar.bz2
Merge branch 'mk/test-seq'
Add a compatibility/utility function to the test framework. * mk/test-seq: tests: Introduce test_seq
Diffstat (limited to 't/test-lib-functions.sh')
-rw-r--r--t/test-lib-functions.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index 04b1a43..9bc57d2 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -572,6 +572,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:
#