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
|
2024-12-11 01:23:19 +00:00
|
|
|
echo "FAILED: $2"
|
|
|
|
echo "EXPECTED: $1"
|
|
|
|
echo "RESULT: $($2)"
|
|
|
|
exit 1
|
2018-11-07 19:49:31 +00:00
|
|
|
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
|
2024-12-11 01:23:19 +00:00
|
|
|
echo Ignore console tests on Windows
|
2018-12-20 17:23:00 +00:00
|
|
|
else
|
2024-12-11 01:23:19 +00:00
|
|
|
$ASEPRITE -b --script scripts/console_print.lua >$t/tmp 2>&1
|
|
|
|
echo -e "hello world\n1\t2\t3" >$t/tmp_expected
|
|
|
|
! diff -u $t/tmp $t/tmp_expected && fail
|
2018-12-20 17:23:00 +00:00
|
|
|
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
|
2024-12-11 01:23:19 +00:00
|
|
|
[[ $script =~ $filter ]] || continue
|
2018-12-20 17:23:00 +00:00
|
|
|
fi
|
|
|
|
if [ $first == 0 ]; then
|
2024-12-11 01:23:19 +00:00
|
|
|
echo ----------------------------------------------------------------------
|
|
|
|
echo "Testing scripts..."
|
|
|
|
first=1
|
2018-12-20 17:23:00 +00:00
|
|
|
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
|
2024-12-11 01:23:19 +00:00
|
|
|
echo FAILED && cat $t/tmp
|
|
|
|
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
|
2024-12-11 01:23:19 +00:00
|
|
|
if [ $first == 0 ]; then
|
|
|
|
echo ----------------------------------------------------------------------
|
|
|
|
echo "Testing CLI..."
|
|
|
|
first=1
|
|
|
|
fi
|
|
|
|
echo "Running $script"
|
|
|
|
source $script
|
2018-12-20 17:23:00 +00:00
|
|
|
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
|