Allow unit tests to test for errors.
This commit is contained in:
parent
1ed866dbf0
commit
d63238ed9d
62
test/run
62
test/run
|
@ -15,7 +15,11 @@ main() {
|
||||||
test_files=$(ls out selections state 2>/dev/null)
|
test_files=$(ls out selections state 2>/dev/null)
|
||||||
cd $work/$dir;
|
cd $work/$dir;
|
||||||
indent="$(echo "${dir}/" | sed -e 's|[^/]*/\+| |g')"
|
indent="$(echo "${dir}/" | sed -e 's|[^/]*/\+| |g')"
|
||||||
name=$(basename $PWD)
|
name=$(echo ${PWD##*/} | sed 's/-fail^//')
|
||||||
|
should_fail=0
|
||||||
|
if [ ${PWD##*-} = fail ]; then
|
||||||
|
should_fail=1
|
||||||
|
fi
|
||||||
if ! test -e cmd; then
|
if ! test -e cmd; then
|
||||||
echo "$indent$name"
|
echo "$indent$name"
|
||||||
elif test -x enabled && ! ./enabled; then
|
elif test -x enabled && ! ./enabled; then
|
||||||
|
@ -46,32 +50,40 @@ main() {
|
||||||
"
|
"
|
||||||
${test}/../src/kak out -n -u -e "$kak_commands"
|
${test}/../src/kak out -n -u -e "$kak_commands"
|
||||||
retval=$?
|
retval=$?
|
||||||
if [ $retval -ne 0 ]; then
|
if [ $should_fail = 0 ]; then
|
||||||
|
if [ $retval -ne 0 ]; then
|
||||||
echo "Kakoune returned error $retval"
|
echo "Kakoune returned error $retval"
|
||||||
fi
|
|
||||||
for expect in $test_files; do
|
|
||||||
if cmp -s $test/$dir/$expect $expect; then
|
|
||||||
echo "$indent$name" | colorize green normal
|
|
||||||
else
|
|
||||||
number_failures=$(($number_failures + 1))
|
|
||||||
echo "$indent$name" | colorize red normal
|
|
||||||
echo
|
|
||||||
diff -u $test/$dir/$expect $expect | while read -r line; do
|
|
||||||
first_character=$(echo "$line" | cut -b 1)
|
|
||||||
case $first_character in
|
|
||||||
+) color=green ;;
|
|
||||||
-) color=red ;;
|
|
||||||
@) color=magenta ;;
|
|
||||||
*) color=none ;;
|
|
||||||
esac
|
|
||||||
echo "$line" | colorize $color normal
|
|
||||||
done
|
|
||||||
echo
|
|
||||||
echo "debug buffer:" | colorize yellow normal
|
|
||||||
cat debug
|
|
||||||
echo
|
|
||||||
fi
|
fi
|
||||||
done
|
for expect in $test_files; do
|
||||||
|
if cmp -s $test/$dir/$expect $expect; then
|
||||||
|
echo "$indent$name" | colorize green normal
|
||||||
|
else
|
||||||
|
number_failures=$(($number_failures + 1))
|
||||||
|
echo "$indent$name" | colorize red normal
|
||||||
|
echo
|
||||||
|
diff -u $test/$dir/$expect $expect | while read -r line; do
|
||||||
|
first_character=$(echo "$line" | cut -b 1)
|
||||||
|
case $first_character in
|
||||||
|
+) color=green ;;
|
||||||
|
-) color=red ;;
|
||||||
|
@) color=magenta ;;
|
||||||
|
*) color=none ;;
|
||||||
|
esac
|
||||||
|
echo "$line" | colorize $color normal
|
||||||
|
done
|
||||||
|
echo
|
||||||
|
echo "debug buffer:" | colorize yellow normal
|
||||||
|
cat debug
|
||||||
|
echo
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
if [ $retval -eq 0 ]; then
|
||||||
|
color=red
|
||||||
|
fi
|
||||||
|
color=${color:-green}
|
||||||
|
echo "$indent$name" | colorize $color normal
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if expr $number_failures > 0; then
|
if expr $number_failures > 0; then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user