Exprash/tests/utils.sh
2023-03-06 02:07:09 -07:00

31 lines
533 B
Bash
Executable File

_testPassCount=0
_testTotalCount=0
# $1: Message
# $2: Subshell output
function it() {
local exitCode=$?
local message="$1"
local output="$2"
local status
_testTotalCount=$((_testTotalCount+1))
if [ "$exitCode" -eq 0 ]; then
status='✓'
_testPassCount=$((_testPassCount+1))
else
status='✗'
fi
if [ -n "$output" ]; then
printf '%s\n' "$output"
fi
printf '%s %s\n' "$status" "$message"
}
function testSummary() {
printf 'Passed: %s of %s tests\n' "$_testPassCount" "$_testTotalCount"
}