Redo build matrix on .travis for C++14 and up

* Use Xenial as the base distribution
* Remove C++11 builds
* Add a lot more C++14 builds
* Add some C++17 builds
* Include newer versions of Clang and GCC
This commit is contained in:
Martin Hořeňovský 2019-10-29 23:38:21 +01:00
parent 7c48ea6016
commit 2c6ace04a7
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
5 changed files with 103 additions and 199 deletions

View File

@ -8,4 +8,4 @@ find_package(Catch2 REQUIRED CONFIG)
add_executable(${PROJECT_NAME} test_package.cpp) add_executable(${PROJECT_NAME} test_package.cpp)
target_link_libraries(${PROJECT_NAME} CONAN_PKG::Catch2) target_link_libraries(${PROJECT_NAME} CONAN_PKG::Catch2)
set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 11) set_target_properties(${PROJECT_NAME} PROPERTIES CXX_STANDARD 14)

View File

@ -1,4 +1,6 @@
language: cpp language: cpp
dist: xenial
branches: branches:
except: except:
@ -6,128 +8,25 @@ branches:
common_sources: &all_sources common_sources: &all_sources
- ubuntu-toolchain-r-test - ubuntu-toolchain-r-test
- llvm-toolchain-trusty - llvm-toolchain-xenial
- llvm-toolchain-trusty-3.9 - llvm-toolchain-xenial-3.8
- llvm-toolchain-trusty-4.0 - llvm-toolchain-xenial-3.9
- llvm-toolchain-xenial-4.0
- llvm-toolchain-xenial-5.0 - llvm-toolchain-xenial-5.0
- llvm-toolchain-xenial-6.0 - llvm-toolchain-xenial-6.0
- llvm-toolchain-xenial-7
- llvm-toolchain-xenial-8
matrix: matrix:
include: include:
# Clang builds
# 1/ Linux Clang Builds
- os: linux - os: linux
compiler: clang compiler: clang
addons: addons:
apt: apt:
sources: *all_sources sources: *all_sources
packages: ['clang-3.5'] packages: ['clang-3.8']
env: COMPILER='clang++-3.5'
- os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-3.6']
env: COMPILER='clang++-3.6'
# Clang 3.7 is intentionally skipped as we cannot get it easily on
# TravisCI container
- os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['lcov', 'clang-3.8']
env: COMPILER='clang++-3.8'
- os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-3.9']
env: COMPILER='clang++-3.9'
- os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-4.0']
env: COMPILER='clang++-4.0'
- os: linux
dist: xenial
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-5.0']
env: COMPILER='clang++-5.0'
- os: linux
dist: xenial
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-6.0']
env: COMPILER='clang++-6.0'
# 2/ Linux GCC Builds
- os: linux
compiler: gcc
addons:
apt:
sources: *all_sources
packages: ['g++-4.9']
env: COMPILER='g++-4.9'
- os: linux
compiler: gcc
addons:
apt:
sources: *all_sources
packages: ['g++-5']
env: COMPILER='g++-5'
- os: linux
compiler: gcc
addons: &gcc6
apt:
sources: *all_sources
packages: ['g++-6']
env: COMPILER='g++-6'
- os: linux
compiler: gcc
addons: &gcc7
apt:
sources: *all_sources
packages: ['g++-7']
env: COMPILER='g++-7'
- os: linux
compiler: gcc
addons: &gcc8
apt:
sources: *all_sources
packages: ['g++-8']
env: COMPILER='g++-8'
# 3b/ Linux C++14 Clang builds
# Note that we need newer libstdc++ for C++14 support
- os: linux
compiler: clang
addons:
apt:
packages: ['clang-3.8', 'libstdc++-6-dev']
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty
env: COMPILER='clang++-3.8' CPP14=1 env: COMPILER='clang++-3.8' CPP14=1
- os: linux - os: linux
@ -135,7 +34,15 @@ matrix:
addons: addons:
apt: apt:
sources: *all_sources sources: *all_sources
packages: ['clang-3.9', 'libstdc++-6-dev'] packages: ['clang-3.8', 'lcov']
env: COMPILER='clang++-3.8' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
- os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-3.9']
env: COMPILER='clang++-3.9' CPP14=1 env: COMPILER='clang++-3.9' CPP14=1
- os: linux - os: linux
@ -143,45 +50,100 @@ matrix:
addons: addons:
apt: apt:
sources: *all_sources sources: *all_sources
packages: ['clang-4.0', 'libstdc++-6-dev'] packages: ['clang-4.0']
env: COMPILER='clang++-4.0' CPP14=1 env: COMPILER='clang++-4.0' CPP14=1
- os: linux - os: linux
dist: xenial
compiler: clang compiler: clang
addons: addons:
apt: apt:
sources: *all_sources sources: *all_sources
packages: ['clang-5.0', 'libstdc++-6-dev'] packages: ['clang-5.0']
env: COMPILER='clang++-5.0' CPP14=1 env: COMPILER='clang++-5.0' CPP14=1
- os: linux - os: linux
dist: xenial
compiler: clang compiler: clang
addons: addons:
apt: apt:
sources: *all_sources sources: *all_sources
packages: ['clang-6.0', 'libstdc++-6-dev'] packages: ['clang-6.0']
env: COMPILER='clang++-6.0' CPP14=1 env: COMPILER='clang++-6.0' CPP14=1
- os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-6.0', 'libstdc++-8-dev']
env: COMPILER='clang++-6.0' CPP17=1
# 4a/ Linux C++14 GCC builds - os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-7']
env: COMPILER='clang++-7' CPP14=1
- os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-8']
env: COMPILER='clang++-8' CPP14=1
- os: linux
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-8', 'libstdc++-8-dev']
env: COMPILER='clang++-8' CPP17=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
# GCC builds
- os: linux - os: linux
compiler: gcc compiler: gcc
addons: *gcc6 addons:
apt:
sources: *all_sources
packages: ['g++-4.9']
env: COMPILER='g++-4.9' CPP14=1
- os: linux
compiler: gcc
addons:
apt:
sources: *all_sources
packages: ['g++-5']
env: COMPILER='g++-5' CPP14=1
- os: linux
compiler: gcc
addons:
apt:
sources: *all_sources
packages: ['g++-6']
env: COMPILER='g++-6' CPP14=1 env: COMPILER='g++-6' CPP14=1
- os: linux - os: linux
compiler: gcc compiler: gcc
addons: *gcc7 addons:
env: COMPILER='g++-7' CPP14=1 apt:
sources: *all_sources
packages: ['g++-7', 'lcov']
env: COMPILER='g++-7' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
- os: linux - os: linux
compiler: gcc compiler: gcc
addons: *gcc8 addons:
env: COMPILER='g++-8' CPP14=1 apt:
sources: *all_sources
packages: ['g++-8']
env: COMPILER='g++-8' CPP17=1
# 5/ OSX Clang Builds # OSX Clang Builds
- os: osx - os: osx
osx_image: xcode9.4 osx_image: xcode9.4
compiler: clang compiler: clang
@ -203,87 +165,20 @@ matrix:
env: COMPILER='clang++' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1 env: COMPILER='clang++' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
# 6/ Special builds -- examples, coverage, valgrind, etc.
- os: linux
compiler: gcc
addons:
apt:
sources: *all_sources
packages: ['lcov', 'g++-7']
env: COMPILER='g++-7' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
- os: linux # Special builds, e.g. conan
compiler: clang
addons:
apt:
packages: ['clang-3.8', 'lcov']
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty
env: COMPILER='clang++-3.8' EXAMPLES=1 COVERAGE=1 EXTRAS=1
- os: linux
compiler: gcc
addons:
apt:
sources: *all_sources
packages: ['valgrind', 'lcov', 'g++-7']
env: COMPILER='g++-7' CPP14=1 VALGRIND=1
# 7/ C++17 builds
- os: linux
compiler: gcc
addons: *gcc7
env: COMPILER='g++-7' CPP17=1
- os: linux
compiler: gcc
addons: *gcc7
env: COMPILER='g++-7' EXAMPLES=1 COVERAGE=1 EXTRAS=1 CPP17=1
- os: linux
dist: xenial
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-6.0', 'libstdc++-8-dev']
env: COMPILER='clang++-6.0' CPP17=1
- os: linux
dist: xenial
compiler: clang
addons:
apt:
sources: *all_sources
packages: ['clang-6.0', 'libstdc++-8-dev']
env: COMPILER='clang++-6.0' CPP17=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1
# 8/ Conan
- language: python - language: python
python: python:
- "3.7" - "3.7"
dist: xenial
install: install:
- pip install conan-package-tools - pip install conan-package-tools
env: env:
- CONAN_GCC_VERSIONS=8 - CONAN_GCC_VERSIONS=8
- CONAN_DOCKER_IMAGE=conanio/gcc8 - CONAN_DOCKER_IMAGE=conanio/gcc8
- CPP14=1
script: script:
- python .conan/build.py - python .conan/build.py
install:
- DEPS_DIR="${TRAVIS_BUILD_DIR}/deps"
- mkdir -p ${DEPS_DIR} && cd ${DEPS_DIR}
- |
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
CMAKE_URL="http://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.tar.gz"
mkdir cmake && travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C cmake
export PATH=${DEPS_DIR}/cmake/bin:${PATH}
elif [[ "${TRAVIS_OS_NAME}" == "osx" ]]; then
which cmake || brew install cmake;
fi
before_script: before_script:
- export CXX=${COMPILER} - export CXX=${COMPILER}
- cd ${TRAVIS_BUILD_DIR} - cd ${TRAVIS_BUILD_DIR}
@ -296,7 +191,7 @@ before_script:
elif [[ ${CPP14} -eq 1 ]]; then elif [[ ${CPP14} -eq 1 ]]; then
export CPP_STANDARD=14 export CPP_STANDARD=14
else else
export CPP_STANDARD=11 travis_terminate 4;
fi fi
# Use Debug builds for running Valgrind and building examples # Use Debug builds for running Valgrind and building examples

View File

@ -10,11 +10,12 @@
#define CATCH_CONFIG_MAIN #define CATCH_CONFIG_MAIN
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
class out_buff : public std::stringbuf { class out_buff : public std::stringbuf {
std::FILE* m_stream; std::FILE* m_stream;
public: public:
out_buff(std::FILE* stream) :m_stream(stream) {} out_buff(std::FILE* stream):m_stream(stream) {}
~out_buff() { pubsync(); } ~out_buff();
int sync() { int sync() {
int ret = 0; int ret = 0;
for (unsigned char c : str()) { for (unsigned char c : str()) {
@ -29,6 +30,12 @@ public:
} }
}; };
out_buff::~out_buff() { pubsync(); }
#if defined(__clang__)
#pragma clang diagnostic ignored "-Wexit-time-destructors" // static variables in cout/cerr/clog
#endif
namespace Catch { namespace Catch {
std::ostream& cout() { std::ostream& cout() {
static std::ostream ret(new out_buff(stdout)); static std::ostream ret(new out_buff(stdout));

View File

@ -22,15 +22,17 @@ public:
} }
} }
std::string const& get() const override { std::string const& get() const override;
return m_line;
}
bool next() override { bool next() override {
return !!std::getline(m_stream, m_line); return !!std::getline(m_stream, m_line);
} }
}; };
std::string const& LineGenerator::get() const {
return m_line;
}
// This helper function provides a nicer UX when instantiating the generator // This helper function provides a nicer UX when instantiating the generator
// Notice that it returns an instance of GeneratorWrapper<std::string>, which // Notice that it returns an instance of GeneratorWrapper<std::string>, which
// is a value-wrapper around std::unique_ptr<IGenerator<std::string>>. // is a value-wrapper around std::unique_ptr<IGenerator<std::string>>.

View File

@ -9,12 +9,12 @@
// We need 2 types with non-trivial copies/moves // We need 2 types with non-trivial copies/moves
struct MyType1 { struct MyType1 {
MyType1() = default; MyType1() = default;
MyType1(MyType1 const&) { throw 1; } [[noreturn]] MyType1(MyType1 const&) { throw 1; }
MyType1& operator=(MyType1 const&) { throw 3; } MyType1& operator=(MyType1 const&) { throw 3; }
}; };
struct MyType2 { struct MyType2 {
MyType2() = default; MyType2() = default;
MyType2(MyType2 const&) { throw 2; } [[noreturn]] MyType2(MyType2 const&) { throw 2; }
MyType2& operator=(MyType2 const&) { throw 4; } MyType2& operator=(MyType2 const&) { throw 4; }
}; };