From d02e67d4a957d050ab4233209c452fdf433b238a Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 20:56:26 +0200 Subject: [PATCH] coveralls with lcov --- .gitignore | 12 ++--- .travis.yml | 134 +++++++++++++++++++++++++++++--------------------- test/Makefile | 2 +- 3 files changed, 85 insertions(+), 63 deletions(-) diff --git a/.gitignore b/.gitignore index b82214e9a..c7e847c4c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,18 +1,16 @@ json_unit json_benchmarks - fuzz-testing *.dSYM +*.o +*.gcno +*.gcda working -html +doc/xml +doc/html me.nlohmann.json.docset -android -doc/xml - benchmarks/files/numbers/*.json - -*.o diff --git a/.travis.yml b/.travis.yml index 903a4c587..03da02d5e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,85 @@ env: matrix: include: + # Valgrind + + - os: linux + compiler: gcc + env: + - COMPILER=g++-4.9 + - SPECIAL=valgrind + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: [g++-4.9, valgrind] + after_success: + - valgrind --error-exitcode=1 --leak-check=full test/json_unit -s "*" ; + + # Coveralls + + #- os: linux + # compiler: gcc + # addons: + # apt: + # sources: ['ubuntu-toolchain-r-test'] + # packages: ['g++-4.9', 'valgrind', 'python-pip', 'python-yaml'] + # before_script: + # - pip install --user git+git://github.com/eddyxu/cpp-coveralls.git + # after_success: + # - make clean + # - touch src/json.hpp + # - make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage -std=c++11 -lstdc++" CXX=$COMPILER + # - test/json_unit "*" + # - coveralls --build-root test --exclude src/catch.hpp --exclude src/unit-algorithms.cpp --exclude src/unit-allocator.cpp --exclude src/unit-capacity.cpp --exclude src/unit-class_const_iterator.cpp --exclude src/unit-class_iterator.cpp --exclude src/unit-class_lexer.cpp --exclude src/unit-class_parser.cpp --exclude src/unit-comparison.cpp --exclude src/unit-concepts.cpp --exclude src/unit-constructor1.cpp --exclude src/unit-constructor2.cpp --exclude src/unit-convenience.cpp --exclude src/unit-conversions.cpp --exclude src/unit-deserialization.cpp --exclude src/unit-element_access1.cpp --exclude src/unit-element_access2.cpp --exclude src/unit-inspection.cpp --exclude src/unit-iterator_wrapper.cpp --exclude src/unit-iterators1.cpp --exclude src/unit-iterators2.cpp --exclude src/unit-json_patch.cpp --exclude src/unit-json_pointer.cpp --exclude src/unit-modifiers.cpp --exclude src/unit-pointer_access.cpp --exclude src/unit-readme.cpp --exclude src/unit-reference_access.cpp --exclude src/unit-regression.cpp --exclude src/unit-serialization.cpp --exclude src/unit-testsuites.cpp --exclude src/unit-unicode.cpp --include ../src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9' + # env: + # - COMPILER=g++-4.9 + # - SPECIAL=coveralls + + - os: linux + compiler: gcc + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-4.9', 'rubygems'] + before_script: + - wget http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.11.orig.tar.gz + - tar xf lcov_1.11.orig.tar.gz + - sudo make -C lcov-1.11/ install + - gem install coveralls-lcov + after_success: + - make clean + - CXXFLAGS="--coverage -g -O0" CPPFLAGS="-DNDEBUG" make + - test/json_unit "*" + - coveralls --build-root test --exclude src/catch.hpp --exclude src/unit-algorithms.cpp --exclude src/unit-allocator.cpp --exclude src/unit-capacity.cpp --exclude src/unit-class_const_iterator.cpp --exclude src/unit-class_iterator.cpp --exclude src/unit-class_lexer.cpp --exclude src/unit-class_parser.cpp --exclude src/unit-comparison.cpp --exclude src/unit-concepts.cpp --exclude src/unit-constructor1.cpp --exclude src/unit-constructor2.cpp --exclude src/unit-convenience.cpp --exclude src/unit-conversions.cpp --exclude src/unit-deserialization.cpp --exclude src/unit-element_access1.cpp --exclude src/unit-element_access2.cpp --exclude src/unit-inspection.cpp --exclude src/unit-iterator_wrapper.cpp --exclude src/unit-iterators1.cpp --exclude src/unit-iterators2.cpp --exclude src/unit-json_patch.cpp --exclude src/unit-json_pointer.cpp --exclude src/unit-modifiers.cpp --exclude src/unit-pointer_access.cpp --exclude src/unit-readme.cpp --exclude src/unit-reference_access.cpp --exclude src/unit-regression.cpp --exclude src/unit-serialization.cpp --exclude src/unit-testsuites.cpp --exclude src/unit-unicode.cpp --include ../src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9' + - lcov --directory src --directory test/src --capture --output-file coverage.info --rc lcov_branch_coverage=1 --no-external + - lcov --remove coverage.info 'test/src/*' --output-file coverage.info --rc lcov_branch_coverage=1 + - lcov --list coverage.info --rc lcov_branch_coverage=1 + - coveralls-lcov --repo-token F9bs4Nop10JRgqPQXRcifyQKYhb3FczkS coverage.info + env: + - COMPILER=g++-4.9 + - SPECIAL=coveralls + + # Coverity (only for branch coverity_scan) + + - os: linux + compiler: gcc + before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: ['g++-5', 'valgrind'] + coverity_scan: + project: + name: "nlohmann/json" + description: "Build submitted via Travis CI" + notification_email: niels.lohmann@gmail.com + build_command_prepend: "make clean ; sudo cp $(which g++-5) $(which g++)" + build_command: "make" + branch_pattern: coverity_scan + env: + - COMPILER=g++-5 + - SPECIAL=coverity + # OSX / Clang - os: osx @@ -109,61 +188,6 @@ matrix: env: LLVM_VERSION=3.8.1 compiler: clang - # Valgrind - - - os: linux - compiler: gcc - env: - - COMPILER=g++-4.9 - - SPECIAL=valgrind - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: [g++-4.9, valgrind] - after_success: - - valgrind --error-exitcode=1 --leak-check=full test/json_unit "*" ; - - # Coveralls - - - os: linux - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'valgrind', 'python-pip', 'python-yaml'] - before_script: - - pip install --user git+git://github.com/eddyxu/cpp-coveralls.git - after_success: - - make clean - - touch src/json.hpp - - make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage -std=c++11 -lstdc++" CXX=$COMPILER - - test/json_unit "*" - - coveralls --build-root test --exclude src/catch.hpp --exclude src/unit-algorithms.cpp --exclude src/unit-allocator.cpp --exclude src/unit-capacity.cpp --exclude src/unit-class_const_iterator.cpp --exclude src/unit-class_iterator.cpp --exclude src/unit-class_lexer.cpp --exclude src/unit-class_parser.cpp --exclude src/unit-comparison.cpp --exclude src/unit-concepts.cpp --exclude src/unit-constructor1.cpp --exclude src/unit-constructor2.cpp --exclude src/unit-convenience.cpp --exclude src/unit-conversions.cpp --exclude src/unit-deserialization.cpp --exclude src/unit-element_access1.cpp --exclude src/unit-element_access2.cpp --exclude src/unit-inspection.cpp --exclude src/unit-iterator_wrapper.cpp --exclude src/unit-iterators1.cpp --exclude src/unit-iterators2.cpp --exclude src/unit-json_patch.cpp --exclude src/unit-json_pointer.cpp --exclude src/unit-modifiers.cpp --exclude src/unit-pointer_access.cpp --exclude src/unit-readme.cpp --exclude src/unit-reference_access.cpp --exclude src/unit-regression.cpp --exclude src/unit-serialization.cpp --exclude src/unit-testsuites.cpp --exclude src/unit-unicode.cpp --include ../src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9' - env: - - COMPILER=g++-4.9 - - SPECIAL=coveralls - - # Coverity (only for branch coverity_scan) - - - os: linux - compiler: gcc - before_install: echo -n | openssl s_client -connect scan.coverity.com:443 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-5', 'valgrind'] - coverity_scan: - project: - name: "nlohmann/json" - description: "Build submitted via Travis CI" - notification_email: niels.lohmann@gmail.com - build_command_prepend: "make clean ; sudo cp $(which g++-5) $(which g++)" - build_command: "make" - branch_pattern: coverity_scan - env: - - COMPILER=g++-5 - - SPECIAL=coverity - ##################### # installation step # ##################### diff --git a/test/Makefile b/test/Makefile index 8e1ad6a00..ead1f0738 100644 --- a/test/Makefile +++ b/test/Makefile @@ -51,4 +51,4 @@ json_unit: $(OBJECTS) ../src/json.hpp src/catch.hpp @$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ clean: - rm -fr json_unit $(OBJECTS) + rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda)