Skip to content

Commit

Permalink
Merge branch 'feature/individual_tests' into feature/messagepack
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Nov 27, 2016
2 parents 93589e6 + 2477b09 commit 56843eb
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 64 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ benchmarks/files/numbers/*.json
.idea
cmake-build-debug


test/test-*
60 changes: 5 additions & 55 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
- make check TEST_PREFIX="valgrind --error-exitcode=1 --leak-check=full " TEST_PATTERN=""

# cppcheck

Expand Down Expand Up @@ -68,9 +68,10 @@ matrix:
- tar xf lcov_1.11.orig.tar.gz
- sudo make -C lcov-1.11/ install
- gem install coveralls-lcov
- pip install --user cpp-coveralls
after_success:
- make clean
- CXXFLAGS="--coverage -g -O0" CPPFLAGS="-DNDEBUG" make
- CXXFLAGS="--coverage -g -O0" CPPFLAGS="-DNDEBUG" make json_unit
- 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
Expand Down Expand Up @@ -248,11 +249,8 @@ script:
- uname -a
- $CXX --version

# compile
- make

# execute unit tests
- test/json_unit "*"
# compile and execute unit tests
- make check

# check if homebrew works (only checks develop branch)
- if [ `which brew` ]; then
Expand All @@ -261,51 +259,3 @@ script:
brew install nlohmann_json --HEAD ;
brew test nlohmann_json ;
fi

#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: [email protected]
# build_command_prepend: "make clean ; sudo cp $(which g++-5) $(which g++)"
# build_command: "make"
# branch_pattern: coverity_scan
# env: COMPILER=g++-5
#
14 changes: 8 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ RE2C = re2c
SED = sed

# main target
all: json_unit
all:
$(MAKE) -C test

# clean up
clean:
Expand All @@ -21,14 +22,14 @@ clean:

# build unit tests
json_unit:
@$(MAKE) -C test
@$(MAKE) json_unit -C test

# run unit tests
check: json_unit
test/json_unit "*"
check:
$(MAKE) check -C test

check-fast: json_unit
test/json_unit
check-fast:
$(MAKE) check -C test TEST_PATTERN=""


##########################################################################
Expand Down Expand Up @@ -69,6 +70,7 @@ cppcheck:
clang_sanitize: clean
CXX=clang++ CXXFLAGS="-g -O2 -fsanitize=address -fsanitize=undefined -fno-omit-frame-pointer" $(MAKE)


##########################################################################
# maintainer targets
##########################################################################
Expand Down
30 changes: 27 additions & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,20 @@ SOURCES = src/unit.cpp \

OBJECTS = $(SOURCES:.cpp=.o)

all: json_unit
TESTCASES = $(patsubst src/unit-%.cpp,test-%,$(wildcard src/unit-*.cpp))

##############################################################################
# main rules
##############################################################################

all: $(TESTCASES)

clean:
rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda) $(TESTCASES)

##############################################################################
# single test file
##############################################################################

json_unit: $(OBJECTS) ../src/json.hpp src/catch.hpp
@echo "[CXXLD] $@"
Expand All @@ -52,5 +65,16 @@ json_unit: $(OBJECTS) ../src/json.hpp src/catch.hpp
@echo "[CXX] $@"
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@

clean:
rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda)

##############################################################################
# individual test cases
##############################################################################

test-%: src/unit-%.cpp
@echo "[CXXLD] $@"
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -DCATCH_CONFIG_MAIN $< -o $@

TEST_PATTERN = "*"
TEST_PREFIX = ""
check: $(TESTCASES)
@cd .. ; for testcase in $(TESTCASES); do echo "Executing $$testcase..."; $(TEST_PREFIX)test/$$testcase $(TEST_PATTERN) -r compact; done

0 comments on commit 56843eb

Please sign in to comment.