X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/dba2e3c8f09a64ebf3c07323f1cb5fb2fa611d12..a940963381421de5cd0354c6fd1491754b5d1f5c:/test/common.sh diff --git a/test/common.sh b/test/common.sh index 1c675e20..5d46c8c2 100644 --- a/test/common.sh +++ b/test/common.sh @@ -31,3 +31,22 @@ require_prog () test_skip "missing $1" fi } + +# Some stuff for doing silly progress indicators +progress_update () +{ + THIS="$1" + FIRST="$2" + LAST="$3" + RANGE="$(($LAST - $FIRST))" + PROG="$(($THIS - $FIRST))" + # this automatically rounds to nearest integer + PERC="$(((100 * $PROG) / $RANGE))" + # note \r so next update will overwrite + printf "%3d%%\r" $PERC +} + +progress_done () +{ + printf "100%%\n" +}