From f0bc16d89985b22235c14c42b07fec343e82a00d Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Sat, 6 Apr 2019 09:02:17 +0200 Subject: [PATCH] :hammer: overworked coverage targets --- Makefile | 5 +++-- README.md | 2 ++ test/CMakeLists.txt | 16 +++++++--------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 2de47b19..46a33b4b 100644 --- a/Makefile +++ b/Makefile @@ -35,6 +35,7 @@ all: @echo "check-fast - compile and execute test suite (skip long-running tests)" @echo "clean - remove built files" @echo "coverage - create coverage information with lcov" + @echo "coverage-fast - create coverage information with fastcov" @echo "cppcheck - analyze code with cppcheck" @echo "cpplint - analyze code with cpplint" @echo "clang_tidy - analyze code with Clang-Tidy" @@ -82,13 +83,13 @@ coverage: cd build_coverage ; ninja lcov_html open build_coverage/test/html/index.html -fast-cov: +coverage-fast: rm -fr build_coverage mkdir build_coverage cd build_coverage ; CXX=$(COMPILER_DIR)/g++ cmake .. -GNinja -DJSON_Coverage=ON -DJSON_MultipleHeaders=ON cd build_coverage ; ninja cd build_coverage ; ctest -E '.*_default' -j10 - cd build_coverage ; ninja lcov_html2 + cd build_coverage ; ninja fastcov_html open build_coverage/test/html/index.html ########################################################################## diff --git a/README.md b/README.md index f05af440..ee0e249f 100644 --- a/README.md +++ b/README.md @@ -1279,9 +1279,11 @@ The library itself consists of a single header file licensed under the MIT licen - [**doctest**](https://github.com/onqtam/doctest) for the unit tests - [**Doozer**](https://doozer.io) for [continuous integration](https://doozer.io/nlohmann/json) on Linux (CentOS, Raspbian, Fedora) - [**Doxygen**](http://www.stack.nl/~dimitri/doxygen/) to generate [documentation](https://nlohmann.github.io/json/) +- [**fastcov**](https://github.com/RPGillespie6/fastcov) to process coverage information - [**git-update-ghpages**](https://github.com/rstacruz/git-update-ghpages) to upload the documentation to gh-pages - [**GitHub Changelog Generator**](https://github.com/skywinder/github-changelog-generator) to generate the [ChangeLog](https://github.com/nlohmann/json/blob/develop/ChangeLog.md) - [**Google Benchmark**](https://github.com/google/benchmark) to implement the benchmarks +- [**lcov**](http://ltp.sourceforge.net/coverage/lcov.php) to process coverage information and create a HTML view - [**libFuzzer**](http://llvm.org/docs/LibFuzzer.html) to implement fuzz testing for OSS-Fuzz - [**OSS-Fuzz**](https://github.com/google/oss-fuzz) for continuous fuzz testing of the library ([project repository](https://github.com/google/oss-fuzz/tree/master/projects/json)) - [**Probot**](https://probot.github.io) for automating maintainer tasks such as closing stale issues, requesting missing information, or detecting toxic comments. diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1a816dbf..b73dfc9a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -27,9 +27,9 @@ endif() if(JSON_Coverage) message(STATUS "Building test suite with coverage information") - #if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - # message(FATAL_ERROR "JSON_Coverage requires GCC.") - #endif() + if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + message(FATAL_ERROR "JSON_Coverage requires GCC.") + endif() # enable profiling set(CMAKE_CXX_FLAGS "--coverage -g -O0 -fprofile-arcs -ftest-coverage") @@ -46,18 +46,16 @@ if(JSON_Coverage) # (filter script from https://stackoverflow.com/a/43726240/266378) add_custom_target(lcov_html COMMAND lcov --directory . --capture --output-file json.info --rc lcov_branch_coverage=1 - COMMAND lcov -e json.info ${SOURCE_FILES} --output-file json.info.filtered --rc lcov_branch_coverage=1 + COMMAND lcov -e json.info ${SOURCE_FILES} --output-file json.info.filtered --gcov-tool ${GCOV_BIN} --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" ) - # add target to collect coverage information and generate HTML file - # (filter script from https://stackoverflow.com/a/43726240/266378) - add_custom_target(lcov_html2 + add_custom_target(fastcov_html COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/fastcov/fastcov.py --branch-coverage --lcov -o json.info --gcov ${GCOV_BIN} --compiler-directory ${CMAKE_BINARY_DIR} --source-files ${SOURCE_FILES} - COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info > 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 + COMMAND ${CMAKE_SOURCE_DIR}/test/thirdparty/imapdl/filterbr.py json.info > json.info.noexcept + COMMAND genhtml --title "JSON for Modern C++" --legend --demangle-cpp --output-directory html --show-details --branch-coverage json.info.noexcept COMMENT "Generating HTML report test/html/index.html" ) endif()