Add support to filter tests to run in run-tests.sh

This commit is contained in:
David Capello 2018-12-20 14:23:00 -03:00
parent 72109b99bb
commit 3e23e63824

View File

@ -22,54 +22,72 @@ function expect() {
fi fi
} }
# General information
echo ---------------------------------------------------------------------- echo ----------------------------------------------------------------------
echo $ASEPRITE --version echo $ASEPRITE --version
$ASEPRITE --version $ASEPRITE --version
echo ---------------------------------------------------------------------- filter="$*"
echo Temp dir if [[ "$filter" != "" ]]; then
echo Filter: $filter
fi
t=$(mktemp -d) t=$(mktemp -d)
echo $t echo Temp dir: $t
echo ---------------------------------------------------------------------- if [[ "$filter" == "" ]] || [[ "console" =~ $filter ]]; then
echo "Testing console..." echo ----------------------------------------------------------------------
$ASEPRITE -b --script scripts/console_assert.lua >$t/tmp 2>$t/tmp_err echo "Testing console..."
! grep -q "this should be in the output" $t/tmp && fail "print() text not found in output"
! grep -q "assertion failed" $t/tmp && fail "assert() text not found in output"
grep -q "this should not be in the output" $t/tmp && fail "text that shouldn't be in the output is"
if [[ "$(uname)" =~ "MINGW32" ]] || [[ "$(uname)" =~ "MSYS_NT-10.0" ]] ; then $ASEPRITE -b --script scripts/console_assert.lua >$t/tmp 2>$t/tmp_err
echo Ignore console tests on Windows ! grep -q "this should be in the output" $t/tmp && fail "print() text not found in output"
else ! grep -q "assertion failed" $t/tmp && fail "assert() text not found in output"
$ASEPRITE -b --script scripts/console_print.lua >$t/tmp 2>$t/tmp_err grep -q "this should not be in the output" $t/tmp && fail "text that shouldn't be in the output is"
cat >$t/tmp_expected <<EOF
if [[ "$(uname)" =~ "MINGW32" ]] || [[ "$(uname)" =~ "MSYS_NT-10.0" ]] ; then
echo Ignore console tests on Windows
else
$ASEPRITE -b --script scripts/console_print.lua >$t/tmp 2>$t/tmp_err
cat >$t/tmp_expected <<EOF
hello world hello world
1 2 3 1 2 3
EOF EOF
! diff -u $t/tmp $t/tmp_expected && fail ! diff -u $t/tmp $t/tmp_expected && fail
fi
fi fi
echo ---------------------------------------------------------------------- first=0
echo "Testing scripts..."
result=0 result=0
for script in scripts/*.lua ; do for script in scripts/*.lua ; do
[[ $script =~ console ]] && continue [[ $script =~ console ]] && continue
if [[ "$filter" != "" ]]; then
[[ $script =~ $filter ]] || continue
fi
if [ $first == 0 ]; then
echo ----------------------------------------------------------------------
echo "Testing scripts..."
first=1
fi
echo "Running $script" echo "Running $script"
if ! $ASEPRITE -b --script $script >$t/tmp 2>$t/tmp_err ; then if ! $ASEPRITE -b --script $script >$t/tmp 2>$t/tmp_err ; then
echo FAILED echo FAILED
echo STDOUT && cat $t/tmp echo STDOUT && cat $t/tmp
echo STDERR && cat $t/tmp_err echo STDERR && cat $t/tmp_err
result=1 result=1
fi fi
done done
echo ---------------------------------------------------------------------- first=0
echo "Testing CLI..."
for script in cli/*.sh ; do for script in cli/*.sh ; do
echo "Running $script" if [[ "$filter" == "" ]] || [[ $script =~ $filter ]]; then
source $script if [ $first == 0 ]; then
echo ----------------------------------------------------------------------
echo "Testing CLI..."
first=1
fi
echo "Running $script"
source $script
fi
done done
echo ---------------------------------------------------------------------- echo ----------------------------------------------------------------------