diff --git a/.travis.yml b/.travis.yml index 2195a02646c..a2255ecc567 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt index 1825ea2c757..1ca5fea8e19 100644 --- a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/CMakeLists.txt @@ -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() diff --git a/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake new file mode 100644 index 00000000000..110d1bfda3f --- /dev/null +++ b/Arrangement_on_surface_2/test/Arrangement_on_surface_2/cgal_test.cmake @@ -0,0 +1,1367 @@ +#! /bin/bash + +# This is a script for the CGAL test suite. Such a script must obey +# the following rules: +# +# - the name of the script is cgal_test +# - for every target two one line messages are written to the file 'error.txt' +# the first one indicates if the compilation was successful +# the second one indicates if the execution was successful +# if one of the two was not successful, the line should start with 'ERROR:' +# - running the script should not require any user interaction +# - the script should clean up object files and executables + +# SET PARAMETERS FOR cgal_test + +include(CGAL_add_test) + +function(cgal_debug_message) +# message(${ARGN}) +endfunction() + +set(ERRORFILE error.txt) +set(DO_RUN y) + +set(FULL_ERROR_DESCRIPTION_FILE ProgramOutput.error.txt) + +#---------------------------------------------------------------------# +# compile_and_run +#---------------------------------------------------------------------# + +# note that these values shloud match to the values in test_configuration.h file + +set(CARTESIAN_KERNEL 0) +set(SIMPLE_CARTESIAN_KERNEL 1) +set(UNIVARIATE_ALGEBRAIC_KERNEL 2) + +set(SEGMENT_GEOM_TRAITS 0) +set(NON_CACHING_SEGMENT_GEOM_TRAITS 1) +set(POLYLINE_GEOM_TRAITS 2) +set(NON_CACHING_POLYLINE_GEOM_TRAITS 3) +set(POLYCURVE_CONIC_GEOM_TRAITS 14) +set(POLYCURVE_CIRCULAR_ARC_GEOM_TRAITS 15) +set(POLYCURVE_BEZIER_GEOM_TRAITS 16) +set(LINEAR_GEOM_TRAITS 4) +set(CORE_CONIC_GEOM_TRAITS 5) +set(LINE_ARC_GEOM_TRAITS 6) +set(CIRCULAR_ARC_GEOM_TRAITS 7) +set(CIRCULAR_LINE_ARC_GEOM_TRAITS 8) +set(CIRCLE_SEGMENT_GEOM_TRAITS 9) +set(BEZIER_GEOM_TRAITS 10) +set(GEODESIC_ARC_ON_SPHERE_GEOM_TRAITS 11) +set(RATIONAL_ARC_GEOM_TRAITS 12) +set(ALGEBRAIC_GEOM_TRAITS 13) +set(POLYCURVE_CONIC_GEOM_TRAITS 14) +set(POLYCURVE_CIRCULAR_ARC_GEOM_TRAITS 15) +set(POLYCURVE_BEZIER_GEOM_TRAITS 16) +set(FLAT_TORUS_GEOM_TRAITS 17) + +set(PLANAR_BOUNDED_TOPOL_TRAITS 0) +set(PLANAR_UNBOUNDED_TOPOL_TRAITS 1) +set(SPHERICAL_TOPOL_TRAITS 2) + +set(DOUBLE_NT 0) +set(MP_FLOAT_NT 1) +set(GMPZ_NT 2) +set(LEDA_RAT_NT 3) +set(QUOTIENT_MP_FLOAT_NT 4) +set(QUOTIENT_CGAL_GMPZ_NT 5) +set(CGAL_GMPQ_NT 6) +set(LAZY_LEDA_RAT_NT 7) +set(LAZY_CGAL_GMPQ_NT 8) +set(LAZY_QUOTIENT_MP_FLOAT_NT 9) +set(LEDA_REAL_NT 10) +set(CORE_EXPR_NT 11) +set(LAZY_GMPZ_NT 12) +set(LEDA_INT_NT 13) +set(CGAL_GMPZ_NT 14) +set(CORE_INT_NT 15) +set(CORE_RAT_NT 16) + +if($ENV{CGAL_DISABLE_GMP}) + message(STATUS "GMP is disable. Try to use LEDA instead.") + set(GMPZ_NT ${LEDA_INT_NT}) + set(QUOTIENT_CGAL_GMPZ_NT ${LEDA_RAT_NT}) + set(CGAL_GMPQ_NT ${LEDA_RAT_NT}) + set(LAZY_CGAL_GMPQ_NT ${LAZY_LEDA_RAT_NT}) + set(LAZY_GMPZ_NT ${LAZY_LEDA_RAT_NT}) + set(CGAL_GMPZ_NT ${LEDA_INT_NT}) +endif() + +set(COMPARE 1) +set(VERTEX 2) +set(IS_VERTICAL 3) +set(COMPARE_Y_AT_X 4) +set(COMPARE_Y_AT_X_LEFT 5) +set(COMPARE_Y_AT_X_RIGHT 6) +set(MAKE_X_MONOTONE 7) +set(INTERSECT 8) +set(SPLIT 9) +set(ARE_MERGEABLE 10) +set(MERGE 11) +set(ASSERTIONS 12) +set(CONSTRUCTOR 13) +set(COMPARE_X_AT_LIMIT 14) +set(COMPARE_X_NEAR_LIMIT 15) +set(COMPARE_X_ON_BOUNDARY 16) +set(COMPARE_X_NEAR_BOUNDARY 17) +set(COMPARE_Y_NEAR_BOUNDARY 18) +set(PARAMETER_SPACE_X 19) +set(PARAMETER_SPACE_Y 20) +set(X_ON_IDENTIFICATION 21) +set(Y_ON_IDENTIFICATION 22) +set(IS_BOUNDED 23) +set(IS_IN_X_RANGE 24) +set(COMPARE_Y_POSITION 25) +set(IS_BETWEEN_CW 26) +set(COMPARE_CW_AROUND_POINT 27) +set(PUSH_BACK 28) +set(PUSH_FRONT 29) +set(NUMBER_OF_POINTS 32) +set(COMPARE_ENDPOINTS_XY 33) +set(CONSTRUCT_OPPOSITE 34) +set(TRIM 35) + +#---------------------------------------------------------------------# +# configure +#---------------------------------------------------------------------# + +function(configure type) + cgal_debug_message(STATUS "---> cmake with -DCGAL_CXX_FLAGS:STRING=\"${TESTSUITE_CXXFLAGS}\"") +# string(REPLACE "-DTEST_" "" suffix "${TESTSUITE_CXXFLAGS}") +# string(REPLACE "KERNEL" "K" suffix "${suffix}") +# string(REPLACE "GEOM_TRAITS" "GT" suffix "${suffix}") +# string(REPLACE "-DCGAL_ARR_POINT_LOCATION" "POINT_LOCATION" suffix "${suffix}") +# string(MAKE_C_IDENTIFIER "${suffix}" suffix) +# cgal_debug_message(STATUS " suffix: ${suffix}") +# set(suffix ${suffix} PARENT_SCOPE) + set(suffix ${type} PARENT_SCOPE) +endfunction() + +function(compile_test_with_flags name type flags) + cgal_debug_message(STATUS "# compile_test_with_flags(${name} ${type} \"${flags}\" ${ARGN})") + set(TESTSUITE_CXXFLAGS "${flags}") + set(TESTSUITE_CXXFLAGS "${flags}" PARENT_SCOPE) +# message(" successful configuration") +# message(" successful compilation of ${name} ${type}") + if(ARGV3) + configure(${ARGV3}) + else() + configure(${type}) + endif() + set(suffix ${suffix} PARENT_SCOPE) +# set(suffix ${type}) + cgal_arr_2_add_target(${name} ${name}.cpp) +endfunction() + +function(cgal_arr_2_add_target exe_name source_file) + cgal_debug_message(STATUS "# cgal_arr_2_add_target(${ARGN})") + if(suffix) + set(name ${exe_name}_${suffix}) + endif() + add_executable(${name} ${source_file}) + separate_arguments(flags UNIX_COMMAND "${TESTSUITE_CXXFLAGS}") + target_compile_options(${name} PRIVATE ${flags}) + cgal_debug_message(STATUS "# -> target ${name} with TESTSUITE_CXXFLAGS: ${flags}") + + # Add a compatibility-mode with the shell script `cgal_test_base` + if(NOT TARGET ${exe_name}) + create_single_source_cgal_program( "${source_file}" ) + endif() +endfunction() + +function(run_test name) + # ${ARGV0} - executable name + cgal_debug_message(STATUS "# run_test(${ARGN})") + cgal_arr_2_add_target(${name} ${ARGN}) +endfunction() + +function(run_test_with_flags) + # ${ARGV0} - executable name + # ${ARGV1} - test substring name + cgal_debug_message(STATUS "# run_test_with_flags(${ARGN})") + cgal_add_test(${ARGV0}_${suffix} ${ARGV0} ${ARGV0}.${ARGV1}) +endfunction() + +function(run_test_alt name datafile) + if(suffix) + set(name ${name}_${suffix}) + endif() + cgal_debug_message(STATUS "# run_test_alt(${ARGN})") + cgal_debug_message(STATUS "# -> ./${name} ${datafile} ${ARGN}") + set(command ${name} ${datafile} ${ARGN}) + string(MAKE_C_IDENTIFIER "${name} ${ARGV4} ${ARGV5}" test_name) + add_test(NAME ${test_name} COMMAND ${command} + WORKING_DIRECTORY ${CGAL_CURRENT_SOURCE_DIR}) +# message(" successful execution of ${name} ${ARGV4} ${ARGV5}") + set_property(TEST "${test_name}" + APPEND PROPERTY LABELS "${PROJECT_NAME}") + cgal_debug_message(STATUS "add test \"${test_name}\": ${name} ${datafile} ${ARGN}") +endfunction() + +function(run_trapped_test name datafile) + cgal_debug_message(STATUS "# run_trapped_test(${name} ${datafile} ${ARGN})") + run_test_alt(${name} ${datafile} ${ARGN}) +endfunction() + +function(compile_and_run) + set(name ${ARGV0}) + cgal_debug_message(STATUS "# compile_and_run(${ARGN})") +# message(" successful compilation of ${name}") + cgal_arr_2_add_target(${name} ${name}.cpp) + cgal_add_test(${name}) +endfunction() + +function(execute_commands_old_structure data_dir traits_type_name) + cgal_debug_message(STATUS "# execute_commands_old_structure(data_dir=${data_dir} traits=${traits_type_name} ${ARGN})") + # at first the tests where designed in such way that all the test input was + # in one file, the points, the xcurves, the curves and the execution block + # this function is used to execute the old tests, one may use it when needed + # but you should remember that separating the input into smaller files creates + # much more modular and comfortable test suite + + # the old structure is default, so this function executes all commands + # except the commands that are given as arguments + + set(commands_indicator_COMPARE 1) + set(commands_indicator_VERTEX 1) + set(commands_indicator_IS_VERTICAL 1) + set(commands_indicator_COMPARE_Y_AT_X 1) + set(commands_indicator_COMPARE_Y_AT_X_LEFT 1) + set(commands_indicator_COMPARE_Y_AT_X_RIGHT 1) + set(commands_indicator_MAKE_X_MONOTONE 1) + set(commands_indicator_INTERSECT 1) + set(commands_indicator_SPLIT 1) + set(commands_indicator_ARE_MERGEABLE 1) + set(commands_indicator_MERGE 1) + set(commands_indicator_ASSERTIONS 1) + set(commands_indicator_CONSTRUCTOR 1) + foreach(arg ${ARGN}) + set(commands_indicator_${arg} 0) + endforeach() + if(commands_indicator_COMPARE) + run_trapped_test(test_traits + data/compare.pt data/empty.zero + data/empty.zero data/compare ${traits_type_name}) + endif() + if(commands_indicator_VERTEX) + run_trapped_test(test_traits + data/${data_dir}/vertex.pt data/${data_dir}/vertex.xcv + data/empty.zero data/${data_dir}/vertex ${traits_type_name}) + endif() + if(commands_indicator_IS_VERTICAL) + run_trapped_test(test_traits + data/empty.zero data/${data_dir}/is_vertical.xcv data/empty.zero + data/${data_dir}/is_vertical ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_Y_AT_X) + run_trapped_test(test_traits + data/${data_dir}/compare_y_at_x.pt data/${data_dir}/compare_y_at_x.xcv + data/empty.zero data/${data_dir}/compare_y_at_x ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_Y_AT_X_LEFT) + run_trapped_test(test_traits + data/${data_dir}/compare_y_at_x_left.pt data/${data_dir}/compare_y_at_x_left.xcv + data/empty.zero data/${data_dir}/compare_y_at_x_left ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_Y_AT_X_RIGHT) + run_trapped_test(test_traits + data/${data_dir}/compare_y_at_x_right.pt data/${data_dir}/compare_y_at_x_right.xcv + data/empty.zero data/${data_dir}/compare_y_at_x_right ${traits_type_name}) + endif() + if(commands_indicator_MAKE_X_MONOTONE) + run_trapped_test(test_traits + data/empty.zero data/${data_dir}/make_x_monotone.xcv + data/${data_dir}/make_x_monotone.cv data/${data_dir}/make_x_monotone ${traits_type_name}) + endif() + if(commands_indicator_INTERSECT) + run_trapped_test(test_traits + data/${data_dir}/intersect.pt data/${data_dir}/intersect.xcv + data/empty.zero data/${data_dir}/intersect ${traits_type_name}) + endif() + if(commands_indicator_SPLIT) + run_trapped_test(test_traits + data/${data_dir}/split.pt data/${data_dir}/split.xcv + data/empty.zero data/${data_dir}/split ${traits_type_name}) + endif() + if(commands_indicator_ARE_MERGEABLE) + run_trapped_test(test_traits + data/empty.zero data/${data_dir}/are_mergeable.xcv + data/empty.zero data/${data_dir}/are_mergeable ${traits_type_name}) + endif() + if(commands_indicator_MERGE) + run_trapped_test(test_traits + data/empty.zero data/${data_dir}/merge.xcv + data/empty.zero data/${data_dir}/merge ${traits_type_name}) + endif() + if(commands_indicator_ASSERTIONS) + run_trapped_test(test_traits + data/${data_dir}/assertions.pt data/${data_dir}/assertions.xcv + data/empty.zero data/${data_dir}/assertions ${traits_type_name}) + endif() + if(commands_indicator_CONSTRUCTOR) + run_trapped_test(test_traits + data/empty.zero data/${data_dir}/constructor.xcv + data/${data_dir}/constructor.cv data/${data_dir}/constructor ${traits_type_name}) + endif() +endfunction() + +function(execute_commands_new_structure data_dir traits_type_name) + cgal_debug_message(STATUS "# execute_commands_new_structure(data_dir=${data_dir} traits=${traits_type_name} ${ARGN} )") +# the new design for the tests includes separation of the test input into 4 +# parts: points file, xcurves file, curves file and execution block file. +# one may reuse the input files for the various tests + +# the new structure is not default, so this function executes only +# commands that are given as arguments + + set(commands_indicator_COMPARE 0) + set(commands_indicator_VERTEX 0) + set(commands_indicator_IS_VERTICAL 0) + set(commands_indicator_COMPARE_X_AT_LIMIT 0) + set(commands_indicator_COMPARE_X_NEAR_LIMIT 0) + set(commands_indicator_COMPARE_X_ON_BOUNDARY 0) + set(commands_indicator_COMPARE_X_NEAR_BOUNDARY 0) + set(commands_indicator_COMPARE_Y_NEAR_BOUNDARY 0) + set(commands_indicator_PARAMETER_SPACE_X 0) + set(commands_indicator_PARAMETER_SPACE_Y 0) + set(commands_indicator_COMPARE_Y_AT_X 0) + set(commands_indicator_COMPARE_Y_AT_X_LEFT 0) + set(commands_indicator_COMPARE_Y_AT_X_RIGHT 0) + set(commands_indicator_MAKE_X_MONOTONE 0) + set(commands_indicator_INTERSECT 0) + set(commands_indicator_SPLIT 0) + set(commands_indicator_ARE_MERGEABLE 0) + set(commands_indicator_MERGE 0) + set(commands_indicator_ASSERTIONS 0) + set(commands_indicator_CONSTRUCTOR 0) + set(commands_indicator_EQUAL 0) + set(commands_indicator_PUSH_BACK 0) + set(commands_indicator_PUSH_FRONT 0) + set(commands_indicator_NUMBER_OF_POINTS 0) + set(commands_indicator_COMPARE_ENDPOINTS_XY 0) + set(commands_indicator_CONSTRUCT_OPPOSITE 0) + set(commands_indicator_TRIM 0) + foreach(arg ${ARGN}) + set(commands_indicator_${arg} 1) + endforeach() + if(commands_indicator_COMPARE) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare ${traits_type_name}) + endif() + if(commands_indicator_VERTEX) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/vertex ${traits_type_name}) + endif() + if(commands_indicator_IS_VERTICAL) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/is_vertical ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_X_AT_LIMIT) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare_x_at_limit ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_X_NEAR_LIMIT) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare_x_near_limit ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_X_ON_BOUNDARY) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare_x_on_boundary ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_X_NEAR_BOUNDARY) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare_x_near_boundary ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_Y_NEAR_BOUNDARY) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare_y_near_boundary ${traits_type_name}) + endif() + if(commands_indicator_PARAMETER_SPACE_X) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/parameter_space_x ${traits_type_name}) + endif() + if(commands_indicator_PARAMETER_SPACE_Y) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/parameter_space_y ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_Y_AT_X) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare_y_at_x ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_Y_AT_X_LEFT) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare_y_at_x_left ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_Y_AT_X_RIGHT) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare_y_at_x_right ${traits_type_name}) + endif() + if(commands_indicator_MAKE_X_MONOTONE) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/make_x_monotone ${traits_type_name}) + endif() + if(commands_indicator_INTERSECT) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/intersect ${traits_type_name}) + endif() + if(commands_indicator_SPLIT) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/split ${traits_type_name}) + endif() + if(commands_indicator_ARE_MERGEABLE) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/are_mergeable ${traits_type_name}) + endif() + if(commands_indicator_MERGE) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/merge ${traits_type_name}) + endif() + if(commands_indicator_ASSERTIONS) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/assertions ${traits_type_name}) + endif() + if(commands_indicator_CONSTRUCTOR) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/constructor ${traits_type_name}) + endif() + if(commands_indicator_EQUAL) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/equal ${traits_type_name}) + endif() + if(commands_indicator_PUSH_BACK) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/push_back ${traits_type_name}) + endif() + if(commands_indicator_PUSH_FRONT) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/push_front ${traits_type_name}) + endif() + if(commands_indicator_NUMBER_OF_POINTS) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/number_of_points ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_ENDPOINTS_XY) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/compare_endpoints_xy ${traits_type_name}) + endif() + if(commands_indicator_CONSTRUCT_OPPOSITE) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/construct_opposite ${traits_type_name}) + endif() + if(commands_indicator_TRIM) + run_trapped_test(test_traits data/${data_dir}/points + data/${data_dir}/xcurves data/${data_dir}/curves data/${data_dir}/trim ${traits_type_name}) + endif() +endfunction() + +function(execute_commands_traits_adaptor data_dir traits_type_name) + cgal_debug_message(STATUS "# execute_commands_traits_adaptor(data_dir=${data_dir} traits=${traits_type_name} ${ARGN} )") +# the new structure is not default, so this function executes only +# commands that are given as arguments + + set(commands_indicator_PARAMETER_SPACE_X 0) + set(commands_indicator_PARAMETER_SPACE_Y 0) + set(commands_indicator_COMPARE_X_AT_LIMIT 0) + set(commands_indicator_COMPARE_X_NEAR_LIMIT 0) + set(commands_indicator_COMPARE_X_ON_BOUNDARY 0) + set(commands_indicator_COMPARE_X_NEAR_BOUNDARY 0) + set(commands_indicator_COMPARE_Y_NEAR_BOUNDARY 0) + set(commands_indicator_COMPARE_Y_AT_X_LEFT 0) + set(commands_indicator_ARE_MERGEABLE 0) + set(commands_indicator_MERGE 0) + set(commands_indicator_X_ON_IDENTIFICATION 0) + set(commands_indicator_Y_ON_IDENTIFICATION 0) + set(commands_indicator_IS_BOUNDED 0) + set(commands_indicator_IS_IN_X_RANGE 0) + set(commands_indicator_COMPARE_Y_POSITION 0) + set(commands_indicator_IS_BETWEEN_CW 0) + set(commands_indicator_COMPARE_CW_AROUND_POINT 0) + foreach(arg ${ARGN}) + set(commands_indicator_${arg} 1) + endforeach() + + if(commands_indicator_PARAMETER_SPACE_X) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/parameter_space_x ${traits_type_name}) + endif() + if(commands_indicator_PARAMETER_SPACE_Y) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/parameter_space_y ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_X_AT_LIMIT) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/compare_x_at_limit ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_X_NEAR_LIMIT) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/compare_x_near_limit ${traits_type_name}) + endif() + + if(commands_indicator_COMPARE_X_ON_BOUNDARY) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/compare_x_on_boundary ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_X_NEAR_BOUNDARY) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/compare_x_near_boundary ${traits_type_name}) + endif() + + if(commands_indicator_COMPARE_Y_NEAR_BOUNDARY) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/compare_y_near_boundary ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_Y_AT_X_LEFT) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/compare_y_at_x_left ${traits_type_name}) + endif() + if(commands_indicator_ARE_MERGEABLE) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/are_mergeable ${traits_type_name}) + endif() + if(commands_indicator_MERGE) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/merge ${traits_type_name}) + endif() + if(commands_indicator_X_ON_IDENTIFICATION) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/x_on_idintification ${traits_type_name}) + endif() + if(commands_indicator_Y_ON_IDENTIFICATION) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/x_on_idintification ${traits_type_name}) + endif() + if(commands_indicator_IS_BOUNDED) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/is_bounded ${traits_type_name}) + endif() + if(commands_indicator_IS_IN_X_RANGE) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/is_in_x_range ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_Y_POSITION) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/compare_y_position ${traits_type_name}) + endif() + if(commands_indicator_IS_BETWEEN_CW) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/is_between_cw ${traits_type_name}) + endif() + if(commands_indicator_COMPARE_CW_AROUND_POINT) + run_trapped_test(test_traits_adaptor data/test_adaptor/${data_dir}/points + data/test_adaptor/${data_dir}/xcurves data/test_adaptor/${data_dir}/curves + data/test_adaptor/${data_dir}/compare_cw_around_point ${traits_type_name}) + endif() +endfunction() + +#---------------------------------------------------------------------# +# traits adaptor (segments traits) +#---------------------------------------------------------------------# +function(test_segment_traits_adaptor) + set(nt ${QUOTIENT_MP_FLOAT_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits_adaptor segments "${flags}") +# if [ -n "${SUCCESS}" ] ; then + execute_commands_traits_adaptor( segments segments_traits_adaptor + COMPARE_Y_POSITION COMPARE_CW_AROUND_POINT COMPARE_Y_AT_X_LEFT + ARE_MERGEABLE MERGE IS_IN_X_RANGE IS_BETWEEN_CW) +endfunction() + +#---------------------------------------------------------------------# +# traits adaptor (linear traits) +#---------------------------------------------------------------------# +function(test_linear_traits_adaptor) + set(nt ${QUOTIENT_MP_FLOAT_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${LINEAR_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags( test_traits_adaptor linear "${flags}") + + execute_commands_traits_adaptor( linear linear_traits_adaptor + COMPARE_Y_AT_X_LEFT ARE_MERGEABLE MERGE IS_IN_X_RANGE + COMPARE_Y_POSITION IS_BETWEEN_CW COMPARE_CW_AROUND_POINT) +endfunction() + +#---------------------------------------------------------------------# +# traits adaptor (spherical arcs traits) +#---------------------------------------------------------------------# +function(test_spherical_arcs_traits_adaptor) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${GEODESIC_ARC_ON_SPHERE_GEOM_TRAITS}) + set(topol_traits ${SPHERICAL_TOPOL_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DTEST_TOPOL_TRAITS=${topol_traits}") + + compile_test_with_flags( test_traits_adaptor geodesic_arcs_on_sphere "${flags}") + + execute_commands_traits_adaptor( spherical_arcs spherical_arcs_traits_adaptor + COMPARE_Y_AT_X_LEFT ARE_MERGEABLE MERGE IS_IN_X_RANGE + COMPARE_Y_POSITION IS_BETWEEN_CW COMPARE_CW_AROUND_POINT) +endfunction() + +#---------------------------------------------------------------------# +# compile and run test with traits +#---------------------------------------------------------------------# +function(compile_and_run_with_flags name type flags) + compile_test_with_flags( ${name} ${type} "${flags}" ${ARGN}) +# if [ -n "${SUCCESS}" ] ; then +# if [ -n "${DO_RUN}" ] ; then + run_test_with_flags( ${name} ${type}) +# fi +# else +# echo " ERROR: not executed construction of segments" >> ${ERRORFILE} +# fi +# clean_tests +endfunction() + +#---------------------------------------------------------------------# +# construction with segments +#---------------------------------------------------------------------# +function(test_construction_segments) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags( test_construction segments "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# construction with linear curves +#---------------------------------------------------------------------# +function(test_construction_linear_curves) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${LINEAR_GEOM_TRAITS}) + set(topol_traits ${PLANAR_UNBOUNDED_TOPOL_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DTEST_TOPOL_TRAITS=${topol_traits}") + compile_and_run_with_flags( test_construction linear "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# construction with geodesic arcs on the sphere +#---------------------------------------------------------------------# +function(test_construction_spherical_arcs) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${GEODESIC_ARC_ON_SPHERE_GEOM_TRAITS}) + set(topol_traits ${SPHERICAL_TOPOL_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DTEST_TOPOL_TRAITS=${topol_traits}") + compile_and_run_with_flags( test_construction geodesic_arcs_on_sphere "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# overlay with segments +#---------------------------------------------------------------------# +function(test_overlay_segments) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags(test_overlay segments "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# overlay with geodesic arcs on the sphere +#---------------------------------------------------------------------# +function(test_overlay_spherical_arcs) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${GEODESIC_ARC_ON_SPHERE_GEOM_TRAITS}) + set(topol_traits ${SPHERICAL_TOPOL_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DTEST_TOPOL_TRAITS=${topol_traits}") + compile_and_run_with_flags(test_overlay geodesic_arcs_on_sphere "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# point location with segments +#---------------------------------------------------------------------# +function(test_point_location_segments) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags(test_point_location segments "${flags}" segments) +endfunction() + +# For backward compatibility +function(test_point_location_segments_version) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DCGAL_ARR_POINT_LOCATION_VERSION=1") + compile_and_run_with_flags(test_point_location segments "${flags}" segments_version) +endfunction() + +# For backward compatibility +function(test_point_location_segments_conversion) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DCGAL_ARR_POINT_LOCATION_CONVERSION") + compile_and_run_with_flags(test_point_location segments "${flags}" segment_conversion) +endfunction() + +#---------------------------------------------------------------------# +# point location dynamic with segments +#---------------------------------------------------------------------# +function(test_point_location_dynamic_segments) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags(test_point_location_dynamic segments "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# point location with circle segments +#---------------------------------------------------------------------# +function(test_point_location_circle_segments) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${CIRCLE_SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags(test_point_location circle_segments "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# point location with linear objects +#---------------------------------------------------------------------# +function(test_point_location_linear) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${LINEAR_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags(test_point_location linear "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# batchecd point location with segments +#---------------------------------------------------------------------# +function(test_batched_point_location_segments) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags(test_batched_point_location segments "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# batchecd point location with linear objects +#---------------------------------------------------------------------# +function(test_batched_point_location_linear) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${LINEAR_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags(test_batched_point_location linear "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# batchecd point location with geodesic arcs on the sphere +#---------------------------------------------------------------------# +function(test_batched_point_location_spherical_arcs) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${GEODESIC_ARC_ON_SPHERE_GEOM_TRAITS}) + set(topol_traits ${SPHERICAL_TOPOL_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DTEST_TOPOL_TRAITS=${topol_traits}") + compile_and_run_with_flags(test_batched_point_location geodesic_arcs_on_sphere "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# vertical decomposition with segments +#---------------------------------------------------------------------# +function(test_vertical_decomposition_segments) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags(test_vertical_decomposition segments "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# vertical decomposition with linear objects +#---------------------------------------------------------------------# +function(test_vertical_decomposition_linear) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${LINEAR_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + compile_and_run_with_flags(test_vertical_decomposition linear "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# vertical decomposition with geodesic arcs on the sphere +#---------------------------------------------------------------------# +function(test_vertical_decomposition_spherical_arcs) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${LINEAR_GEOM_TRAITS}) + set(topol_traits ${SPHERICAL_TOPOL_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DTEST_TOPOL_TRAITS=${topol_traits}") + compile_and_run_with_flags(test_vertical_decomposition geodesic_arcs_on_sphere "${flags}") +endfunction() + +#---------------------------------------------------------------------# +# segment traits +#---------------------------------------------------------------------# +function(test_segment_traits) + set(nt ${QUOTIENT_MP_FLOAT_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits segments "${flags}") + + execute_commands_old_structure( segments segment_traits + VERTEX IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT CONSTRUCTOR + COMPARE_Y_AT_X_RIGHT ARE_MERGEABLE) + + execute_commands_new_structure( segments segment_traits + IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT ARE_MERGEABLE) + + run_trapped_test( test_traits + data/segments/vertex.pt data/segments/xcurves + data/empty.zero data/segments/vertex segment_traits) +endfunction() + +#---------------------------------------------------------------------# +# non-caching segment traits +#---------------------------------------------------------------------# +function(test_non_caching_segment_traits) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${NON_CACHING_SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits non_caching_segments "${flags}") + + execute_commands_old_structure(segments non_caching_segment_traits + VERTEX IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT CONSTRUCTOR + COMPARE_Y_AT_X_RIGHT ARE_MERGEABLE ASSERTIONS) + + execute_commands_new_structure(segments segment_traits + IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT) + + run_trapped_test(test_traits + data/segments/vertex.pt data/segments/xcurves + data/empty.zero data/segments/vertex non_caching_segment_traits) +endfunction() + +#---------------------------------------------------------------------# +# polycurve conic traits +#---------------------------------------------------------------------# +function(test_polycurve_conic_traits) +# echo polycurve test starting + set(nt ${CORE_EXPR_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${POLYCURVE_CONIC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits conic_polycurve "${flags}") + + # The input arguments for the execute_commands_new_structure, + # 1. Polycurve_conics is the directory name in "data" + # 2. polycurve_conic_traits is a string + # Execute_command_new_structure will only run the test on functors provided as the third, fourth and so on arguments. + # To see how the input data directory should be structured for each functor, check the execute_commands_new_structure function in this file. + execute_commands_new_structure(polycurves_conics polycurve_conic_traits + COMPARE_Y_AT_X + INTERSECT + EQUAL + IS_VERTICAL + SPLIT + ARE_MERGEABLE + COMPARE_Y_AT_X_LEFT + COMPARE_Y_AT_X_RIGHT + MAKE_X_MONOTONE + PUSH_BACK + PUSH_FRONT + NUMBER_OF_POINTS + VERTEX + CONSTRUCT_OPPOSITE + MERGE + COMPARE_ENDPOINTS_XY + TRIM) + +endfunction() + +#---------------------------------------------------------------------# +# polycurve arc traits +#---------------------------------------------------------------------# +function(test_polycurve_circular_arc_traits) + set(nt ${QUOTIENT_MP_FLOAT_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${POLYCURVE_CIRCULAR_ARC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits circular_arc_polycurve "${flags}") + + execute_commands_new_structure(Polycurves_circular_arcs polycurve_circular_arc_traits + COMPARE_Y_AT_X + EQUAL + IS_VERTICAL + SPLIT + ARE_MERGEABLE + COMPARE_Y_AT_X_LEFT + COMPARE_Y_AT_X_RIGHT + MAKE_X_MONOTONE + PUSH_BACK + PUSH_FRONT + NUMBER_OF_POINTS + VERTEX + CONSTRUCT_OPPOSITE + MERGE + COMPARE_ENDPOINTS_XY + INTERSECT) +endfunction() + +#---------------------------------------------------------------------# +# polycurve bezier traits +#---------------------------------------------------------------------# +function(test_polycurve_bezier_traits) + set(nt ${CORE_EXPR_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${POLYCURVE_BEZIER_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits bezier_polycurve "${flags}") + + execute_commands_new_structure(Polycurves_bezier test_polycurve_bezier_traits + MERGE + EQUAL + IS_VERTICAL + NUMBER_OF_POINTS + PUSH_BACK + PUSH_FRONT + VERTEX + ARE_MERGEABLE + COMPARE_ENDPOINTS_XY + # TODO (add data for these tests) + # COMPARE_Y_AT_X + # SPLIT + # COMPARE_Y_AT_X_LEFT + # COMPARE_Y_AT_X_RIGHT + # MAKE_X_MONOTONE + # CONSTRUCT_OPPOSITE + + # INTERSECT + ) +endfunction() + +#---------------------------------------------------------------------# +# polyline traits +#---------------------------------------------------------------------# +function(test_polyline_traits) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${POLYLINE_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits test_polylines "${flags}") + + execute_commands_old_structure(polylines polyline_traits + CONSTRUCTOR COMPARE_Y_AT_X_LEFT + COMPARE_Y_AT_X_RIGHT ARE_MERGEABLE) +endfunction() + +#---------------------------------------------------------------------# +# non-caching polyline traits +#---------------------------------------------------------------------# +function(test_non_caching_polyline_traits) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${NON_CACHING_POLYLINE_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits non_caching_polylines "${flags}") + + execute_commands_old_structure(polylines non_caching_polyline_traits + CONSTRUCTOR COMPARE_Y_AT_X_LEFT + COMPARE_Y_AT_X_RIGHT ARE_MERGEABLE) +endfunction() + +#---------------------------------------------------------------------# +# linear traits +#---------------------------------------------------------------------# +function(test_linear_traits) + set(nt ${QUOTIENT_MP_FLOAT_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${LINEAR_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits linear "${flags}") + + execute_commands_old_structure(linear/segments linear_traits.segments + VERTEX IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT + COMPARE_Y_AT_X_RIGHT CONSTRUCTOR ARE_MERGEABLE) + + execute_commands_new_structure(linear/segments linear_traits.segments + IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT) + + run_trapped_test(test_traits + data/linear/segments/vertex.pt data/linear/segments/xcurves + data/empty.zero data/linear/segments/vertex linear_traits.segments) + + execute_commands_old_structure(linear/rays linear_traits.rays + VERTEX IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT + COMPARE_Y_AT_X_RIGHT CONSTRUCTOR ARE_MERGEABLE) + + execute_commands_new_structure(linear/rays linear_traits.rays + IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT) + + run_trapped_test(test_traits + data/linear/rays/vertex.pt data/linear/rays/xcurves + data/empty.zero data/linear/rays/vertex linear_traits.rays) + + execute_commands_new_structure(linear/lines linear_traits.lines + IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT INTERSECT + SPLIT MERGE + PARAMETER_SPACE_X PARAMETER_SPACE_Y + COMPARE_X_AT_LIMIT COMPARE_X_NEAR_LIMIT COMPARE_Y_NEAR_BOUNDARY) +endfunction() + +#---------------------------------------------------------------------# +# conic traits +#---------------------------------------------------------------------# +function(test_conic_traits) + set(nt ${CORE_EXPR_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${CORE_CONIC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits conics "${flags}") + + execute_commands_old_structure(conics conic_traits + INTERSECT SPLIT MERGE COMPARE_Y_AT_X_LEFT + COMPARE_Y_AT_X_RIGHT ARE_MERGEABLE) + + execute_commands_new_structure(conics conic_traits + INTERSECT SPLIT MERGE) + + run_trapped_test(test_traits + data/conics/compare.pt data/empty.zero + data/empty.zero data/conics/compare conic_traits) +endfunction() + +#---------------------------------------------------------------------# +# "line arcs" (segments) only +#---------------------------------------------------------------------# +function(test_line_arc_traits) + set(nt ${QUOTIENT_MP_FLOAT_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${LINE_ARC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits line_arcs "${flags}") + + execute_commands_old_structure(circular_lines line_arc_traits + VERTEX IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT + ASSERTIONS COMPARE_Y_AT_X_RIGHT MERGE ARE_MERGEABLE) + + execute_commands_new_structure(circular_lines line_arc_traits + IS_VERTICAL COMPARE_Y_AT_X) + + run_trapped_test(test_traits + data/circular_lines/compare.pt data/empty.zero + data/empty.zero data/circular_lines/compare line_arc_traits) + + run_trapped_test(test_traits + data/circular_lines/vertex.pt data/circular_lines/xcurves + data/empty.zero data/circular_lines/vertex line_arc_traits) +endfunction() + +#---------------------------------------------------------------------# +# circular arcs only +#---------------------------------------------------------------------# +function(test_circular_arc_traits) + set(nt ${QUOTIENT_MP_FLOAT_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${CIRCULAR_ARC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits circular_arcs "${flags}") + + execute_commands_old_structure(circular_arcs circular_arc_traits + VERTEX IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT + ASSERTIONS COMPARE_Y_AT_X_RIGHT MERGE ARE_MERGEABLE) + + execute_commands_new_structure(circular_arcs circular_arc_traits + VERTEX IS_VERTICAL COMPARE_Y_AT_X) +endfunction() + +#---------------------------------------------------------------------# +# circular and line arcs +#---------------------------------------------------------------------# +function(test_circular_line_arc_traits) + set(nt ${QUOTIENT_MP_FLOAT_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${CIRCULAR_LINE_ARC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits circular_line_arcs "${flags}") + + execute_commands_old_structure(circular_line_arcs circular_line_arc_traits + VERTEX IS_VERTICAL CONSTRUCTOR COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT + ASSERTIONS COMPARE_Y_AT_X_RIGHT MERGE ARE_MERGEABLE) + + execute_commands_new_structure(circular_line_arcs circular_line_arc_traits + IS_VERTICAL COMPARE_Y_AT_X) + + run_trapped_test(test_traits + data/circular_line_arcs/vertex.pt data/circular_line_arcs/xcurves + data/empty.zero data/circular_line_arcs/vertex circular_line_arc_traits) +endfunction() + +#---------------------------------------------------------------------# +# circle segment traits +#---------------------------------------------------------------------# +function(test_circle_segments_traits) + set(nt ${QUOTIENT_MP_FLOAT_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${CIRCLE_SEGMENT_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits circle_segments "${flags}") + + execute_commands_old_structure(circle_segments circle_segments_traits + VERTEX IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT + COMPARE_Y_AT_X_RIGHT CONSTRUCTOR ARE_MERGEABLE) + + run_trapped_test(test_traits + data/circle_segments/points data/circle_segments/xcurves.8 + data/empty.zero data/circle_segments/vertex circle_segments_traits) + run_trapped_test(test_traits + data/empty.zero data/circle_segments/xcurves.8 + data/empty.zero data/circle_segments/is_vertical circle_segments_traits) + run_trapped_test(test_traits + data/circle_segments/points data/circle_segments/xcurves.8 + data/empty.zero data/circle_segments/compare_y_at_x circle_segments_traits) + run_trapped_test(test_traits + data/circle_segments/points data/circle_segments/xcurves.16 + data/empty.zero data/circle_segments/compare_y_at_x_left circle_segments_traits) + run_trapped_test(test_traits + data/circle_segments/points data/circle_segments/xcurves.16 + data/empty.zero data/circle_segments/compare_y_at_x_right circle_segments_traits) + run_trapped_test(test_traits + data/empty.zero data/circle_segments/constructor.xcv + data/empty.zero data/circle_segments/constructor circle_segments_traits) +endfunction() + +#---------------------------------------------------------------------# +# bezier traits +#---------------------------------------------------------------------# +function(test_bezier_traits) + set(nt ${CORE_EXPR_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${BEZIER_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits Bezier "${flags}") + + execute_commands_old_structure(bezier bezier_traits + COMPARE_Y_AT_X_LEFT COMPARE_Y_AT_X_RIGHT SPLIT + CONSTRUCTOR ASSERTIONS ARE_MERGEABLE) +endfunction() + +#---------------------------------------------------------------------# +# spherical arc traits +#---------------------------------------------------------------------# +function(test_spherical_arc_traits) + set(nt ${CGAL_GMPQ_NT}) + set(kernel ${CARTESIAN_KERNEL}) + set(geom_traits ${GEODESIC_ARC_ON_SPHERE_GEOM_TRAITS}) + set(topol_traits ${SPHERICAL_TOPOL_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits} -DTEST_TOPOL_TRAITS=${topol_traits}") + + compile_test_with_flags(test_traits geodesic_arcs_on_sphere "${flags}") + + execute_commands_old_structure(spherical_arcs spherical_arc_traits + COMPARE_Y_AT_X_LEFT COMPARE_Y_AT_X_RIGHT INTERSECT + CONSTRUCTOR + COMPARE MAKE_X_MONOTONE SPLIT MERGE ASSERTIONS ARE_MERGEABLE) + + execute_commands_new_structure(spherical_arcs spherical_arc_traits + INTERSECT + COMPARE_X_ON_BOUNDARY COMPARE_X_NEAR_BOUNDARY + COMPARE_Y_NEAR_BOUNDARY) + + run_trapped_test(test_traits + data/spherical_arcs/compare.pt data/spherical_arcs/compare.xcv + data/empty.zero data/spherical_arcs/compare spherical_arc_traits) +endfunction() + +#---------------------------------------------------------------------# +# rational arc traits +#---------------------------------------------------------------------# +function(test_rational_arc_traits) + set(nt ${CORE_INT_NT}) + set(kernel ${UNIVARIATE_ALGEBRAIC_KERNEL}) + set(geom_traits ${RATIONAL_ARC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits rational_arcs "${flags}") + + run_trapped_test(test_traits + data/compare.pt data/empty.zero + data/empty.zero data/compare rational_arc_traits) + + execute_commands_new_structure(rational_arcs rational_arc_traits + VERTEX IS_VERTICAL COMPARE_Y_AT_X COMPARE_Y_AT_X_LEFT SPLIT MERGE + COMPARE_X_AT_LIMIT COMPARE_X_NEAR_LIMIT COMPARE_Y_NEAR_BOUNDARY) +endfunction() + +#---------------------------------------------------------------------# +# algebraic traits with GMP/MPFI +#---------------------------------------------------------------------# +function(test_algebraic_traits_gmp) + #TODO: Adapt + + set(nt ${CGAL_GMPZ_NT}) + set(kernel ${UNIVARIATE_ALGEBRAIC_KERNEL}) + set(geom_traits ${ALGEBRAIC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits algebraic "${flags}" algebraic_traits_gmp) + + execute_commands_new_structure(algebraic algebraic_traits_gmp + COMPARE COMPARE_Y_AT_X COMPARE_Y_AT_X_RIGHT COMPARE_Y_AT_X_LEFT + MAKE_X_MONOTONE IS_VERTICAL VERTEX SPLIT MERGE INTERSECT + PARAMETER_SPACE_X PARAMETER_SPACE_Y) +endfunction() + +#---------------------------------------------------------------------# +# algebraic traits with LEDA +#---------------------------------------------------------------------# +function(test_algebraic_traits_leda) + #TODO: Adapt + + set(nt ${LEDA_INT_NT}) + set(kernel ${UNIVARIATE_ALGEBRAIC_KERNEL}) + set(geom_traits ${ALGEBRAIC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits algebraic "${flags}" algebraic_traits_leda) + + execute_commands_new_structure(algebraic algebraic_traits_leda + COMPARE COMPARE_Y_AT_X COMPARE_Y_AT_X_RIGHT COMPARE_Y_AT_X_LEFT + MAKE_X_MONOTONE IS_VERTICAL VERTEX SPLIT MERGE INTERSECT + PARAMETER_SPACE_X PARAMETER_SPACE_Y) +endfunction() + + +#---------------------------------------------------------------------# +# algebraic traits with CORE +#---------------------------------------------------------------------# +function(test_algebraic_traits_core) + #TODO: Adapt + + set(nt ${CORE_INT_NT}) + set(kernel ${UNIVARIATE_ALGEBRAIC_KERNEL}) + set(geom_traits ${ALGEBRAIC_GEOM_TRAITS}) + set(flags "-DTEST_NT=${nt} -DTEST_KERNEL=${kernel} -DTEST_GEOM_TRAITS=${geom_traits}") + + compile_test_with_flags(test_traits algebraic "${flags}" algebraic_traits_core) + + execute_commands_new_structure(algebraic algebraic_traits_core + COMPARE COMPARE_Y_AT_X COMPARE_Y_AT_X_RIGHT COMPARE_Y_AT_X_LEFT + MAKE_X_MONOTONE IS_VERTICAL VERTEX SPLIT MERGE INTERSECT + PARAMETER_SPACE_X PARAMETER_SPACE_Y) +endfunction() + + +configure("") +compile_and_run(construction_test_suite_generator) + +test_segment_traits() +test_non_caching_segment_traits() +test_polyline_traits() +test_polycurve_conic_traits() +test_polycurve_circular_arc_traits() +test_polycurve_bezier_traits() +test_non_caching_polyline_traits() +test_linear_traits() +test_conic_traits() + +test_line_arc_traits() # "line arcs" (segments) only +test_circular_arc_traits() # circular arcs only +test_circular_line_arc_traits() # for both + +test_circle_segments_traits() +test_bezier_traits() + +test_spherical_arc_traits() + +test_rational_arc_traits() + +test_algebraic_traits_core() +test_algebraic_traits_gmp() +test_algebraic_traits_leda() + +compile_and_run(test_insertion) +compile_and_run(test_unbounded_rational_insertion) +compile_and_run(test_unbounded_rational_direct_insertion) +compile_and_run(test_rational_function_traits_2) +compile_and_run(test_iso_verts) + +compile_and_run(test_vert_ray_shoot_vert_segments) + +test_construction_segments() +test_construction_linear_curves() +test_construction_spherical_arcs() + +test_overlay_segments() +test_overlay_spherical_arcs() + +test_point_location_segments() +test_point_location_segments_version() +test_point_location_segments_conversion() +test_point_location_circle_segments() +test_point_location_linear() + +test_point_location_dynamic_segments() + +test_batched_point_location_segments() +test_batched_point_location_linear() +test_batched_point_location_spherical_arcs() + +test_vertical_decomposition_segments() +test_vertical_decomposition_linear() +# test_vertical_decomposition_spherical_arcs + +compile_and_run(test_dual) +compile_and_run(test_do_intersect) +compile_and_run(test_zone) + +compile_and_run(test_observer) +compile_and_run(test_do_equal) + +test_segment_traits_adaptor() +test_linear_traits_adaptor() +test_spherical_arcs_traits_adaptor() + +compile_and_run(test_removal) +compile_and_run(test_unbounded_removal) +compile_and_run(test_spherical_removal) + +compile_and_run(test_io) diff --git a/CMakeLists.txt b/CMakeLists.txt index afda9b5ce18..9d6e9ed78b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/Installation/CMakeLists.txt b/Installation/CMakeLists.txt index 0058828a7e5..b05a922a051 100644 --- a/Installation/CMakeLists.txt +++ b/Installation/CMakeLists.txt @@ -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) diff --git a/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake b/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake index 8549d00dd9a..73fdc9117a6 100644 --- a/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake +++ b/Installation/cmake/modules/CGAL_CreateSingleSourceCGALProgram.cmake @@ -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} ) diff --git a/Installation/cmake/modules/CGAL_add_test.cmake b/Installation/cmake/modules/CGAL_add_test.cmake new file mode 100644 index 00000000000..56fc661e989 --- /dev/null +++ b/Installation/cmake/modules/CGAL_add_test.cmake @@ -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=$ + -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() diff --git a/Installation/cmake/modules/UseCGAL.cmake b/Installation/cmake/modules/UseCGAL.cmake index 814d4bfbc06..259fb97b451 100644 --- a/Installation/cmake/modules/UseCGAL.cmake +++ b/Installation/cmake/modules/UseCGAL.cmake @@ -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) diff --git a/Installation/cmake/modules/run_test_with_cin.cmake b/Installation/cmake/modules/run_test_with_cin.cmake new file mode 100644 index 00000000000..c5218fc8141 --- /dev/null +++ b/Installation/cmake/modules/run_test_with_cin.cmake @@ -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() diff --git a/Installation/test/Installation/CMakeLists.txt b/Installation/test/Installation/CMakeLists.txt index 0512386bfbd..8d23065d0da 100644 --- a/Installation/test/Installation/CMakeLists.txt +++ b/Installation/test/Installation/CMakeLists.txt @@ -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}) diff --git a/Installation/test/Installation/will_fail.cpp b/Installation/test/Installation/will_fail.cpp new file mode 100644 index 00000000000..1ae6cb4c591 --- /dev/null +++ b/Installation/test/Installation/will_fail.cpp @@ -0,0 +1,5 @@ +#include + +int f() { + return EXIT_FAILURE; +} diff --git a/Installation/test/Installation/will_fail_aux.cpp b/Installation/test/Installation/will_fail_aux.cpp new file mode 100644 index 00000000000..f999acead77 --- /dev/null +++ b/Installation/test/Installation/will_fail_aux.cpp @@ -0,0 +1,2 @@ +extern int f(); +int main() { return f(); } diff --git a/Scripts/scripts/cgal_create_cmake_script b/Scripts/scripts/cgal_create_cmake_script index b39812fa1d7..d31102227d2 100755 --- a/Scripts/scripts/cgal_create_cmake_script +++ b/Scripts/scripts/cgal_create_cmake_script @@ -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