From 2c6ace04a74458003506befea9291f5e60078bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 29 Oct 2019 23:38:21 +0100 Subject: [PATCH] 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 --- .conan/test_package/CMakeLists.txt | 2 +- .travis.yml | 277 ++++++------------ examples/231-Cfg-OutputStreams.cpp | 11 +- examples/301-Gen-MapTypeConversion.cpp | 8 +- .../UsageTests/ToStringVariant.tests.cpp | 4 +- 5 files changed, 103 insertions(+), 199 deletions(-) diff --git a/.conan/test_package/CMakeLists.txt b/.conan/test_package/CMakeLists.txt index db056599..1cd751ae 100644 --- a/.conan/test_package/CMakeLists.txt +++ b/.conan/test_package/CMakeLists.txt @@ -8,4 +8,4 @@ find_package(Catch2 REQUIRED CONFIG) add_executable(${PROJECT_NAME} test_package.cpp) 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) diff --git a/.travis.yml b/.travis.yml index ffd785ed..1fca40b8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,6 @@ language: cpp +dist: xenial + branches: except: @@ -6,42 +8,34 @@ branches: common_sources: &all_sources - ubuntu-toolchain-r-test - - llvm-toolchain-trusty - - llvm-toolchain-trusty-3.9 - - llvm-toolchain-trusty-4.0 + - llvm-toolchain-xenial + - llvm-toolchain-xenial-3.8 + - llvm-toolchain-xenial-3.9 + - llvm-toolchain-xenial-4.0 - llvm-toolchain-xenial-5.0 - llvm-toolchain-xenial-6.0 + - llvm-toolchain-xenial-7 + - llvm-toolchain-xenial-8 + matrix: include: - - # 1/ Linux Clang Builds + # Clang builds - os: linux compiler: clang addons: - apt: - sources: *all_sources - packages: ['clang-3.5'] - env: COMPILER='clang++-3.5' + apt: + sources: *all_sources + packages: ['clang-3.8'] + env: COMPILER='clang++-3.8' CPP14=1 - 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' + packages: ['clang-3.8', 'lcov'] + env: COMPILER='clang++-3.8' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1 - os: linux compiler: clang @@ -49,93 +43,6 @@ matrix: 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 - - - os: linux - compiler: clang - addons: - apt: - sources: *all_sources - packages: ['clang-3.9', 'libstdc++-6-dev'] env: COMPILER='clang++-3.9' CPP14=1 - os: linux @@ -143,45 +50,100 @@ matrix: addons: apt: sources: *all_sources - packages: ['clang-4.0', 'libstdc++-6-dev'] + packages: ['clang-4.0'] env: COMPILER='clang++-4.0' CPP14=1 - os: linux - dist: xenial compiler: clang addons: apt: sources: *all_sources - packages: ['clang-5.0', 'libstdc++-6-dev'] + packages: ['clang-5.0'] env: COMPILER='clang++-5.0' CPP14=1 - os: linux - dist: xenial compiler: clang addons: apt: sources: *all_sources - packages: ['clang-6.0', 'libstdc++-6-dev'] + packages: ['clang-6.0'] 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 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 - os: linux compiler: gcc - addons: *gcc7 - env: COMPILER='g++-7' CPP14=1 + addons: + apt: + sources: *all_sources + packages: ['g++-7', 'lcov'] + env: COMPILER='g++-7' CPP14=1 EXAMPLES=1 COVERAGE=1 EXTRAS=1 - os: linux compiler: gcc - addons: *gcc8 - env: COMPILER='g++-8' CPP14=1 + addons: + apt: + sources: *all_sources + packages: ['g++-8'] + env: COMPILER='g++-8' CPP17=1 - # 5/ OSX Clang Builds + # OSX Clang Builds - os: osx osx_image: xcode9.4 compiler: clang @@ -203,87 +165,20 @@ matrix: 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 - 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 + # Special builds, e.g. conan - language: python python: - "3.7" - dist: xenial install: - pip install conan-package-tools env: - CONAN_GCC_VERSIONS=8 - CONAN_DOCKER_IMAGE=conanio/gcc8 + - CPP14=1 script: - 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: - export CXX=${COMPILER} - cd ${TRAVIS_BUILD_DIR} @@ -296,7 +191,7 @@ before_script: elif [[ ${CPP14} -eq 1 ]]; then export CPP_STANDARD=14 else - export CPP_STANDARD=11 + travis_terminate 4; fi # Use Debug builds for running Valgrind and building examples diff --git a/examples/231-Cfg-OutputStreams.cpp b/examples/231-Cfg-OutputStreams.cpp index efa99971..2f42c297 100644 --- a/examples/231-Cfg-OutputStreams.cpp +++ b/examples/231-Cfg-OutputStreams.cpp @@ -10,11 +10,12 @@ #define CATCH_CONFIG_MAIN #include + class out_buff : public std::stringbuf { std::FILE* m_stream; public: - out_buff(std::FILE* stream) :m_stream(stream) {} - ~out_buff() { pubsync(); } + out_buff(std::FILE* stream):m_stream(stream) {} + ~out_buff(); int sync() { int ret = 0; 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 { std::ostream& cout() { static std::ostream ret(new out_buff(stdout)); diff --git a/examples/301-Gen-MapTypeConversion.cpp b/examples/301-Gen-MapTypeConversion.cpp index b6377e99..88772971 100644 --- a/examples/301-Gen-MapTypeConversion.cpp +++ b/examples/301-Gen-MapTypeConversion.cpp @@ -22,15 +22,17 @@ public: } } - std::string const& get() const override { - return m_line; - } + std::string const& get() const override; bool next() override { 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 // Notice that it returns an instance of GeneratorWrapper, which // is a value-wrapper around std::unique_ptr>. diff --git a/projects/SelfTest/UsageTests/ToStringVariant.tests.cpp b/projects/SelfTest/UsageTests/ToStringVariant.tests.cpp index 60b3f903..c6809c0f 100644 --- a/projects/SelfTest/UsageTests/ToStringVariant.tests.cpp +++ b/projects/SelfTest/UsageTests/ToStringVariant.tests.cpp @@ -9,12 +9,12 @@ // We need 2 types with non-trivial copies/moves struct MyType1 { MyType1() = default; - MyType1(MyType1 const&) { throw 1; } + [[noreturn]] MyType1(MyType1 const&) { throw 1; } MyType1& operator=(MyType1 const&) { throw 3; } }; struct MyType2 { MyType2() = default; - MyType2(MyType2 const&) { throw 2; } + [[noreturn]] MyType2(MyType2 const&) { throw 2; } MyType2& operator=(MyType2 const&) { throw 4; } };