From 268f5a3d0aff46cef8f95a17121bb871ac6f61c6 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 25 Aug 2017 21:29:27 +0200 Subject: [PATCH] :construction_worker: added option to switch off exceptions --- .travis.yml | 8 ++------ test/CMakeLists.txt | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 07d4afad..43323c34 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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/) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 16614898..a8090378 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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")