cmake: fix generate-examples/check-examples (#2545)

This commit is contained in:
Daniel Hahler 2019-02-19 00:15:19 +01:00 committed by GitHub
parent 24dbb1de20
commit ddf422dd0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 27 deletions

View file

@ -199,10 +199,7 @@ script:
travis_fold_start "DO_COVERAGE" travis_fold_start "DO_COVERAGE"
# Run tests/examples explicitly. # Run tests/examples explicitly.
(mkdir -p tests/examples/build \ make check-examples || exit 1
&& cd tests/examples/build \
&& cmake $CMAKE_ARGS .. \
&& make)
do_codecov samples do_codecov samples
make check-unit || exit 1 make check-unit || exit 1
@ -215,6 +212,7 @@ script:
travis_fold_end travis_fold_end
else else
# TODO: does not run check-examples. Should it?
travis_run_in_fold "make.check-unit" make check-unit travis_run_in_fold "make.check-unit" make check-unit
travis_run_in_fold "make.check-integration" make check-integration travis_run_in_fold "make.check-integration" make check-integration
travis_run_in_fold "make.check-themes" make check-themes travis_run_in_fold "make.check-themes" make check-themes

View file

@ -275,15 +275,15 @@ if(GENERATE_DOC)
# Load the common documentation # Load the common documentation
include(docs/load_ldoc.cmake) include(docs/load_ldoc.cmake)
# Use `include`, rather than `add_subdirectory`, to keep the variables
# The file is a valid CMakeLists.txt and can be executed directly if only
# the image artefacts are needed.
include(tests/examples/CMakeLists.txt)
# Generate the widget lists # Generate the widget lists
include(docs/widget_lists.cmake) include(docs/widget_lists.cmake)
endif() endif()
# Use `include`, rather than `add_subdirectory`, to keep the variables
# The file is a valid CMakeLists.txt and can be executed directly if only
# the image artefacts are needed.
include(tests/examples/CMakeLists.txt)
# {{{ Configure files # {{{ Configure files
file(GLOB awesome_base_c_configure_files RELATIVE ${SOURCE_DIR} file(GLOB awesome_base_c_configure_files RELATIVE ${SOURCE_DIR}
${SOURCE_DIR}/*.c ${SOURCE_DIR}/*.c

View file

@ -20,7 +20,9 @@ cmake_minimum_required(VERSION 3.0.0)
execute_process(COMMAND lua -e "p = package.path:gsub(';', '\\\\;'); io.stdout:write(p)" execute_process(COMMAND lua -e "p = package.path:gsub(';', '\\\\;'); io.stdout:write(p)"
OUTPUT_VARIABLE "LUA_PATH_") OUTPUT_VARIABLE "LUA_PATH_")
# Make sure the system can be called from the test directory # Allow to use the example tests by themselves.
# This was used on Travis for separate coverage reporting, but is not really
# required anymore.
if(NOT SOURCE_DIR AND ${CMAKE_CURRENT_SOURCE_DIR} MATCHES "/tests/examples") if(NOT SOURCE_DIR AND ${CMAKE_CURRENT_SOURCE_DIR} MATCHES "/tests/examples")
get_filename_component(TOP_SOURCE_DIR get_filename_component(TOP_SOURCE_DIR
"${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE) "${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE)
@ -256,26 +258,26 @@ function(run_test test_path namespace escaped_content)
file(RELATIVE_PATH rel_template "${TOP_SOURCE_DIR}" "${template}") file(RELATIVE_PATH rel_template "${TOP_SOURCE_DIR}" "${template}")
file(RELATIVE_PATH rel_test_path "${TOP_SOURCE_DIR}" "${test_path}") file(RELATIVE_PATH rel_test_path "${TOP_SOURCE_DIR}" "${test_path}")
# Add target to run this as test (via check-examples, not ignoring errors).
set(TARGET_NAME "run-${rel_test_path}")
STRING(REPLACE "/" "-" TARGET_NAME ${TARGET_NAME})
set(EXAMPLE_DOC_TEST_TARGETS ${EXAMPLE_DOC_TEST_TARGETS} ${TARGET_NAME}
PARENT_SCOPE)
add_custom_target(${TARGET_NAME}
COMMAND "${TOP_SOURCE_DIR}/tests/examples/runner.sh" "${expected_output_path}" ${LUA_COV_RUNNER} ${template} ${test_path} ${IMAGE_PATH}
VERBATIM)
if(NOT ${OUTPUT_IMAGE_PATH} STREQUAL "") if(NOT ${OUTPUT_IMAGE_PATH} STREQUAL "")
file(RELATIVE_PATH rel_output "${TOP_SOURCE_DIR}" "${OUTPUT_IMAGE_PATH}") file(RELATIVE_PATH rel_output "${TOP_SOURCE_DIR}" "${OUTPUT_IMAGE_PATH}")
add_custom_command( add_custom_command(
COMMAND "${TOP_SOURCE_DIR}/tests/examples/runner.sh" "${expected_output_path}" ${LUA_COV_RUNNER} ${template} ${test_path} ${IMAGE_PATH} ${IGNORE_ERRORS} COMMAND "${TOP_SOURCE_DIR}/tests/examples/runner.sh" "${expected_output_path}" ${LUA_COV_RUNNER} ${template} ${test_path} ${IMAGE_PATH} ${IGNORE_ERRORS}
COMMENT "Running ${rel_test_path} (via ${rel_template}, generating ${rel_output})" # COMMENT "Running ${rel_test_path} (via ${rel_template}, generating ${rel_output})"
DEPENDS ${template} ${test_path} DEPENDS ${template} ${test_path}
OUTPUT ${OUTPUT_IMAGE_PATH} OUTPUT ${OUTPUT_IMAGE_PATH}
VERBATIM) VERBATIM)
set(EXAMPLE_DOC_GENERATED_FILES ${OUTPUT_IMAGE_PATH} ${EXAMPLE_DOC_GENERATED_FILES} set(EXAMPLE_DOC_GENERATED_FILES ${OUTPUT_IMAGE_PATH} ${EXAMPLE_DOC_GENERATED_FILES}
PARENT_SCOPE) PARENT_SCOPE)
else()
set(TARGET_NAME "run-${rel_test_path}")
STRING(REPLACE "/" "-" TARGET_NAME ${TARGET_NAME})
add_custom_target(${TARGET_NAME}
COMMAND "${TOP_SOURCE_DIR}/tests/examples/runner.sh" "${expected_output_path}" ${LUA_COV_RUNNER} ${template} ${test_path} ${IMAGE_PATH} ${IGNORE_ERRORS}
COMMENT "Running ${rel_test_path} (via ${rel_template})"
DEPENDS ${template} ${test_path}
VERBATIM)
set(EXAMPLE_DOC_EXTRA_TARGETS ${TARGET_NAME} ${EXAMPLE_DOC_EXTRA_TARGETS}
PARENT_SCOPE)
endif() endif()
# Export the outout to the parent scope. # Export the outout to the parent scope.
@ -310,11 +312,7 @@ foreach(file ${test_files})
endif() endif()
endforeach() endforeach()
add_custom_target(generate-examples ALL DEPENDS ${EXAMPLE_DOC_GENERATED_FILES} ${EXAMPLE_DOC_EXTRA_TARGETS}) add_custom_target(generate-examples DEPENDS ${EXAMPLE_DOC_GENERATED_FILES})
add_custom_target(check-examples DEPENDS ${EXAMPLE_DOC_TEST_TARGETS})
add_custom_target(check-examples
${CMAKE_COMMAND} ${CMAKE_SOURCE_DIR}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
list(APPEND CHECK_TARGETS check-examples)
# vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker # vim: filetype=cmake:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80:foldmethod=marker