More consistent whitespace in tests.sh
This commit is contained in:
parent
0c9c876d00
commit
2af48f63ca
42
src/tests.sh
42
src/tests.sh
|
@ -6,12 +6,12 @@ TOTAL_PASSES=0
|
||||||
TOTAL_FAILS=0
|
TOTAL_FAILS=0
|
||||||
FAILS=0
|
FAILS=0
|
||||||
FAIL_OUTPUT=""
|
FAIL_OUTPUT=""
|
||||||
VALGRIND=0
|
VALGRIND=false
|
||||||
|
|
||||||
CURRENT_BLOCK=""
|
CURRENT_BLOCK=""
|
||||||
|
|
||||||
if [ "$1" == "-val" ]; then
|
if [ "$1" == "-val" ]; then
|
||||||
VALGRIND=1
|
VALGRIND=true
|
||||||
fi
|
fi
|
||||||
|
|
||||||
endBlock() {
|
endBlock() {
|
||||||
|
@ -28,31 +28,31 @@ title() {
|
||||||
}
|
}
|
||||||
|
|
||||||
pass() {
|
pass() {
|
||||||
echo -n "[1;32m✓"
|
echo -n "[1;32m✓"
|
||||||
((TOTAL_PASSES++))
|
((TOTAL_PASSES++))
|
||||||
}
|
}
|
||||||
|
|
||||||
fail() {
|
fail() {
|
||||||
echo -n "[1;31mX"
|
echo -n "[1;31mX"
|
||||||
FAIL_OUTPUT="$FAIL_OUTPUT [1;31m$1 test FAILED [0;34m$2[0m"
|
FAIL_OUTPUT="$FAIL_OUTPUT [1;31m$1 test FAILED [0;34m$2[0m"
|
||||||
((FAILS++))
|
((FAILS++))
|
||||||
((TOTAL_FAILS++))
|
((TOTAL_FAILS++))
|
||||||
}
|
}
|
||||||
|
|
||||||
check() {
|
check() {
|
||||||
local output
|
local output
|
||||||
if (($VALGRIND == 1)); then
|
if $VALGRIND; then
|
||||||
local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2")
|
local output=$($VALCOM ./pl "(loadfile \"examples/lib.pbl\") $2")
|
||||||
else
|
else
|
||||||
local output=$(./pl "(loadfile \"examples/lib.pbl\") $2")
|
local output=$(./pl "(loadfile \"examples/lib.pbl\") $2")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$output" == "$3" ]; then
|
if [ "$output" == "$3" ]; then
|
||||||
pass $1
|
pass $1
|
||||||
else
|
else
|
||||||
fail $1 "$2"
|
fail $1 "$2"
|
||||||
FAIL_OUTPUT="${FAIL_OUTPUT}\n [31mExpected '$3' but received '$output'"
|
FAIL_OUTPUT="${FAIL_OUTPUT}\n [31mExpected '$3' but received '$output'"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "[1;33mSTARTING TESTS[0;m"
|
echo "[1;33mSTARTING TESTS[0;m"
|
||||||
|
@ -191,7 +191,7 @@ endBlock
|
||||||
echo ""
|
echo ""
|
||||||
|
|
||||||
if [ "$TOTAL_FAILS" -ne "0" ]; then
|
if [ "$TOTAL_FAILS" -ne "0" ]; then
|
||||||
echo -n "[1;31m"
|
echo -n "[1;31m"
|
||||||
fi
|
fi
|
||||||
echo "$TOTAL_FAILS Tests Failed[0m"
|
echo "$TOTAL_FAILS Tests Failed[0m"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue