From 0111f3187ec0f1424ab9a307f89f198af013b3e0 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Feb 2018 21:30:15 +0100 Subject: [PATCH 1/6] :hammer: working on #953 --- .travis.yml | 4 ++-- Makefile | 2 +- test/CMakeLists.txt | 5 ++++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index fa2918f35..f1e538f83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -99,10 +99,10 @@ matrix: before_script: - pip install --user cpp-coveralls after_success: - - coveralls --build-root test --include single_header/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp' + - coveralls --build-root test --include include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp' env: - COMPILER=g++-4.9 - - CMAKE_OPTIONS=-DJSON_Coverage=ON + - CMAKE_OPTIONS=-DJSON_Coverage=ON -DJSON_MultipleHeader=ON # Coverity (only for branch coverity_scan) diff --git a/Makefile b/Makefile index 30b8ba9ab..1cfa5101b 100644 --- a/Makefile +++ b/Makefile @@ -81,7 +81,7 @@ clean: coverage: mkdir build_coverage - cd build_coverage ; CXX=g++-5 cmake .. -GNinja -DJSON_Coverage=ON + cd build_coverage ; CXX=g++-5 cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON cd build_coverage ; ninja cd build_coverage ; ctest -j10 cd build_coverage ; ninja lcov_html diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a4021923e..d53d5c4b3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -40,11 +40,14 @@ if(JSON_Coverage) string(REGEX MATCH "^[0-9]+" GCC_VERSION "${CMAKE_CXX_COMPILER_VERSION}") find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov HINTS ${COMPILER_PATH}) + # collect all source files from the chosen include dir + file(GLOB_RECURSE SOURCE_FILES ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}*.hpp) + # add target to collect coverage information and generate HTML file # (filter script from https://stackoverflow.com/a/43726240/266378) add_custom_target(lcov_html COMMAND lcov --directory . --capture --output-file json.info --gcov-tool ${GCOV_BIN} --rc lcov_branch_coverage=1 - COMMAND lcov -e json.info ${CMAKE_SOURCE_DIR}/single_include/nlohmann/json.hpp --output-file json.info.filtered --rc lcov_branch_coverage=1 + COMMAND lcov -e json.info ${SOURCE_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1 COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info.filtered > json.info.filtered.noexcept COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.filtered.noexcept COMMENT "Generating HTML report test/html/index.html" From 316634e12991bf65a3d2324af37620e1fa24bb9c Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Feb 2018 21:54:32 +0100 Subject: [PATCH 2/6] :hammer: added quotes around parameters --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f1e538f83..81d55d06c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,7 +102,7 @@ matrix: - coveralls --build-root test --include include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp' env: - COMPILER=g++-4.9 - - CMAKE_OPTIONS=-DJSON_Coverage=ON -DJSON_MultipleHeader=ON + - CMAKE_OPTIONS="-DJSON_Coverage=ON -DJSON_MultipleHeader=ON" # Coverity (only for branch coverity_scan) From 1e8f4d6ab3481008c3043664d0e43ce6b425d7a8 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Feb 2018 22:11:05 +0100 Subject: [PATCH 3/6] :hammer: more trying --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 81d55d06c..a6cd9f008 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,7 +102,8 @@ matrix: - coveralls --build-root test --include include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp' env: - COMPILER=g++-4.9 - - CMAKE_OPTIONS="-DJSON_Coverage=ON -DJSON_MultipleHeader=ON" + - CMAKE_OPTIONS=-DJSON_Coverage=ON + - CMAKE_OPTIONS_MORE=-DJSON_MultipleHeader=ON # Coverity (only for branch coverity_scan) @@ -288,7 +289,7 @@ script: # compile and execute unit tests - mkdir -p build && cd build - - cmake .. ${CMAKE_OPTIONS} -GNinja && cmake --build . --config Release + - cmake .. ${CMAKE_OPTIONS} ${CMAKE_OPTIONS_MORE} -GNinja && cmake --build . --config Release - ctest -C Release -V -j - cd .. From b455154cc9b5265fff2613320c19949dc2546b84 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Feb 2018 22:18:51 +0100 Subject: [PATCH 4/6] :hammer: another try --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index a6cd9f008..895ddd8d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,8 +102,8 @@ matrix: - coveralls --build-root test --include include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp' env: - COMPILER=g++-4.9 - - CMAKE_OPTIONS=-DJSON_Coverage=ON - - CMAKE_OPTIONS_MORE=-DJSON_MultipleHeader=ON + - CMAKE_OPTIONS=-DJSON_MultipleHeader=ON + - CMAKE_OPTIONS_MORE=-DJSON_Coverage=ON # Coverity (only for branch coverity_scan) From ab05df3a489bc4daff1d1a22f7cc13b766b87598 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Feb 2018 22:27:08 +0100 Subject: [PATCH 5/6] :hammer: another try --- .travis.yml | 5 ++--- test/CMakeLists.txt | 1 + 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 895ddd8d7..17ff58bfd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -102,8 +102,7 @@ matrix: - coveralls --build-root test --include include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp' env: - COMPILER=g++-4.9 - - CMAKE_OPTIONS=-DJSON_MultipleHeader=ON - - CMAKE_OPTIONS_MORE=-DJSON_Coverage=ON + - CMAKE_OPTIONS=-DJSON_Coverage=ON # Coverity (only for branch coverity_scan) @@ -289,7 +288,7 @@ script: # compile and execute unit tests - mkdir -p build && cd build - - cmake .. ${CMAKE_OPTIONS} ${CMAKE_OPTIONS_MORE} -GNinja && cmake --build . --config Release + - cmake .. ${CMAKE_OPTIONS} -GNinja && cmake --build . --config Release - ctest -C Release -V -j - cd .. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d53d5c4b3..1dfe34009 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -41,6 +41,7 @@ if(JSON_Coverage) find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov HINTS ${COMPILER_PATH}) # collect all source files from the chosen include dir + set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/single_include/") file(GLOB_RECURSE SOURCE_FILES ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}*.hpp) # add target to collect coverage information and generate HTML file From 74675dd69c049b45b2b9d74a4a728cf77ef49a34 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Fri, 9 Feb 2018 22:40:52 +0100 Subject: [PATCH 6/6] :rewind: back to the original version --- .travis.yml | 2 +- test/CMakeLists.txt | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17ff58bfd..868ac9978 100644 --- a/.travis.yml +++ b/.travis.yml @@ -99,7 +99,7 @@ matrix: before_script: - pip install --user cpp-coveralls after_success: - - coveralls --build-root test --include include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp' + - coveralls --build-root test --include single_include/nlohmann --gcov 'gcov-4.9' --gcov-options '\-lp' env: - COMPILER=g++-4.9 - CMAKE_OPTIONS=-DJSON_Coverage=ON diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1dfe34009..d53d5c4b3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -41,7 +41,6 @@ if(JSON_Coverage) find_program(GCOV_BIN NAMES gcov-${GCC_VERSION} gcov HINTS ${COMPILER_PATH}) # collect all source files from the chosen include dir - set(NLOHMANN_JSON_INCLUDE_BUILD_DIR "${PROJECT_SOURCE_DIR}/single_include/") file(GLOB_RECURSE SOURCE_FILES ${NLOHMANN_JSON_INCLUDE_BUILD_DIR}*.hpp) # add target to collect coverage information and generate HTML file