diff options
| author | Marc Jeanmougin <marc@jeanmougin.fr> | 2017-07-20 19:02:10 +0000 |
|---|---|---|
| committer | Marc Jeanmougin <marc@jeanmougin.fr> | 2017-07-20 19:02:10 +0000 |
| commit | 9485eb8a1e2046f26d2410290bc6dc4a850c5471 (patch) | |
| tree | 3d1a9b573d245b2e96929e86df6efa8fa042b0c0 | |
| parent | CI/AppVeyor: try something new with ccache (diff) | |
| download | inkscape-9485eb8a1e2046f26d2410290bc6dc4a850c5471.tar.gz inkscape-9485eb8a1e2046f26d2410290bc6dc4a850c5471.zip | |
Add a rendering test platform
| -rw-r--r-- | CMakeLists.txt | 2 | ||||
| -rw-r--r-- | testfiles/CMakeLists.txt | 3 | ||||
| -rw-r--r-- | testfiles/rendering_tests/expected_rendering/test-empty-large.png | bin | 0 -> 69082 bytes | |||
| -rw-r--r-- | testfiles/rendering_tests/expected_rendering/test-empty.png | bin | 0 -> 6920 bytes | |||
| -rw-r--r-- | testfiles/rendering_tests/test-empty.svg | 65 | ||||
| -rwxr-xr-x | testfiles/rendering_tests/test.sh | 65 |
6 files changed, 134 insertions, 1 deletions
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 Binary files differnew file mode 100644 index 000000000..34acf1f26 --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-empty-large.png diff --git a/testfiles/rendering_tests/expected_rendering/test-empty.png b/testfiles/rendering_tests/expected_rendering/test-empty.png Binary files differnew file mode 100644 index 000000000..2e0a5fe1d --- /dev/null +++ b/testfiles/rendering_tests/expected_rendering/test-empty.png 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 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="210mm" + height="297mm" + viewBox="0 0 210 297" + version="1.1" + id="svg8" + inkscape:version="0.92.1 r15371" + sodipodi:docname="test-empty.svg"> + <defs + id="defs2" /> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="0.0" + inkscape:pageshadow="2" + inkscape:zoom="0.35" + inkscape:cx="-360" + inkscape:cy="537.14286" + inkscape:document-units="mm" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="1920" + inkscape:window-height="1006" + inkscape:window-x="0" + inkscape:window-y="25" + inkscape:window-maximized="1" /> + <metadata + id="metadata5"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <rect + style="fill:#ffffff;fill-opacity:1;stroke:#000000;stroke-width:2.64583325;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:0.98039216" + id="rect7" + width="92.226196" + height="75.595238" + x="52.160713" + y="46.023808" + rx="6.6565199" + ry="6.6565199" /> + </g> +</svg> 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 <yourfile>.svg -d 96 -e expected_rendering/<yourfile>.png +# - inkscape <yourfile>.svg -d 384 -e expected_rendering/<yourfile>-large.png +# - add the test in the list below +# - use stable if possible to generate the reference png files +# - git add <yourfile>.svg expected_rendering/<yourfile>-large.png expected_rendering/<yourfile>.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 |
