Skip to content

Commit

Permalink
Merge pull request #1329 from ipfs/implement-test-seq
Browse files Browse the repository at this point in the history
ipfs-test-lib: implement test_seq()
  • Loading branch information
jbenet committed Jun 3, 2015
2 parents 238fac5 + 59cac0a commit 0397bdf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions test/ipfs-test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,16 @@ test_sort_cmp() {
sort "$2" >"$2_sorted" &&
test_cmp "$1_sorted" "$2_sorted"
}

# Depending on GNU seq availability is not nice.
# Git also has test_seq but it uses Perl.
test_seq() {
test "$1" -le "$2" || return
i="$1"
j="$2"
while test "$i" -le "$j"
do
echo "$i"
i=$(expr "$i" + 1)
done
}
4 changes: 2 additions & 2 deletions test/sharness/lib/test-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fi
. ../../ipfs-test-lib.sh

test_cmp_repeat_10_sec() {
for i in `seq 1 100`
for i in $(test_seq 1 100)
do
test_cmp "$1" "$2" >/dev/null && return
sleep 0.1
Expand Down Expand Up @@ -245,7 +245,7 @@ test_launch_ipfs_daemon_and_mount() {
test_kill_repeat_10_sec() {
# try to shut down once + wait for graceful exit
kill $1
for i in `seq 1 100`
for i in $(test_seq 1 100)
do
sleep 0.1
! kill -0 $1 2>/dev/null && return
Expand Down

0 comments on commit 0397bdf

Please sign in to comment.