Description: partial patch from upstream to ease the next patch Origin: upstream, 699da8c402e8fce05b08021d1bfff779499d711c Last-Update: 2022-12-18 --- a/testfiles/cli_tests/CMakeLists.txt +++ b/testfiles/cli_tests/CMakeLists.txt @@ -8,6 +8,7 @@ # Command line options: # INPUT_FILENAME - name of input file (optional) # OUTPUT_FILENAME - name of output file (optional) +# OUTPUT_PAGE - index of page in multipage output (optional), starts from 0 # PARAMETERS - additional command line parameters to pass to Inkscape # # Pass/fail criteria: @@ -17,6 +18,7 @@ # see https://cmake.org/cmake/help/latest/prop_test/FAIL_REGULAR_EXPRESSION.html for details # REFERENCE_FILENAME - compare OUTPUT_FILENAME with this pre-rendered reference file # both files are converted to PNG and compared with ImageMagick's 'compare' +# for multipage output, use OUTPUT_PAGE to specify a single page for comparison # EXPECTED_FILES - verify the command produced the expected files (i.e. they exist on disk) # TEST_SCRIPT - additional script to run after performing all checks and before cleaning up # @@ -24,7 +26,7 @@ # ENVIRONMENT - Additional environment variables to set while running the test function(add_cli_test name) # parse arguments - set(oneValueArgs INPUT_FILENAME OUTPUT_FILENAME PASS_FOR_OUTPUT FAIL_FOR_OUTPUT REFERENCE_FILENAME) + set(oneValueArgs INPUT_FILENAME OUTPUT_FILENAME OUTPUT_PAGE PASS_FOR_OUTPUT FAIL_FOR_OUTPUT REFERENCE_FILENAME) set(multiValueArgs PARAMETERS EXPECTED_FILES TEST_SCRIPT ENVIRONMENT) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) @@ -78,7 +80,8 @@ add_test(NAME ${testname}_check_output COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/check_output.sh - "${ARG_OUTPUT_FILENAME}" "${ARG_REFERENCE_FILENAME}" "${ARG_EXPECTED_FILES}" "${ARG_TEST_SCRIPT}") + "${ARG_OUTPUT_FILENAME}" "${ARG_OUTPUT_PAGE}" "${ARG_REFERENCE_FILENAME}" + "${ARG_EXPECTED_FILES}" "${ARG_TEST_SCRIPT}") set_tests_properties(${testname}_check_output PROPERTIES ENVIRONMENT "${CMAKE_CTEST_ENV}" DEPENDS ${testname} SKIP_RETURN_CODE 42) endif() --- a/testfiles/cli_tests/check_output.sh +++ b/testfiles/cli_tests/check_output.sh @@ -5,9 +5,10 @@ command -v compare >/dev/null 2>&1 || { echo >&2 "I require ImageMagick's 'compare' but it's not installed. Aborting."; exit 1; } OUTPUT_FILENAME=$1 -REFERENCE_FILENAME=$2 -EXPECTED_FILES=$3 -TEST_SCRIPT=$4 +OUTPUT_PAGE=$2 +REFERENCE_FILENAME=$3 +EXPECTED_FILES=$4 +TEST_SCRIPT=$5 # check if expected files exist for file in ${EXPECTED_FILES}; do @@ -29,7 +30,14 @@ # - use internal MSVG delegate in SVG conversions for reproducibility reasons (avoid inkscape or rsvg delegates) [ "${OUTPUT_FILENAME##*.}" = "svg" ] && delegate1=MSVG: [ "${REFERENCE_FILENAME##*.}" = "svg" ] && delegate2=MSVG: - if ! convert ${delegate1}${OUTPUT_FILENAME} ${OUTPUT_FILENAME}.png; then + + # extract a page from multipage PDF if requested and convert it to RGB + OUTFILE_SUFFIX="" + if [ -n "$OUTPUT_PAGE" ]; then + OUTFILE_SUFFIX="[${OUTPUT_PAGE}] -colorspace RGB" + fi + + if ! convert ${delegate1}${OUTPUT_FILENAME}${OUTFILE_SUFFIX} ${OUTPUT_FILENAME}.png; then echo "Warning: Failed to convert test file '${OUTPUT_FILENAME}' to PNG format. Skipping comparison test." exit 42 fi @@ -61,7 +69,7 @@ interpreter=python3 ;; *) - interpreter=sh + interpreter=bash ;; esac