From 117fd59abd1854bd4d90f5276cc4f82268a58ae2 Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 9 Aug 2016 22:18:13 +0200 Subject: [PATCH 01/17] first try --- .travis.yml | 371 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 212 insertions(+), 159 deletions(-) diff --git a/.travis.yml b/.travis.yml index 929095be..fc631eee 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,175 +1,228 @@ +######################### +# project configuration # +######################### + +# C++ project language: cpp -dist: trusty -sudo: required +# container-based build +sudo: false -env: - global: - # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created - # via the "travis encrypt" command using the project repo's public key - - secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA=" +addons: + apt: + packages: + - g++-6 + sources: &sources + - ubuntu-toolchain-r-test + + +################ +# build matrix # +################ -# from http://stackoverflow.com/a/32127147/266378 matrix: include: - - 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 - - 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 + - os: osx + osx_image: xcode7.3 - - os: linux - compiler: gcc - addons: - apt: - sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-6', 'valgrind'] - env: COMPILER=g++-6 + - os: osx + osx_image: xcode8 - # from https://github.com/travis-ci/travis-ci/issues/6120 - - os: linux - env: - - LLVM_VERSION=3.8.0 - - LLVM_ARCHIVE_PATH=$HOME/clang+llvm.tar.xz - - COMPILER=clang++ - - CPPFLAGS="-I $HOME/clang-$LLVM_VERSION/include/c++/v1" - - LDFLAGS=-lc++ - - PATH=$HOME/clang-$LLVM_VERSION/bin:$PATH - - LD_LIBRARY_PATH=$HOME/clang-$LLVM_VERSION/lib:$LD_LIBRARY_PATH - before_install: - - wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-14.04.tar.xz -O $LLVM_ARCHIVE_PATH - - mkdir $HOME/clang-$LLVM_VERSION - - tar xf $LLVM_ARCHIVE_PATH -C $HOME/clang-$LLVM_VERSION --strip-components 1 + - os: linux + env: COMPILER=g++-6 + compiler: gcc - # Clang 3.5 is not able to compile the code, - # see https://travis-ci.org/nlohmann/json/jobs/126720186 -# - os: linux -# compiler: clang -# addons: -# apt: -# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] -# packages: ['clang-3.6', 'valgrind'] -# env: COMPILER=clang++-3.6 -# -# - os: linux -# compiler: clang -# addons: -# apt: -# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] -# packages: ['clang-3.7', 'valgrind'] -# env: COMPILER=clang++-3.7 -# -# - os: linux -# compiler: clang -# addons: -# apt: -# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.8'] -# packages: ['clang-3.8', 'valgrind'] -# env: COMPILER=clang++-3.8 +##################### +# installation step # +##################### - # - os: linux - # compiler: clang - # addons: - # apt: - # sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise'] - # packages: ['clang-3.9', 'valgrind'] - # env: COMPILER=clang++-3.9 +install: + - if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi - - os: osx - osx_image: beta-xcode6.1 - compiler: clang - env: - - COMPILER=clang - - CXXFLAGS=-lstdc++ - - os: osx - osx_image: beta-xcode6.2 - compiler: clang - env: - - COMPILER=clang - - CXXFLAGS=-lstdc++ - - - os: osx - osx_image: beta-xcode6.3 - compiler: clang - env: - - COMPILER=clang - - CXXFLAGS=-lstdc++ - - - os: osx - osx_image: xcode6.4 - compiler: clang - env: - - COMPILER=clang - - CXXFLAGS=-lstdc++ - - - os: osx - osx_image: xcode7.1 - compiler: clang - env: - - COMPILER=clang - - CXXFLAGS=-lstdc++ - - - os: osx - osx_image: xcode7.2 - compiler: clang - env: - - COMPILER=clang - - CXXFLAGS=-lstdc++ - - - os: osx - osx_image: xcode7.3 - compiler: clang - env: - - COMPILER=clang - - CXXFLAGS=-lstdc++ - - - os: osx - osx_image: xcode8 - compiler: clang - env: - - COMPILER=clang - - CXXFLAGS=-lstdc++ +################ +# build script # +################ script: - - uname -a - - $COMPILER --version - - make CXX=$COMPILER - - test/json_unit "*" - - if [ `which valgrind` ]; then - valgrind --error-exitcode=1 --leak-check=full test/json_unit ; - fi - - if [ `which brew` ]; then - brew update ; - brew tap nlohmann/json ; - brew install nlohmann_json --HEAD ; - brew test nlohmann_json ; - fi + - make + - test/json_unit + +#language: cpp +# +#dist: trusty +#sudo: required +# +#env: +# global: +# # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created +# # via the "travis encrypt" command using the project repo's public key +# - secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA=" +# +## from http://stackoverflow.com/a/32127147/266378 +#matrix: +# include: +# - 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 +# +# - 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 +# +# - os: linux +# compiler: gcc +# addons: +# apt: +# sources: ['ubuntu-toolchain-r-test'] +# packages: ['g++-6', 'valgrind'] +# env: COMPILER=g++-6 +# +# # from https://github.com/travis-ci/travis-ci/issues/6120 +# - os: linux +# env: +# - LLVM_VERSION=3.8.0 +# - LLVM_ARCHIVE_PATH=$HOME/clang+llvm.tar.xz +# - COMPILER=clang++ +# - CPPFLAGS="-I $HOME/clang-$LLVM_VERSION/include/c++/v1" +# - LDFLAGS=-lc++ +# - PATH=$HOME/clang-$LLVM_VERSION/bin:$PATH +# - LD_LIBRARY_PATH=$HOME/clang-$LLVM_VERSION/lib:$LD_LIBRARY_PATH +# before_install: +# - wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-14.04.tar.xz -O $LLVM_ARCHIVE_PATH +# - mkdir $HOME/clang-$LLVM_VERSION +# - tar xf $LLVM_ARCHIVE_PATH -C $HOME/clang-$LLVM_VERSION --strip-components 1 +# +# # Clang 3.5 is not able to compile the code, +# # see https://travis-ci.org/nlohmann/json/jobs/126720186 +# +## - os: linux +## compiler: clang +## addons: +## apt: +## sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] +## packages: ['clang-3.6', 'valgrind'] +## env: COMPILER=clang++-3.6 +## +## - os: linux +## compiler: clang +## addons: +## apt: +## sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] +## packages: ['clang-3.7', 'valgrind'] +## env: COMPILER=clang++-3.7 +## +## - os: linux +## compiler: clang +## addons: +## apt: +## sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.8'] +## packages: ['clang-3.8', 'valgrind'] +## env: COMPILER=clang++-3.8 +# +# # - os: linux +# # compiler: clang +# # addons: +# # apt: +# # sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise'] +# # packages: ['clang-3.9', 'valgrind'] +# # env: COMPILER=clang++-3.9 +# +# - os: osx +# osx_image: beta-xcode6.1 +# compiler: clang +# env: +# - COMPILER=clang +# - CXXFLAGS=-lstdc++ +# +# - os: osx +# osx_image: beta-xcode6.2 +# compiler: clang +# env: +# - COMPILER=clang +# - CXXFLAGS=-lstdc++ +# +# - os: osx +# osx_image: beta-xcode6.3 +# compiler: clang +# env: +# - COMPILER=clang +# - CXXFLAGS=-lstdc++ +# +# - os: osx +# osx_image: xcode6.4 +# compiler: clang +# env: +# - COMPILER=clang +# - CXXFLAGS=-lstdc++ +# +# - os: osx +# osx_image: xcode7.1 +# compiler: clang +# env: +# - COMPILER=clang +# - CXXFLAGS=-lstdc++ +# +# - os: osx +# osx_image: xcode7.2 +# compiler: clang +# env: +# - COMPILER=clang +# - CXXFLAGS=-lstdc++ +# +# - os: osx +# osx_image: xcode7.3 +# compiler: clang +# env: +# - COMPILER=clang +# - CXXFLAGS=-lstdc++ +# +# - os: osx +# osx_image: xcode8 +# compiler: clang +# env: +# - COMPILER=clang +# - CXXFLAGS=-lstdc++ +# +#script: +# - uname -a +# - $COMPILER --version +# - make CXX=$COMPILER +# - test/json_unit "*" +# - if [ `which valgrind` ]; then +# valgrind --error-exitcode=1 --leak-check=full test/json_unit ; +# fi +# - if [ `which brew` ]; then +# brew update ; +# brew tap nlohmann/json ; +# brew install nlohmann_json --HEAD ; +# brew test nlohmann_json ; +# fi +# \ No newline at end of file From 4b37082e365103695fbfff01d412d78951f7bcad Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 9 Aug 2016 22:29:01 +0200 Subject: [PATCH 02/17] more GCC versions --- .travis.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc631eee..16716796 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,8 +10,6 @@ sudo: false addons: apt: - packages: - - g++-6 sources: &sources - ubuntu-toolchain-r-test @@ -30,8 +28,18 @@ matrix: osx_image: xcode8 - os: linux - env: COMPILER=g++-6 compiler: gcc + env: COMPILER=g++-4.9 + addons: + apt: + packages: g++-4.9 + + - os: linux + compiler: gcc + env: COMPILER=g++-5 + addons: + apt: + packages: g++-5 ##################### @@ -47,6 +55,8 @@ install: ################ script: + - uname -a + - $CXX --version - make - test/json_unit From be05dbe6188013f82267ebf19d43fb68ca5ba77a Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 9 Aug 2016 22:33:31 +0200 Subject: [PATCH 03/17] moved sources --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 16716796..2f541e42 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,11 +8,6 @@ language: cpp # container-based build sudo: false -addons: - apt: - sources: &sources - - ubuntu-toolchain-r-test - ################ # build matrix # @@ -32,6 +27,7 @@ matrix: env: COMPILER=g++-4.9 addons: apt: + sources: ['ubuntu-toolchain-r-test'] packages: g++-4.9 - os: linux @@ -39,6 +35,7 @@ matrix: env: COMPILER=g++-5 addons: apt: + sources: ['ubuntu-toolchain-r-test'] packages: g++-5 From 6150ffb9dce6fd2588d57a53c1de30ab9ee59d88 Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 9 Aug 2016 22:49:08 +0200 Subject: [PATCH 04/17] more compilers --- .travis.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2f541e42..e0b2db50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,12 +16,34 @@ sudo: false matrix: include: + # OSX / Clang + + - os: osx + osx_image: beta-xcode6.1 + + - os: osx + osx_image: beta-xcode6.2 + + - os: osx + osx_image: beta-xcode6.3 + + - os: osx + osx_image: xcode6.4 + + - os: osx + osx_image: xcode7.1 + + - os: osx + osx_image: xcode7.2 + - os: osx osx_image: xcode7.3 - os: osx osx_image: xcode8 + # Linux / GCC + - os: linux compiler: gcc env: COMPILER=g++-4.9 @@ -38,6 +60,14 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: g++-5 + - os: linux + compiler: gcc + env: COMPILER=g++-6 + addons: + apt: + sources: ['ubuntu-toolchain-r-test'] + packages: g++-6 + ##################### # installation step # @@ -56,6 +86,12 @@ script: - $CXX --version - make - test/json_unit + - if [ `which brew` ]; then + brew update ; + brew tap nlohmann/json ; + brew install nlohmann_json --HEAD ; + brew test nlohmann_json ; + fi #language: cpp # From b76861dde53ec85cd09d3467c3a8e94f33cae7f8 Mon Sep 17 00:00:00 2001 From: Niels Date: Tue, 9 Aug 2016 23:05:42 +0200 Subject: [PATCH 05/17] commit to re-fix issue #195 --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index e0b2db50..9b8feb6f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,8 @@ # C++ project language: cpp -# container-based build -sudo: false +dist: trusty +sudo: required ################ From b1c1fe9d39abbeb2c11fdac8238a265c916e3056 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 16:22:53 +0200 Subject: [PATCH 06/17] added Clang 3.8 --- .travis.yml | 35 +++++++++++++++++++++++++++++++++++ test/Makefile | 2 +- 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9b8feb6f..c102ab00 100644 --- a/.travis.yml +++ b/.travis.yml @@ -68,14 +68,49 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: g++-6 + # Linux / Clang + + - os: linux + env: LLVM_VERSION=3.8.0 + compiler: clang ##################### # installation step # ##################### +cache: + directories: + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.0 + + install: + - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" + - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} + - if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi + - | + if [[ "${LLVM_VERSION}" != "" ]]; then + LLVM_DIR=${DEPS_DIR}/llvm-${LLVM_VERSION} + if [[ -z "$(ls -A ${LLVM_DIR})" ]]; then + LLVM_URL="http://llvm.org/releases/${LLVM_VERSION}/llvm-${LLVM_VERSION}.src.tar.xz" + LIBCXX_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxx-${LLVM_VERSION}.src.tar.xz" + LIBCXXABI_URL="http://llvm.org/releases/${LLVM_VERSION}/libcxxabi-${LLVM_VERSION}.src.tar.xz" + CLANG_URL="http://llvm.org/releases/${LLVM_VERSION}/clang+llvm-${LLVM_VERSION}-x86_64-linux-gnu-ubuntu-14.04.tar.xz" + mkdir -p ${LLVM_DIR} ${LLVM_DIR}/build ${LLVM_DIR}/projects/libcxx ${LLVM_DIR}/projects/libcxxabi ${LLVM_DIR}/clang + travis_retry wget --quiet -O - ${LLVM_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR} + travis_retry wget --quiet -O - ${LIBCXX_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxx + travis_retry wget --quiet -O - ${LIBCXXABI_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/projects/libcxxabi + travis_retry wget --quiet -O - ${CLANG_URL} | tar --strip-components=1 -xJ -C ${LLVM_DIR}/clang + (cd ${LLVM_DIR}/build && cmake .. -DCMAKE_INSTALL_PREFIX=${LLVM_DIR}/install -DCMAKE_CXX_COMPILER=clang++) + (cd ${LLVM_DIR}/build/projects/libcxx && make install -j2) + (cd ${LLVM_DIR}/build/projects/libcxxabi && make install -j2) + fi + export CXXFLAGS="-nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1" + export LDFLAGS="-L ${LLVM_DIR}/install/lib -l c++ -l c++abi" + export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LLVM_DIR}/install/lib" + export PATH="${LLVM_DIR}/clang/bin:${PATH}" + fi ################ # build script # diff --git a/test/Makefile b/test/Makefile index 7bc8274f..8e1ad6a0 100644 --- a/test/Makefile +++ b/test/Makefile @@ -3,7 +3,7 @@ ########################################################################## # additional flags -CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wno-ctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wno-keyword-macro -Wno-float-equal +CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wno-ctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wno-float-equal CPPFLAGS += -I ../src -I . SOURCES = src/unit.cpp \ From 407e8dbb8e318033e905a7545b73c267cb9bae8c Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 16:25:35 +0200 Subject: [PATCH 07/17] fixed YAML error --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c102ab00..3cdf45f2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,9 +70,9 @@ matrix: # Linux / Clang - - os: linux - env: LLVM_VERSION=3.8.0 - compiler: clang + - os: linux + env: LLVM_VERSION=3.8.0 + compiler: clang ##################### # installation step # From 31963723d3692c22d7f4cb866e06a259ca23c6d9 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 16:35:57 +0200 Subject: [PATCH 08/17] no directory change --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3cdf45f2..de6e25b1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -85,7 +85,7 @@ cache: install: - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - - mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR} + - mkdir -p ${DEPS_DIR} - if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi From 997bc5d1ab216dbdf2877a7237aecae7c477ee52 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 16:56:05 +0200 Subject: [PATCH 09/17] more clang versions --- .travis.yml | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/.travis.yml b/.travis.yml index de6e25b1..b204d375 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,17 +70,62 @@ matrix: # Linux / Clang + - os: linux + env: LLVM_VERSION=3.5.0 + compiler: clang + + - os: linux + env: LLVM_VERSION=3.5.1 + compiler: clang + + - os: linux + env: LLVM_VERSION=3.5.2 + compiler: clang + + - os: linux + env: LLVM_VERSION=3.6.0 + compiler: clang + + - os: linux + env: LLVM_VERSION=3.6.1 + compiler: clang + + - os: linux + env: LLVM_VERSION=3.6.2 + compiler: clang + + - os: linux + env: LLVM_VERSION=3.7.0 + compiler: clang + + - os: linux + env: LLVM_VERSION=3.7.1 + compiler: clang + - os: linux env: LLVM_VERSION=3.8.0 compiler: clang + - os: linux + env: LLVM_VERSION=3.8.1 + compiler: clang + ##################### # installation step # ##################### cache: directories: + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.5.2 + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.5.1 + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.5.0 + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.2 + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.1 + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.0 + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.0 + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.7.1 - ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.0 + - ${TRAVIS_BUILD_DIR}/deps/llvm-3.8.1 install: From 4d90331718f015b7ee90d914690b9412d740fc0a Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 17:42:33 +0200 Subject: [PATCH 10/17] a test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b204d375..344aa219 100644 --- a/.travis.yml +++ b/.travis.yml @@ -151,7 +151,7 @@ install: (cd ${LLVM_DIR}/build/projects/libcxx && make install -j2) (cd ${LLVM_DIR}/build/projects/libcxxabi && make install -j2) fi - export CXXFLAGS="-nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1" + export CXXFLAGS="-stdlib=libc++ -nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1" export LDFLAGS="-L ${LLVM_DIR}/install/lib -l c++ -l c++abi" export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LLVM_DIR}/install/lib" export PATH="${LLVM_DIR}/clang/bin:${PATH}" From a2e923de32d04012f201c2cc8fe4b79e425b5608 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 18:38:31 +0200 Subject: [PATCH 11/17] removed clang 3.5.x --- .travis.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 344aa219..f1db0a25 100644 --- a/.travis.yml +++ b/.travis.yml @@ -70,18 +70,6 @@ matrix: # Linux / Clang - - os: linux - env: LLVM_VERSION=3.5.0 - compiler: clang - - - os: linux - env: LLVM_VERSION=3.5.1 - compiler: clang - - - os: linux - env: LLVM_VERSION=3.5.2 - compiler: clang - - os: linux env: LLVM_VERSION=3.6.0 compiler: clang @@ -116,9 +104,6 @@ matrix: cache: directories: - - ${TRAVIS_BUILD_DIR}/deps/llvm-3.5.2 - - ${TRAVIS_BUILD_DIR}/deps/llvm-3.5.1 - - ${TRAVIS_BUILD_DIR}/deps/llvm-3.5.0 - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.2 - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.1 - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.0 @@ -151,7 +136,7 @@ install: (cd ${LLVM_DIR}/build/projects/libcxx && make install -j2) (cd ${LLVM_DIR}/build/projects/libcxxabi && make install -j2) fi - export CXXFLAGS="-stdlib=libc++ -nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1" + export CXXFLAGS="-nostdinc++ -isystem ${LLVM_DIR}/install/include/c++/v1" export LDFLAGS="-L ${LLVM_DIR}/install/lib -l c++ -l c++abi" export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${LLVM_DIR}/install/lib" export PATH="${LLVM_DIR}/clang/bin:${PATH}" @@ -166,6 +151,9 @@ script: - $CXX --version - make - test/json_unit + - if [ `which valgrind` ]; then + valgrind --error-exitcode=1 --leak-check=full test/json_unit ; + fi - if [ `which brew` ]; then brew update ; brew tap nlohmann/json ; From efe1d52629b6d661b39cf1774285096c940f7ce5 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 18:54:19 +0200 Subject: [PATCH 12/17] added coverity, coveralls, and valgrind --- .travis.yml | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index f1db0a25..2e6d4a1c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,17 @@ dist: trusty sudo: required +################### +# global settings # +################### + +env: + global: + # The next declaration is the encrypted COVERITY_SCAN_TOKEN, created + # via the "travis encrypt" command using the project repo's public key + - secure: "m89SSgE+ASLO38rSKx7MTXK3n5NkP9bIx95jwY71YEiuFzib30PDJ/DifKnXxBjvy/AkCGztErQRk/8ZCvq+4HXozU2knEGnL/RUitvlwbhzfh2D4lmS3BvWBGS3N3NewoPBrRmdcvnT0xjOGXxtZaJ3P74TkB9GBnlz/HmKORA=" + + ################ # build matrix # ################ @@ -98,10 +109,66 @@ 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 # ##################### +# set directories to cache cache: directories: - ${TRAVIS_BUILD_DIR}/deps/llvm-3.6.2 @@ -114,11 +181,14 @@ cache: install: + # create deps dir if not existing - DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" - mkdir -p ${DEPS_DIR} + # make sure CXX is correctly set - if [[ "${COMPILER}" != "" ]]; then export CXX=${COMPILER}; fi + # install LLVM/clang when LLVM_VERSION is set - | if [[ "${LLVM_VERSION}" != "" ]]; then LLVM_DIR=${DEPS_DIR}/llvm-${LLVM_VERSION} @@ -147,13 +217,17 @@ install: ################ script: + # show OS/compiler version - uname -a - $CXX --version + + # compile - make - - test/json_unit - - if [ `which valgrind` ]; then - valgrind --error-exitcode=1 --leak-check=full test/json_unit ; - fi + + # execute unit tests + - test/json_unit "*" + + # check if homebrew works (only checks develop branch) - if [ `which brew` ]; then brew update ; brew tap nlohmann/json ; From ce30526ee8bdf057ac81d5fa0c0d00e7eb683c61 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 19:35:27 +0200 Subject: [PATCH 13/17] fixed Valgrind call --- .travis.yml | 131 +--------------------------------------------------- 1 file changed, 1 insertion(+), 130 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2e6d4a1c..903a4c58 100644 --- a/.travis.yml +++ b/.travis.yml @@ -121,7 +121,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: [g++-4.9, valgrind] after_success: - - valgrind --error-exitcode=1 --leak-check=full test/json_unit * ; + - valgrind --error-exitcode=1 --leak-check=full test/json_unit "*" ; # Coveralls @@ -282,132 +282,3 @@ script: # branch_pattern: coverity_scan # env: COMPILER=g++-5 # -# - os: linux -# compiler: gcc -# addons: -# apt: -# sources: ['ubuntu-toolchain-r-test'] -# packages: ['g++-6', 'valgrind'] -# env: COMPILER=g++-6 -# -# # from https://github.com/travis-ci/travis-ci/issues/6120 -# - os: linux -# env: -# - LLVM_VERSION=3.8.0 -# - LLVM_ARCHIVE_PATH=$HOME/clang+llvm.tar.xz -# - COMPILER=clang++ -# - CPPFLAGS="-I $HOME/clang-$LLVM_VERSION/include/c++/v1" -# - LDFLAGS=-lc++ -# - PATH=$HOME/clang-$LLVM_VERSION/bin:$PATH -# - LD_LIBRARY_PATH=$HOME/clang-$LLVM_VERSION/lib:$LD_LIBRARY_PATH -# before_install: -# - wget http://llvm.org/releases/$LLVM_VERSION/clang+llvm-$LLVM_VERSION-x86_64-linux-gnu-ubuntu-14.04.tar.xz -O $LLVM_ARCHIVE_PATH -# - mkdir $HOME/clang-$LLVM_VERSION -# - tar xf $LLVM_ARCHIVE_PATH -C $HOME/clang-$LLVM_VERSION --strip-components 1 -# -# # Clang 3.5 is not able to compile the code, -# # see https://travis-ci.org/nlohmann/json/jobs/126720186 -# -## - os: linux -## compiler: clang -## addons: -## apt: -## sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6'] -## packages: ['clang-3.6', 'valgrind'] -## env: COMPILER=clang++-3.6 -## -## - os: linux -## compiler: clang -## addons: -## apt: -## sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7'] -## packages: ['clang-3.7', 'valgrind'] -## env: COMPILER=clang++-3.7 -## -## - os: linux -## compiler: clang -## addons: -## apt: -## sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.8'] -## packages: ['clang-3.8', 'valgrind'] -## env: COMPILER=clang++-3.8 -# -# # - os: linux -# # compiler: clang -# # addons: -# # apt: -# # sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise'] -# # packages: ['clang-3.9', 'valgrind'] -# # env: COMPILER=clang++-3.9 -# -# - os: osx -# osx_image: beta-xcode6.1 -# compiler: clang -# env: -# - COMPILER=clang -# - CXXFLAGS=-lstdc++ -# -# - os: osx -# osx_image: beta-xcode6.2 -# compiler: clang -# env: -# - COMPILER=clang -# - CXXFLAGS=-lstdc++ -# -# - os: osx -# osx_image: beta-xcode6.3 -# compiler: clang -# env: -# - COMPILER=clang -# - CXXFLAGS=-lstdc++ -# -# - os: osx -# osx_image: xcode6.4 -# compiler: clang -# env: -# - COMPILER=clang -# - CXXFLAGS=-lstdc++ -# -# - os: osx -# osx_image: xcode7.1 -# compiler: clang -# env: -# - COMPILER=clang -# - CXXFLAGS=-lstdc++ -# -# - os: osx -# osx_image: xcode7.2 -# compiler: clang -# env: -# - COMPILER=clang -# - CXXFLAGS=-lstdc++ -# -# - os: osx -# osx_image: xcode7.3 -# compiler: clang -# env: -# - COMPILER=clang -# - CXXFLAGS=-lstdc++ -# -# - os: osx -# osx_image: xcode8 -# compiler: clang -# env: -# - COMPILER=clang -# - CXXFLAGS=-lstdc++ -# -#script: -# - uname -a -# - $COMPILER --version -# - make CXX=$COMPILER -# - test/json_unit "*" -# - if [ `which valgrind` ]; then -# valgrind --error-exitcode=1 --leak-check=full test/json_unit ; -# fi -# - if [ `which brew` ]; then -# brew update ; -# brew tap nlohmann/json ; -# brew install nlohmann_json --HEAD ; -# brew test nlohmann_json ; -# fi -# \ No newline at end of file From d02e67d4a957d050ab4233209c452fdf433b238a Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 20:56:26 +0200 Subject: [PATCH 14/17] 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 b82214e9..c7e847c4 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 903a4c58..03da02d5 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 8e1ad6a0..ead1f073 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) From 1c4ca6d7b1ca3caec06ca81f57abb1b2e15c41e7 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 21:00:36 +0200 Subject: [PATCH 15/17] rubygems -> ruby --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 03da02d5..ce3fc057 100644 --- a/.travis.yml +++ b/.travis.yml @@ -66,7 +66,7 @@ matrix: addons: apt: sources: ['ubuntu-toolchain-r-test'] - packages: ['g++-4.9', 'rubygems'] + packages: ['g++-4.9', 'ruby'] 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 From 5db41313ba4b8652c90af2294871a662387210e9 Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 21:33:03 +0200 Subject: [PATCH 16/17] valgrind + full unit tests takes too long --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index ce3fc057..59f07481 100644 --- a/.travis.yml +++ b/.travis.yml @@ -39,7 +39,7 @@ matrix: sources: ['ubuntu-toolchain-r-test'] packages: [g++-4.9, valgrind] after_success: - - valgrind --error-exitcode=1 --leak-check=full test/json_unit -s "*" ; + - valgrind --error-exitcode=1 --leak-check=full test/json_unit # Coveralls From 46174879efbd6bad0c8d5105429562ab3cb1e9df Mon Sep 17 00:00:00 2001 From: Niels Date: Wed, 10 Aug 2016 22:41:09 +0200 Subject: [PATCH 17/17] clean up --- .travis.yml | 20 +--- README.md | 8 +- test/src/unit-pointer_access.cpp | 190 ++++++++++++++++++++++++++++++- 3 files changed, 193 insertions(+), 25 deletions(-) diff --git a/.travis.yml b/.travis.yml index 59f07481..ad1d12d9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,25 +41,7 @@ matrix: 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 + # Coveralls (http://gronlier.fr/blog/2015/01/adding-code-coverage-to-your-c-project/) - os: linux compiler: gcc diff --git a/README.md b/README.md index 722bf880..c6fa73b4 100644 --- a/README.md +++ b/README.md @@ -416,7 +416,13 @@ The following compilers are currently used in continuous integration at [Travis] | GCC 4.9.3 | Ubuntu 14.04.4 LTS | g++-4.9 (Ubuntu 4.9.3-8ubuntu2~14.04) 4.9.3 | | GCC 5.3.0 | Ubuntu 14.04.4 LTS | g++-5 (Ubuntu 5.3.0-3ubuntu1~14.04) 5.3.0 20151204 | | GCC 6.1.1 | Ubuntu 14.04.4 LTS | g++-6 (Ubuntu 6.1.1-3ubuntu11~14.04.1) 6.1.1 20160511 | +| Clang 3.6.0 | Ubuntu 14.04.4 LTS | clang version 3.6.0 (tags/RELEASE_360/final) | +| Clang 3.6.1 | Ubuntu 14.04.4 LTS | clang version 3.6.1 (tags/RELEASE_361/final) | +| Clang 3.6.2 | Ubuntu 14.04.4 LTS | clang version 3.6.2 (tags/RELEASE_362/final) | +| Clang 3.7.0 | Ubuntu 14.04.4 LTS | clang version 3.7.0 (tags/RELEASE_370/final) | +| Clang 3.7.1 | Ubuntu 14.04.4 LTS | clang version 3.7.1 (tags/RELEASE_371/final) | | Clang 3.8.0 | Ubuntu 14.04.4 LTS | clang version 3.8.0 (tags/RELEASE_380/final) | +| Clang 3.8.1 | Ubuntu 14.04.4 LTS | clang version 3.8.1 (tags/RELEASE_381/final) | | Clang Xcode 6.1 | Darwin Kernel Version 13.4.0 (OSX 10.9.5) | Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) | | Clang Xcode 6.2 | Darwin Kernel Version 13.4.0 (OSX 10.9.5) | Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn) | | Clang Xcode 6.3 | Darwin Kernel Version 14.3.0 (OSX 10.10.3) | Apple LLVM version 6.1.0 (clang-602.0.49) (based on LLVM 3.6.0svn) | @@ -504,7 +510,7 @@ To compile and run the tests, you need to execute $ make check =============================================================================== -All tests passed (8905012 assertions in 32 test cases) +All tests passed (8905099 assertions in 32 test cases) ``` For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml). diff --git a/test/src/unit-pointer_access.cpp b/test/src/unit-pointer_access.cpp index bae9ee4c..9353b5b0 100644 --- a/test/src/unit-pointer_access.cpp +++ b/test/src/unit-pointer_access.cpp @@ -79,18 +79,30 @@ TEST_CASE("pointer access") SECTION("pointer access to const object_t") { - using test_type = json::object_t; + using test_type = const json::object_t; const json value = {{"one", 1}, {"two", 2}}; - // this should not compile - // test_type* p1 = value.get_ptr(); - // check if pointers are returned correctly + test_type* p1 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p1 == value.get()); + const test_type* p2 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); CHECK(*p2 == value.get()); const test_type* const p3 = value.get_ptr(); - CHECK(p2 == p3); + CHECK(p1 == value.get_ptr()); + CHECK(*p3 == value.get()); + + // check if null pointers are returned correctly + CHECK(value.get_ptr() != nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); } SECTION("pointer access to array_t") @@ -121,6 +133,34 @@ TEST_CASE("pointer access") CHECK(value.get_ptr() == nullptr); } + SECTION("pointer access to const array_t") + { + using test_type = const json::array_t; + const json value = {1, 2, 3, 4}; + + // check if pointers are returned correctly + test_type* p1 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p1 == value.get()); + + const test_type* p2 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p2 == value.get()); + + const test_type* const p3 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p3 == value.get()); + + // check if null pointers are returned correctly + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() != nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + } + SECTION("pointer access to string_t") { using test_type = json::string_t; @@ -149,6 +189,34 @@ TEST_CASE("pointer access") CHECK(value.get_ptr() == nullptr); } + SECTION("pointer access to const string_t") + { + using test_type = const json::string_t; + const json value = "hello"; + + // check if pointers are returned correctly + test_type* p1 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p1 == value.get()); + + const test_type* p2 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p2 == value.get()); + + const test_type* const p3 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p3 == value.get()); + + // check if null pointers are returned correctly + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() != nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + } + SECTION("pointer access to boolean_t") { using test_type = json::boolean_t; @@ -177,6 +245,34 @@ TEST_CASE("pointer access") CHECK(value.get_ptr() == nullptr); } + SECTION("pointer access to const boolean_t") + { + using test_type = const json::boolean_t; + const json value = false; + + // check if pointers are returned correctly + test_type* p1 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + //CHECK(*p1 == value.get()); + + const test_type* p2 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + //CHECK(*p2 == value.get()); + + const test_type* const p3 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + //CHECK(*p3 == value.get()); + + // check if null pointers are returned correctly + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() != nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + } + SECTION("pointer access to number_integer_t") { using test_type = json::number_integer_t; @@ -205,6 +301,34 @@ TEST_CASE("pointer access") CHECK(value.get_ptr() == nullptr); } + SECTION("pointer access to const number_integer_t") + { + using test_type = const json::number_integer_t; + const json value = 23; + + // check if pointers are returned correctly + test_type* p1 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p1 == value.get()); + + const test_type* p2 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p2 == value.get()); + + const test_type* const p3 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p3 == value.get()); + + // check if null pointers are returned correctly + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() != nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + } + SECTION("pointer access to number_unsigned_t") { using test_type = json::number_unsigned_t; @@ -233,6 +357,34 @@ TEST_CASE("pointer access") CHECK(value.get_ptr() == nullptr); } + SECTION("pointer access to const number_unsigned_t") + { + using test_type = const json::number_unsigned_t; + const json value = 23u; + + // check if pointers are returned correctly + test_type* p1 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p1 == value.get()); + + const test_type* p2 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p2 == value.get()); + + const test_type* const p3 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p3 == value.get()); + + // check if null pointers are returned correctly + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() != nullptr); + CHECK(value.get_ptr() != nullptr); + CHECK(value.get_ptr() == nullptr); + } + SECTION("pointer access to number_float_t") { using test_type = json::number_float_t; @@ -260,4 +412,32 @@ TEST_CASE("pointer access") CHECK(value.get_ptr() == nullptr); CHECK(value.get_ptr() != nullptr); } + + SECTION("pointer access to const number_float_t") + { + using test_type = const json::number_float_t; + const json value = 42.23; + + // check if pointers are returned correctly + test_type* p1 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p1 == Approx(value.get())); + + const test_type* p2 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p2 == Approx(value.get())); + + const test_type* const p3 = value.get_ptr(); + CHECK(p1 == value.get_ptr()); + CHECK(*p3 == Approx(value.get())); + + // check if null pointers are returned correctly + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() == nullptr); + CHECK(value.get_ptr() != nullptr); + } }