2022-10-25 17:56:41 +00:00
|
|
|
#! /bin/bash
|
2018-11-07 19:49:31 +00:00
|
|
|
# Copyright (C) 2018 Igara Studio S.A.
|
2018-06-14 14:59:07 +00:00
|
|
|
# Copyright (C) 2018 David Capello
|
|
|
|
|
|
|
|
if [[ "$ASEPRITE" == "" ]]; then
|
|
|
|
echo ASEPRITE env var must be pointing to the Aseprite executable
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
function fail() {
|
|
|
|
echo FAIL
|
|
|
|
echo $BASH_SOURCE:$BASH_LINENO: error: $*
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2018-11-07 19:49:31 +00:00
|
|
|
function expect() {
|
2021-03-08 22:27:07 +00:00
|
|
|
if [[ $1 != "$($2 | tr -d "\r")" ]] ; then
|
2018-11-07 19:49:31 +00:00
|
|
|
echo "FAILED: $2"
|
|
|
|
echo "EXPECTED: $1"
|
|
|
|
echo "RESULT: $($2)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-12-20 17:23:00 +00:00
|
|
|
# General information
|
2018-06-14 14:59:07 +00:00
|
|
|
echo ----------------------------------------------------------------------
|
|
|
|
echo $ASEPRITE --version
|
|
|
|
$ASEPRITE --version
|
|
|
|
|
2018-12-20 17:23:00 +00:00
|
|
|
filter="$*"
|
|
|
|
if [[ "$filter" != "" ]]; then
|
|
|
|
echo Filter: $filter
|
|
|
|
fi
|
|
|
|
|
2018-11-07 19:49:31 +00:00
|
|
|
t=$(mktemp -d)
|
2021-03-08 19:28:55 +00:00
|
|
|
if [[ "$(uname)" =~ "MINGW" ]] || [[ "$(uname)" =~ "MSYS" ]] ; then
|
2019-12-11 17:44:29 +00:00
|
|
|
PWDARG=-W
|
|
|
|
t=$(cd "$t" && pwd $PWDARG)
|
|
|
|
else
|
|
|
|
PWDARG=
|
|
|
|
fi
|
2018-12-20 17:23:00 +00:00
|
|
|
echo Temp dir: $t
|
2019-12-02 22:27:04 +00:00
|
|
|
export ASEPRITE_USER_FOLDER=$t
|
2018-11-07 19:49:31 +00:00
|
|
|
|
2018-12-20 17:23:00 +00:00
|
|
|
if [[ "$filter" == "" ]] || [[ "console" =~ $filter ]]; then
|
|
|
|
echo ----------------------------------------------------------------------
|
|
|
|
echo "Testing console..."
|
2021-03-08 19:07:35 +00:00
|
|
|
echo "uname=$(uname)"
|
2018-06-14 14:59:07 +00:00
|
|
|
|
2020-08-07 16:12:08 +00:00
|
|
|
$ASEPRITE -b --script scripts/console_assert.lua >$t/tmp 2>&1
|
2018-12-20 17:23:00 +00:00
|
|
|
! 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"
|
|
|
|
|
2021-03-08 19:28:55 +00:00
|
|
|
if [[ "$(uname)" =~ "MINGW" ]] || [[ "$(uname)" =~ "MSYS" ]] ; then
|
2018-12-20 17:23:00 +00:00
|
|
|
echo Ignore console tests on Windows
|
|
|
|
else
|
2020-08-07 16:12:08 +00:00
|
|
|
$ASEPRITE -b --script scripts/console_print.lua >$t/tmp 2>&1
|
2018-12-20 17:23:00 +00:00
|
|
|
cat >$t/tmp_expected <<EOF
|
2018-06-14 14:59:07 +00:00
|
|
|
hello world
|
2018-08-22 17:56:07 +00:00
|
|
|
1 2 3
|
2018-06-14 14:59:07 +00:00
|
|
|
EOF
|
2018-12-20 17:23:00 +00:00
|
|
|
! diff -u $t/tmp $t/tmp_expected && fail
|
|
|
|
fi
|
2018-09-06 17:21:34 +00:00
|
|
|
fi
|
2018-06-14 14:59:07 +00:00
|
|
|
|
2018-12-20 17:23:00 +00:00
|
|
|
first=0
|
2018-08-20 17:22:36 +00:00
|
|
|
result=0
|
2018-08-22 17:56:07 +00:00
|
|
|
for script in scripts/*.lua ; do
|
|
|
|
[[ $script =~ console ]] && continue
|
2018-12-20 17:23:00 +00:00
|
|
|
if [[ "$filter" != "" ]]; then
|
|
|
|
[[ $script =~ $filter ]] || continue
|
|
|
|
fi
|
|
|
|
if [ $first == 0 ]; then
|
|
|
|
echo ----------------------------------------------------------------------
|
|
|
|
echo "Testing scripts..."
|
|
|
|
first=1
|
|
|
|
fi
|
2018-08-22 17:56:07 +00:00
|
|
|
echo "Running $script"
|
2020-08-07 16:12:08 +00:00
|
|
|
if ! $ASEPRITE -b --script $script >$t/tmp 2>&1 ; then
|
|
|
|
echo FAILED && cat $t/tmp
|
2018-12-20 17:23:00 +00:00
|
|
|
result=1
|
2018-06-14 14:59:07 +00:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2018-12-20 17:23:00 +00:00
|
|
|
first=0
|
2018-11-07 19:49:31 +00:00
|
|
|
for script in cli/*.sh ; do
|
2018-12-20 17:23:00 +00:00
|
|
|
if [[ "$filter" == "" ]] || [[ $script =~ $filter ]]; then
|
|
|
|
if [ $first == 0 ]; then
|
|
|
|
echo ----------------------------------------------------------------------
|
|
|
|
echo "Testing CLI..."
|
|
|
|
first=1
|
|
|
|
fi
|
|
|
|
echo "Running $script"
|
|
|
|
source $script
|
|
|
|
fi
|
2018-11-07 19:49:31 +00:00
|
|
|
done
|
|
|
|
|
2018-06-14 14:59:07 +00:00
|
|
|
echo ----------------------------------------------------------------------
|
2018-12-06 16:00:56 +00:00
|
|
|
if [ $result == 0 ] ; then
|
|
|
|
echo Done
|
|
|
|
else
|
|
|
|
echo FAILED
|
|
|
|
fi
|
2018-06-14 14:59:07 +00:00
|
|
|
echo ----------------------------------------------------------------------
|
2018-08-20 17:22:36 +00:00
|
|
|
|
|
|
|
exit $result
|