Skip to content
This repository has been archived by the owner on Apr 6, 2023. It is now read-only.

Commit

Permalink
add test infrastructure
Browse files Browse the repository at this point in the history
  • Loading branch information
badaix committed Aug 2, 2021
1 parent 9a6615e commit c6703b5
Show file tree
Hide file tree
Showing 8 changed files with 17,604 additions and 15 deletions.
87 changes: 77 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,16 @@ matrix:
- ubuntu-toolchain-r-test
packages:
- g++-4.9
- build-essential cmake
env:
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"

- os: linux
sudo: required
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-5
- build-essential cmake
env:
- MATRIX_EVAL="CC=gcc-5 && CXX=g++-5"

Expand All @@ -35,32 +32,102 @@ matrix:
- ubuntu-toolchain-r-test
packages:
- g++-6
- build-essential cmake
env:
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"

- os: linux
sudo: required
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- g++-7
- build-essential cmake
env:
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.6
packages:
- clang-3.6
env:
- MATRIX_EVAL="CC=clang-3.6 && CXX=clang++-3.6"

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.7
packages:
- clang-3.7
env:
- MATRIX_EVAL="CC=clang-3.7 && CXX=clang++-3.7"

# works on Precise and Trusty
- os: linux
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
packages:
- clang-3.8
env:
- MATRIX_EVAL="CC=clang-3.8 && CXX=clang++-3.8"

# works on Trusty
- os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-3.9
packages:
- clang-3.9
env:
- MATRIX_EVAL="CC=clang-3.9 && CXX=clang++-3.9"

# works on Trusty
- os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-4.0
packages:
- clang-4.0
env:
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"

# works on Trusty
- os: linux
addons:
apt:
sources:
- llvm-toolchain-trusty-5.0
packages:
- clang-5.0
env:
- MATRIX_EVAL="CC=clang-5.0 && CXX=clang++-5.0"

# build on osx
- os: osx
osx_image: xcode8
osx_image: xcode9.4

- os: osx
osx_image: xcode10.3

- os: osx
osx_image: xcode9.1
osx_image: xcode11

before_install:
- eval "${MATRIX_EVAL}"

script:
- mkdir build
- cd build
- cmake .. && make
- cmake .. && make && ./example/popl_example && ./test/popl_test
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ set(PROJECT_DESCRIPTION "Header-only C++ program options parser library")
set(PROJECT_URL "https://github.com/badaix/popl")

option(BUILD_EXAMPLE "Build example (build popl_example demo)" ON)
option(BUILD_TESTS "Build tests" ON)


if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
Expand All @@ -40,10 +41,13 @@ include_directories(
"include"
)

install(FILES include/popl.hpp DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")

if (BUILD_EXAMPLE)
add_executable(popl_example popl_example.cpp)
add_subdirectory(example)
endif (BUILD_EXAMPLE)


install(FILES include/popl.hpp DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
if (BUILD_TESTS)
add_subdirectory(test)
endif (BUILD_TESTS)

2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SHELL = /bin/bash
CXX = /usr/bin/g++
CXXFLAGS = -Wall -O3 -std=c++11 -Iinclude -pedantic -Wextra -Wshadow -Wconversion

OBJ = popl_example.o
OBJ = example/popl_example.o
BIN = popl_example

all: $(TARGET)
Expand Down
1 change: 1 addition & 0 deletions example/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
add_executable(popl_example popl_example.cpp)
2 changes: 1 addition & 1 deletion popl_example.cpp → example/popl_example.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/***
This file is part of popl (program options parser lib)
Copyright (C) 2015-2018 Johannes Pohl
Copyright (C) 2015-2019 Johannes Pohl
This software may be modified and distributed under the terms
of the MIT license. See the LICENSE file for details.
Expand Down
10 changes: 10 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Prepare "Catch" library for other executables
set(CATCH_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE ${CATCH_INCLUDE_DIR})

# Make test executable
set(TEST_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/test_main.cpp)
add_executable(jsonrpcpp_test ${TEST_SOURCES})
target_link_libraries(jsonrpcpp_test Catch)

Loading

0 comments on commit c6703b5

Please sign in to comment.