👷 added option to switch off exceptions

This commit is contained in:
Niels Lohmann 2017-08-25 21:29:27 +02:00
parent 839681ff9f
commit 268f5a3d0a
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
2 changed files with 14 additions and 9 deletions

View file

@ -64,19 +64,15 @@ matrix:
- make cppcheck
# no exceptions
- os: linux
compiler: gcc
env:
- COMPILER=g++-4.9
- SPECIAL=no_exceptions
- CMAKE_OPTIONS=-DJSON_NoExceptions=ON
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9', 'cppcheck', 'ninja-build']
after_success:
- make clean
- CPPFLAGS="-DJSON_NOEXCEPTION" make check TEST_PATTERN="-e \"*\""
packages: ['g++-4.9', 'ninja-build']
# Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/)

View file

@ -1,5 +1,6 @@
option(JSON_Sanitizer "Build test suite with Clang sanitizer" OFF)
option(JSON_Valgrind "Execute test suite with Valgrind" OFF)
option(JSON_NoExceptions "Build test suite without exceptions" OFF)
if(JSON_Sanitizer)
message(STATUS "Building test suite with Clang sanitizer")
@ -16,6 +17,14 @@ if(JSON_Valgrind)
separate_arguments(memcheck_command)
endif()
if(JSON_NoExceptions)
message(STATUS "Building test suite without exceptions")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DJSON_NOEXCEPTION")
endif()
set(CATCH_TEST_FILTER -e)
endif()
#############################################################################
# Catch library with the main function to speed up build
#############################################################################
@ -62,20 +71,20 @@ foreach(file ${files})
endif()
add_test(NAME "${testcase}_default"
COMMAND ${testcase}
COMMAND ${testcase} ${CATCH_TEST_FILTER}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
set_tests_properties("${testcase}_default" PROPERTIES LABELS "default")
add_test(NAME "${testcase}_all"
COMMAND ${testcase} "*"
COMMAND ${testcase} ${CATCH_TEST_FILTER} "*"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
set_tests_properties("${testcase}_all" PROPERTIES LABELS "all")
if(JSON_Valgrind)
add_test(NAME "${testcase}_valgrind"
COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase}
COMMAND ${memcheck_command} ${CMAKE_CURRENT_BINARY_DIR}/${testcase} ${CATCH_TEST_FILTER}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
set_tests_properties("${testcase}_valgrind" PROPERTIES LABELS "valgrind")