From 5a924516c5f16550454af7841c82d82b408447bf Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sun, 14 Feb 2021 17:02:47 +0100 Subject: [PATCH] This add a system to test LPE based in data of paths Because inkscape recreate the d atribute on run from comand line we use this feature to store the same version with and without d atribute and check the new generated d attributes are equal original ones. --- src/object/sp-lpe-item.cpp | 3 +- testfiles/CMakeLists.txt | 1 + testfiles/lpe_tests/CMakeLists.txt | 18 ++ testfiles/lpe_tests/README | 16 ++ testfiles/lpe_tests/bend.svg | 240 ++++++++++++++++++++++++++ testfiles/lpe_tests/expected/bend.svg | 240 ++++++++++++++++++++++++++ testfiles/lpe_tests/test.sh | 25 +++ 7 files changed, 542 insertions(+), 1 deletion(-) create mode 100644 testfiles/lpe_tests/CMakeLists.txt create mode 100644 testfiles/lpe_tests/README create mode 100644 testfiles/lpe_tests/bend.svg create mode 100644 testfiles/lpe_tests/expected/bend.svg create mode 100755 testfiles/lpe_tests/test.sh diff --git a/src/object/sp-lpe-item.cpp b/src/object/sp-lpe-item.cpp index cb4e1d13aa9..1d44507262f 100755 --- a/src/object/sp-lpe-item.cpp +++ b/src/object/sp-lpe-item.cpp @@ -419,7 +419,8 @@ lpeobject_ref_modified(SPObject */*href*/, guint flags, SPLPEItem *lpeitem) #ifdef SHAPE_VERBOSE g_message("lpeobject_ref_modified"); #endif - if (flags != 29 && flags != 253) { + auto lprtestenv = Glib::getenv("INKTESTENV"); + if (!lprtestenv.empty() || (flags != 29 && flags != 253)) { sp_lpe_item_update_patheffect (lpeitem, true, true); } } diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index 8983863fa68..3c645b53e8e 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -96,6 +96,7 @@ endforeach() ### CLI and rendering tests add_subdirectory(cli_tests) add_subdirectory(rendering_tests) +add_subdirectory(lpe_tests) ### Fuzz test diff --git a/testfiles/lpe_tests/CMakeLists.txt b/testfiles/lpe_tests/CMakeLists.txt new file mode 100644 index 00000000000..a2787bfc009 --- /dev/null +++ b/testfiles/lpe_tests/CMakeLists.txt @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +#add your test here (do not put the .svg extension) +set(LPE_TESTS + # -- Generic tests -- + bend + ${LPE_TESTS_64bit} +) + + +foreach(lpe_test ${LPE_TESTS}) + set(testname "lpe_${lpe_test}") + add_test(NAME ${testname} + COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/test.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/inkscape ${CMAKE_CURRENT_SOURCE_DIR}/${lpe_test} + WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/testfiles/lpe_tests) + set_tests_properties(${testname} PROPERTIES ENVIRONMENT "${INKSCAPE_TEST_PROFILE_DIR_ENV}/${testname};${CMAKE_CTEST_ENV}") +endforeach() + diff --git a/testfiles/lpe_tests/README b/testfiles/lpe_tests/README new file mode 100644 index 00000000000..6ee6579b1f5 --- /dev/null +++ b/testfiles/lpe_tests/README @@ -0,0 +1,16 @@ +HOWTO + +# Add a LPE test: + - create the svg file with some examples of the same LPE (clip, mask shape, path, group.... + - add the test in CMakeLists.txt + - use 1.0 if posible as base to generarte files + - store the file in "lpe_tests/expected" folder + - copy also the file to "lpe_tests" folder open it in a text editoer and remove all d attributes of the file + + +# Fix a failing test (due to a change in code): + - DO *NOT* MODIFY the expected rendering (or the svg) before getting advice from inkscape-devel@ + - fix your code if possible + - manually double check the changes + + diff --git a/testfiles/lpe_tests/bend.svg b/testfiles/lpe_tests/bend.svg new file mode 100644 index 00000000000..f612bdffe35 --- /dev/null +++ b/testfiles/lpe_tests/bend.svg @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testfiles/lpe_tests/expected/bend.svg b/testfiles/lpe_tests/expected/bend.svg new file mode 100644 index 00000000000..112399e4203 --- /dev/null +++ b/testfiles/lpe_tests/expected/bend.svg @@ -0,0 +1,240 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/testfiles/lpe_tests/test.sh b/testfiles/lpe_tests/test.sh new file mode 100755 index 00000000000..0541bf3da35 --- /dev/null +++ b/testfiles/lpe_tests/test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0-or-later + +if [ "$#" -lt 2 ]; then + echo "pass the path of the inkscape executable as parameter then the name of the test" $# + exit 1 +fi + +INKSCAPE_EXE=$1 +exit_status=0 +test=$2 +EXPECTED=$(dirname $test)"/expected/"$(basename $test) +testname=$(basename $test) + INKTESTENV=true ${INKSCAPE_EXE} --export-filename=${testname}_ORIG.svg ${test}.svg #2>/dev/null >/dev/null + INKTESTENV=true ${INKSCAPE_EXE} --export-filename=${testname}_ESPECT.svg ${EXPECTED}.svg #2>/dev/null >/dev/null + cat ${testname}_ORIG.svg | sed 's| />||' | sed -En 's| (d=".*?")|\1|p' > ${testname}A.diff + cat ${testname}_ESPECT.svg | sed 's| />||' | sed -En 's| (d=".*?")|\1|p' > ${testname}B.diff + if cmp --silent -- "${testname}A.diff" "${testname}B.diff"; then + echo ${testname} "PASSED" + rm ${testname}_ORIG.svg ${testname}_ESPECT.svg ${testname}A.diff ${testname}B.diff + else + echo ${testname} "FAILED" + exit_status=1 + fi +exit $exit_status -- GitLab