1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
# shellcheck shell=bash
#------------------------------------------------------------------------------
# This is a tiny version of test-more-bash that I use here. test-more-bash uses
# bash+, so I want to avoid the circular dependency. This little guy does
# 80-90% what test-more-bash does, with minimal code. It's a good example of
# how nice Bash can be.
#------------------------------------------------------------------------------
set -e -o pipefail
PATH=$PWD/bin:$PATH
run=0
plan() {
echo "1..$1"
}
pass() {
(( ++run ))
echo "ok $run${1:+ - $1}"
}
fail() {
(( ++run ))
echo "not ok $run${1:+ - $1}"
}
is() {
if [[ $1 == "$2" ]]; then
pass "$3"
else
fail "$3"
diag "Got: $1"
diag "Want: $2"
fi
}
ok() {
if (exit "${1:-$?}"); then
pass "$2"
else
fail "$2"
fi
}
like() {
if [[ $1 =~ $2 ]]; then
pass "$3"
else
fail "$3"
diag "Got: $1"
diag "Like: $2"
fi
}
unlike() {
if [[ ! $1 =~ $2 ]]; then
pass "$3"
else
fail "$3"
diag "Got: $1"
diag "Dont: $2"
fi
}
done_testing() {
echo "1..${1:-$run}"
}
diag() {
echo "# ${1//$'\n'/$'\n'# }" >&2
}
note() {
echo "# ${1//$'\n'/$'\n'# }"
}
#! vim: ft=sh sw=2:
|