From 9485eb8a1e2046f26d2410290bc6dc4a850c5471 Mon Sep 17 00:00:00 2001 From: Marc Jeanmougin Date: Thu, 20 Jul 2017 21:02:10 +0200 Subject: Add a rendering test platform --- CMakeLists.txt | 2 + testfiles/CMakeLists.txt | 3 +- .../expected_rendering/test-empty-large.png | Bin 0 -> 69082 bytes .../expected_rendering/test-empty.png | Bin 0 -> 6920 bytes testfiles/rendering_tests/test-empty.svg | 65 +++++++++++++++++++++ testfiles/rendering_tests/test.sh | 65 +++++++++++++++++++++ 6 files changed, 134 insertions(+), 1 deletion(-) create mode 100644 testfiles/rendering_tests/expected_rendering/test-empty-large.png create mode 100644 testfiles/rendering_tests/expected_rendering/test-empty.png create mode 100644 testfiles/rendering_tests/test-empty.svg create mode 100755 testfiles/rendering_tests/test.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 094ebacab..1060a350e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,6 +256,8 @@ if(GMOCK_PRESENT) set(CMAKE_CTEST_ENV INKSCAPE_DATADIR=${CMAKE_CURRENT_SOURCE_DIR}/share) add_subdirectory(testfiles EXCLUDE_FROM_ALL) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} DEPENDS tests) + add_dependencies(check inkscape) + add_dependencies(check ALL) endif() # Canonicalize the flags to speed up recompilation using ccache/etc. diff --git a/testfiles/CMakeLists.txt b/testfiles/CMakeLists.txt index 388a04b11..637a7a8cd 100644 --- a/testfiles/CMakeLists.txt +++ b/testfiles/CMakeLists.txt @@ -28,4 +28,5 @@ foreach(source ${TEST_SOURCES}) add_test(NAME ${source} COMMAND ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${source}) set_tests_properties(${source} PROPERTIES ENVIRONMENT ${CMAKE_CTEST_ENV}) add_dependencies(tests ${source}) -endforeach() \ No newline at end of file +endforeach() +add_test(NAME "rendering_test" COMMAND test.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/inkscape WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/testfiles/rendering_tests ) diff --git a/testfiles/rendering_tests/expected_rendering/test-empty-large.png b/testfiles/rendering_tests/expected_rendering/test-empty-large.png new file mode 100644 index 000000000..34acf1f26 Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-empty-large.png differ diff --git a/testfiles/rendering_tests/expected_rendering/test-empty.png b/testfiles/rendering_tests/expected_rendering/test-empty.png new file mode 100644 index 000000000..2e0a5fe1d Binary files /dev/null and b/testfiles/rendering_tests/expected_rendering/test-empty.png differ diff --git a/testfiles/rendering_tests/test-empty.svg b/testfiles/rendering_tests/test-empty.svg new file mode 100644 index 000000000..24b396e21 --- /dev/null +++ b/testfiles/rendering_tests/test-empty.svg @@ -0,0 +1,65 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + diff --git a/testfiles/rendering_tests/test.sh b/testfiles/rendering_tests/test.sh new file mode 100755 index 000000000..aaaa1527d --- /dev/null +++ b/testfiles/rendering_tests/test.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +### HOWTO ### +# Add a rendering test: +# - create the svg file +# - inkscape .svg -d 96 -e expected_rendering/.png +# - inkscape .svg -d 384 -e expected_rendering/-large.png +# - add the test in the list below +# - use stable if possible to generate the reference png files +# - git add .svg expected_rendering/-large.png expected_rendering/.png +# +# 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 +# - IF you change introduces a greater compatibility with css or browsers +# - AND you cannot reasonably "update" files from older versions to match the appearance +# - AND inkscape-devel@ has a consensus that it's the only way +# -> do as you must +# - manually double check the changes +# Fix a failing test (due to a change in pixman or cairo): +# - update renderings. Use a *stable* version to generate the renderings, NOT TRUNK +# - manually check appearances +############# + +### test list ### + +tests="\ + test-empty\ + " + +### script ### + + + +if [ "$#" -lt 1 ]; then + echo "pass the path of the inkscape executable as parameter" $# + exit 1 +fi +INKSCAPE_EXE=$1 +exit_status=0 +for test in $tests +do + ${INKSCAPE_EXE} -z ${test}.svg -d 96 -e ${test}.png 2>/dev/null >/dev/null + compare -metric AE ${test}.png expected_rendering/${test}.png ${test}-compare.png 2> .tmp + test1=`cat .tmp` + echo $test1 + if [ $test1 == 0 ]; then + echo ${test} "PASSED" + rm ${test}.png ${test}-compare.png + else + echo ${test} "FAILED" + exist_status=1 + fi + ${INKSCAPE_EXE} -z ${test}.svg -d 384 -e ${test}-large.png 2>/dev/null >/dev/null + compare -metric AE ${test}-large.png expected_rendering/${test}-large.png ${test}-compare-large.png 2>.tmp + test2=`cat .tmp` + if [ $test2 == 0 ]; then + echo ${test}-large "PASSED" + rm ${test}-large.png ${test}-compare-large.png + else + echo ${test}-large "FAILED" + fi +done +rm .tmp +exit $exit_status -- cgit v1.2.3