mirror of https://github.com/CGAL/cgal
Merge pull request #1357 from lrineau/CGAL-add_ctest_cont-lrineau
CTest support (cont.)
This commit is contained in:
commit
41c7658466
|
|
@ -1,5 +1,7 @@
|
|||
language: cpp
|
||||
dist: trusty
|
||||
before_install:
|
||||
- sudo add-apt-repository ppa:smspillaz/cmake-2.8.12 -y
|
||||
install:
|
||||
before_script:
|
||||
- mkdir build
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
project( Arrangement_on_surface_2_ )
|
||||
|
||||
enable_testing()
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.10)
|
||||
|
||||
find_package(CGAL QUIET COMPONENTS Core)
|
||||
|
|
@ -16,11 +18,19 @@ if ( CGAL_FOUND )
|
|||
|
||||
include_directories (BEFORE "../../include")
|
||||
|
||||
# create a target per cppfile
|
||||
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
foreach(cppfile ${cppfiles})
|
||||
create_single_source_cgal_program( "${cppfile}" )
|
||||
endforeach()
|
||||
if(COMMAND target_compile_options)
|
||||
# Since CMake-2.8.12: New CMake script, that defines the targets and
|
||||
# the CTest test cases.
|
||||
include( ${CMAKE_CURRENT_SOURCE_DIR}/cgal_test.cmake )
|
||||
else()
|
||||
# If CMake version is <= 2.8.11, use the usual CMake script.
|
||||
|
||||
# create a target per cppfile
|
||||
file(GLOB cppfiles RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
||||
foreach(cppfile ${cppfiles})
|
||||
create_single_source_cgal_program( "${cppfile}" )
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
else()
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
|
|
@ -13,6 +13,11 @@ include(${CMAKE_SOURCE_DIR}/Installation/cmake/modules/CGAL_SCM.cmake)
|
|||
option( CGAL_REPORT_DUPLICATE_FILES "Switch on to start (naive) detection of duplicate source- and headerfiles in packages" OFF)
|
||||
|
||||
message( "== CMake setup (DONE) ==\n" )
|
||||
|
||||
# Enable testing with BUILD_TESTING
|
||||
option(BUILD_TESTING "Build the testing tree." OFF)
|
||||
include(CTest)
|
||||
|
||||
# and finally start actual build
|
||||
add_subdirectory( Installation )
|
||||
add_subdirectory( Documentation/doc)
|
||||
|
|
|
|||
|
|
@ -130,6 +130,10 @@ else ( CGAL_BRANCH_BUILD )
|
|||
set(CGAL_CORE_PACKAGE_DIR "${CMAKE_SOURCE_DIR}" CACHE INTERNAL "Directory containing the Core package")
|
||||
set(CGAL_GRAPHICSVIEW_PACKAGE_DIR "${CMAKE_SOURCE_DIR}" CACHE INTERNAL "Directory containing the GraphicsView package")
|
||||
|
||||
# Enable testing with BUILD_TESTING
|
||||
option(BUILD_TESTING "Build the testing tree." OFF)
|
||||
include(CTest)
|
||||
|
||||
endif (CGAL_BRANCH_BUILD )
|
||||
|
||||
#message(STATUS "Packages found: ${CGAL_CONFIGURED_PACKAGES}")
|
||||
|
|
@ -776,10 +780,6 @@ message("== Write compiler_config.h (DONE) ==\n")
|
|||
#--------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
# Enable testing with BUILD_TESTING
|
||||
option(BUILD_TESTING "Build the testing tree." OFF)
|
||||
include(CTest)
|
||||
|
||||
message("== Generating build files ==")
|
||||
|
||||
set(CGAL_LIBRARIES_DIR ${CMAKE_BINARY_DIR}/lib)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
include(CGAL_add_test)
|
||||
|
||||
function(create_single_source_cgal_program firstfile )
|
||||
|
||||
if(NOT IS_ABSOLUTE "${firstfile}")
|
||||
set(firstfile "${CMAKE_CURRENT_SOURCE_DIR}/${firstfile}")
|
||||
set(firstfile "${CGAL_CURRENT_SOURCE_DIR}/${firstfile}")
|
||||
endif()
|
||||
|
||||
get_filename_component(exe_name ${firstfile} NAME_WE)
|
||||
|
|
@ -12,27 +14,15 @@ function(create_single_source_cgal_program firstfile )
|
|||
|
||||
# remaining files
|
||||
foreach( i ${ARGN} )
|
||||
set( all ${all} ${CMAKE_CURRENT_SOURCE_DIR}/${i} )
|
||||
set( all ${all} ${CGAL_CURRENT_SOURCE_DIR}/${i} )
|
||||
endforeach()
|
||||
|
||||
|
||||
add_executable(${exe_name} ${all})
|
||||
|
||||
if(BUILD_TESTING)
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cin")
|
||||
set(ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cin")
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cmd")
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cmd" ARGS LIMIT_COUNT 1)
|
||||
# TODO: handle multi-lines .cmd files
|
||||
# see https://github.com/CGAL/cgal/pull/1295/files/c65d3abe17bb3e677b8077996cdaf8672f9c4c6f#r71705451
|
||||
endif()
|
||||
message(STATUS "add test for ${exe_name}")
|
||||
add_test(NAME ${exe_name}
|
||||
COMMAND ${exe_name} ${ARGS}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_property(TEST "${exe_name}"
|
||||
APPEND PROPERTY LABELS "${PROJECT_NAME}")
|
||||
endif(BUILD_TESTING)
|
||||
if(NOT NO_TESTING)
|
||||
cgal_add_test("${exe_name}")
|
||||
endif(NOT NO_TESTING)
|
||||
|
||||
add_to_cached_list( CGAL_EXECUTABLE_TARGETS ${exe_name} )
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
if(CGAL_add_test_included)
|
||||
return()
|
||||
endif(CGAL_add_test_included)
|
||||
set(CGAL_add_test_included TRUE)
|
||||
|
||||
|
||||
# Process a list, and replace items contains a file pattern (like
|
||||
# `*.off`) by the sublist that corresponds to the globbing of the
|
||||
# pattern in the directory `${CGAL_CURRENT_SOURCE_DIR}`.
|
||||
#
|
||||
#
|
||||
# For example: the `file
|
||||
# test/Poisson_surface_reconstruction_3/poisson_reconstruction_test.cmd`
|
||||
# contains:
|
||||
#
|
||||
# data/*.off data/*.xyz data/*.pwn
|
||||
#
|
||||
# For that file, the list `ARGS` computed in the function
|
||||
# `create_single_source_cgal_program` (see below) is the list:
|
||||
#
|
||||
# data/*.off;data/*.xyz;data/*.pwn
|
||||
#
|
||||
# A call to `expand_list_with_globbing(ARGS)` replaces the list by:
|
||||
#
|
||||
# data/ChineseDragon-10kv.off;data/robocat_deci.off;data/sphere_20k.xyz;data/oni.pwn"
|
||||
#
|
||||
function(expand_list_with_globbing list_name)
|
||||
set(input_list ${${list_name}})
|
||||
# message(STATUS "expand_list_with_globbing(${list_name}), ${list_name} is: ${input_list}")
|
||||
list(LENGTH input_list list_lenght)
|
||||
math(EXPR list_last_n "${list_lenght} - 1")
|
||||
set(output_list)
|
||||
foreach(n RANGE ${list_last_n})
|
||||
# message(STATUS "n=${n}")
|
||||
list(GET input_list ${n} item_n)
|
||||
# message(STATUS "argument ${n} is ${item_n}")
|
||||
if(item_n MATCHES ".*\\*.*")
|
||||
file(GLOB files RELATIVE ${CGAL_CURRENT_SOURCE_DIR} ${item_n})
|
||||
list(APPEND output_list ${files})
|
||||
else()
|
||||
list(APPEND output_list ${item_n})
|
||||
endif()
|
||||
# message(STATUS " new value of the output list: ${output_list}")
|
||||
endforeach()
|
||||
set(${list_name} ${output_list} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(cgal_add_test exe_name)
|
||||
set(cin_file "${CGAL_CURRENT_SOURCE_DIR}/${exe_name}.cin")
|
||||
if(EXISTS ${cin_file})
|
||||
add_test(NAME ${exe_name}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DCMD:STRING=$<TARGET_FILE:${exe_name}>
|
||||
-DCIN:STRING=${cin_file}
|
||||
-P "${CGAL_MODULES_DIR}/run_test_with_cin.cmake")
|
||||
# message(STATUS "add test: ${exe_name} < ${cin_file}")
|
||||
else()
|
||||
# TODO: deal with shell globbing; if the `cmd` file contains
|
||||
# a `*`, then interprete the command using bash.
|
||||
if(ARGV2)
|
||||
set(cmd_file "${CGAL_CURRENT_SOURCE_DIR}/${ARGV2}.cmd")
|
||||
elseif(ARGV1 AND NOT EXISTS ${cmd_file})
|
||||
set(cmd_file "${CGAL_CURRENT_SOURCE_DIR}/${ARGV1}.cmd")
|
||||
elseif(NOT EXISTS ${cmd_file})
|
||||
set(cmd_file "${CGAL_CURRENT_SOURCE_DIR}/${exe_name}.cmd")
|
||||
endif()
|
||||
if(EXISTS ${cmd_file})
|
||||
file(STRINGS "${cmd_file}" CMD_LINES)
|
||||
set(ARGS)
|
||||
# message(STATUS "DEBUG test ${exe_name}")
|
||||
foreach(CMD_LINE ${CMD_LINES})
|
||||
# message(STATUS " command line: ${CMD_LINE}")
|
||||
separate_arguments(CMD_LINE_ARGS UNIX_COMMAND ${CMD_LINE})
|
||||
# message(STATUS " args: ${CMD_LINE_ARGS}")
|
||||
list(APPEND ARGS ${CMD_LINE_ARGS})
|
||||
endforeach()
|
||||
expand_list_with_globbing(ARGS)
|
||||
endif()
|
||||
# message(STATUS "add test: ${exe_name} ${ARGS}")
|
||||
add_test(NAME ${exe_name} COMMAND ${exe_name} ${ARGS})
|
||||
endif()
|
||||
set_property(TEST "${exe_name}"
|
||||
APPEND PROPERTY LABELS "${PROJECT_NAME}")
|
||||
# message(STATUS " working dir: ${CGAL_CURRENT_SOURCE_DIR}")
|
||||
set_property(TEST "${exe_name}"
|
||||
PROPERTY WORKING_DIRECTORY ${CGAL_CURRENT_SOURCE_DIR})
|
||||
|
||||
return()
|
||||
|
||||
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cin")
|
||||
set(ARGS "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cin")
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV2}.cmd")
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV2}.cmd"
|
||||
ARGS LIMIT_COUNT 1)
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV1}.cmd")
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/${ARGV1}.cmd"
|
||||
ARGS LIMIT_COUNT 1)
|
||||
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cmd")
|
||||
file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/${exe_name}.cmd"
|
||||
ARGS LIMIT_COUNT 1)
|
||||
# TODO: handle multi-lines .cmd files
|
||||
# see https://github.com/CGAL/cgal/pull/1295/files/c65d3abe17bb3e677b8077996cdaf8672f9c4c6f#r71705451
|
||||
endif()
|
||||
string(REPLACE ";" " " args_str "${ARGS}")
|
||||
add_test(NAME ${exe_name}
|
||||
COMMAND ${exe_name} ${ARGS}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
set_property(TEST "${exe_name}"
|
||||
APPEND PROPERTY LABELS "${PROJECT_NAME}")
|
||||
endfunction()
|
||||
|
|
@ -9,6 +9,11 @@ include(${CGAL_MODULES_DIR}/CGAL_Macros.cmake)
|
|||
|
||||
cgal_setup_module_path()
|
||||
|
||||
# Save the current source directory. That variable can be changed by
|
||||
# a `CMakeLists.txt`, for `CMakeLists.txt` files that are created in
|
||||
# the binary directory.
|
||||
set(CGAL_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
if(NOT USE_CGAL_FILE_INCLUDED)
|
||||
set(USE_CGAL_FILE_INCLUDED 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
if(NOT CMD OR NOT EXISTS ${CMD})
|
||||
message(FATAL_ERROR
|
||||
"The variable `CMD` should be defined to the test program to run!")
|
||||
endif()
|
||||
|
||||
if(NOT CIN OR NOT EXISTS ${CIN})
|
||||
message(FATAL_ERROR
|
||||
"The variable `CIN` should be defined to the input file for the test!")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND ${CMD}
|
||||
INPUT_FILE ${CIN}
|
||||
RESULT_VARIABLE error_result)
|
||||
|
||||
if(error_result)
|
||||
message(SEND_ERROR
|
||||
"The test `${CMD} < ${CIN}` ended with the error code ${error_result}.")
|
||||
endif()
|
||||
|
|
@ -40,6 +40,11 @@ if ( CGAL_FOUND )
|
|||
|
||||
create_single_source_cgal_program( "test_use_h.cpp" )
|
||||
|
||||
create_single_source_cgal_program( will_fail.cpp will_fail_aux.cpp )
|
||||
if(BUILD_TESTING)
|
||||
set_property(TEST will_fail PROPERTY WILL_FAIL TRUE)
|
||||
endif()
|
||||
|
||||
find_package( TBB QUIET )
|
||||
if( TBB_FOUND )
|
||||
include(${TBB_USE_FILE})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
#include <cstdlib>
|
||||
|
||||
int f() {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
extern int f();
|
||||
int main() { return f(); }
|
||||
|
|
@ -58,6 +58,10 @@ if ( CGAL_FOUND )
|
|||
include( CGAL_CreateSingleSourceCGALProgram )
|
||||
|
||||
EOF
|
||||
if [ -d "${SOURCE_DIR}" ] ; then
|
||||
echo " set(CGAL_CURRENT_SOURCE_DIR \"${SOURCE_DIR}\")"
|
||||
echo
|
||||
fi
|
||||
if [ -d "${SOURCE_DIR}../../include" ] ; then
|
||||
echo " include_directories (BEFORE \"${SOURCE_DIR}../../include\")"
|
||||
echo
|
||||
|
|
|
|||
Loading…
Reference in New Issue