diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b157e346..f7e79e7d4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,13 +64,6 @@ jobs: if [[ "${{ runner.os }}" == "Linux" ]] ; then export XVFB=xvfb-run fi - if [[ "${{ github.base_ref }}" == "beta" ]] || [[ "${{ github.ref }}" == "refs/heads/beta" ]] ; then - export TESTS_BRANCH=beta - else - export TESTS_BRANCH=main - fi - cd build - export ASEPRITE=$PWD/bin/aseprite - git clone --branch $TESTS_BRANCH --recursive https://github.com/aseprite/tests.git + export ASEPRITE=$PWD/build/bin/aseprite cd tests $XVFB bash run-tests.sh diff --git a/.gitmodules b/.gitmodules index 3108b72c0..f053e6d23 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ +[submodule "tests/third_party/json"] + path = tests/third_party/json + url = https://github.com/aseprite/json.lua [submodule "third_party/pixman"] path = third_party/pixman url = https://github.com/aseprite/pixman.git diff --git a/tests/LICENSE.txt b/tests/LICENSE.txt new file mode 100644 index 000000000..7d9e58083 --- /dev/null +++ b/tests/LICENSE.txt @@ -0,0 +1,21 @@ +Copyright (c) 2018-2022 Igara Studio S.A. +Copyright (c) 2018 David Capello + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 000000000..0035a1783 --- /dev/null +++ b/tests/README.md @@ -0,0 +1,31 @@ +# Aseprite Tests + +Test suite for [Aseprite](https://github.com/aseprite/aseprite) +to avoid breaking backward compatibility. + +This project is cloned by the +[build.yml](https://github.com/aseprite/aseprite/blob/main/.github/workflows/build.yml) file +on Aseprite project to do several automated tests: + +* Save/load file formats correctly. For this we have `.aseprite`, `.png`, + `.gif`, etc. files [sprites](https://github.com/aseprite/tests/tree/main/sprites) + folder. +* Test backward compatibility with [Aseprite CLI](https://www.aseprite.org/docs/cli/) options +* Future [scripting API](https://github.com/aseprite/api) using [scripts](https://github.com/aseprite/tests/tree/main/scripts) + +## How to run tests? + +You have to set the `ASEPRITE` environment variable pointing to the +Aseprite executable and then run `run-tests.sh` from Bash: + + export ASEPRITE=$HOME/your-aseprite-build/bin/aseprite + git clone https://github.com/aseprite/tests.git + cd tests + bash run-tests.sh + +You can filter some tests with a regex giving a parameter to +`run-tests.sh`, for example: + + run-tests.sh color + +Should run all tests which have the `color` word in their name. diff --git a/tests/cli/file-formats.sh b/tests/cli/file-formats.sh new file mode 100644 index 000000000..cd0b28666 --- /dev/null +++ b/tests/cli/file-formats.sh @@ -0,0 +1,61 @@ +#! /bin/bash +# Copyright (C) 2019 Igara Studio S.A. + +# Create a simple image and save it in all formats using scripts +d=$t/file-formats +mkdir $d +cat >$d/gen.lua <$d/compare.lua < /dev/null ; then + echo "FAILED: --help doesn't include usage information" + exit 1 +fi diff --git a/tests/cli/list-layers.sh b/tests/cli/list-layers.sh new file mode 100644 index 000000000..cd81c1cc9 --- /dev/null +++ b/tests/cli/list-layers.sh @@ -0,0 +1,10 @@ +#! /bin/bash +# Copyright (C) 2018 Igara Studio S.A. + +expect "bg +fg" "$ASEPRITE -b --list-layers sprites/1empty3.aseprite" + +expect "a +b +c +d" "$ASEPRITE -b --list-layers sprites/abcd.aseprite" diff --git a/tests/cli/list-tags.sh b/tests/cli/list-tags.sh new file mode 100644 index 000000000..0c3c5a2c6 --- /dev/null +++ b/tests/cli/list-tags.sh @@ -0,0 +1,5 @@ +#! /bin/bash +# Copyright (C) 2018 Igara Studio S.A. + +expect "a +b" "$ASEPRITE -b --list-tags sprites/1empty3.aseprite" diff --git a/tests/cli/save-as.sh b/tests/cli/save-as.sh new file mode 100644 index 000000000..c8791ed36 --- /dev/null +++ b/tests/cli/save-as.sh @@ -0,0 +1,256 @@ +#! /bin/bash +# Copyright (C) 2018-2021 Igara Studio S.A. + +function list_files() { + oldwd=$(pwd $PWDARG) + cd $1 && ls -1 *.* + cd $oldwd +} + +# --save-as + +d=$t/save-as +$ASEPRITE -b sprites/1empty3.aseprite --save-as "$d/image00.png" || exit 1 +expect "image00.png +image01.png +image02.png" "list_files $d" + +# --ignore-empty --save-as + +d=$t/save-as-ignore-empty +$ASEPRITE -b sprites/1empty3.aseprite --ignore-empty --save-as $d/image00.png || exit 1 +expect "image00.png +image02.png" "list_files $d" + +# --split-layers --save-as + +d=$t/save-as-split-layers +$ASEPRITE -b sprites/1empty3.aseprite --split-layers --save-as $d/layer.png || exit 1 +expect "layer (bg) 0.png +layer (bg) 1.png +layer (bg) 2.png +layer (fg) 0.png +layer (fg) 1.png +layer (fg) 2.png" "list_files $d" + +# --save-as {layer} + +d=$t/save-as-layer +mkdir $d # TODO why do we need this? +$ASEPRITE -b sprites/1empty3.aseprite --save-as $d/layer-{layer}.gif || exit 1 +expect "layer-bg.gif +layer-fg.gif" "list_files $d" + +# --save-as frame8-test.png + +d=$t/save-as-frame8-test +$ASEPRITE -b sprites/1empty3.aseprite --save-as "$d/frame8-test.png" || exit 1 +expect "frame8-test1.png +frame8-test2.png +frame8-test3.png" "list_files $d" + +# --save-as frame-0.png + +d=$t/save-as-frame-0 +$ASEPRITE -b sprites/1empty3.aseprite --save-as "$d/frame-0.png" || exit 1 +expect "frame-0.png +frame-1.png +frame-2.png" "list_files $d" + +# --save-as frame-00.png + +d=$t/save-as-frame-00 +$ASEPRITE -b sprites/1empty3.aseprite --save-as "$d/frame-00.png" || exit 1 +expect "frame-00.png +frame-01.png +frame-02.png" "list_files $d" + +# --save-as frame-001.png + +d=$t/save-as-frame-001 +$ASEPRITE -b sprites/1empty3.aseprite --save-as "$d/frame-001.png" || exit 1 +expect "frame-001.png +frame-002.png +frame-003.png" "list_files $d" + +# --save-as frame-0032.png + +d=$t/save-as-frame-0032 +$ASEPRITE -b sprites/1empty3.aseprite --save-as "$d/frame-0032.png" || exit 1 +expect "frame-0032.png +frame-0033.png +frame-0034.png" "list_files $d" + +# --trim --save-as + +d=$t/save-as-trim +$ASEPRITE -b --trim sprites/1empty3.aseprite --save-as "$d/trim-000.png" || exit 1 +expect "trim-000.png +trim-001.png +trim-002.png" "list_files $d" +cat >$d/compare.lua <$d/compare.lua <