From 1ed45af2def951f84ce077a60b429d9987c099ab Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 14 Apr 2020 08:39:29 +0200 Subject: [PATCH 01/12] Add appveyor CMake builds --- appveyor.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f20a17e..97d782a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -34,7 +34,7 @@ configuration: - release install: - - cd C:\projects\turtle\doc + - cd %APPVEYOR_BUILD_FOLDER%\doc - appveyor-retry powershell Invoke-WebRequest ftp://ftp.zlatkovic.com/libxml/iconv-1.9.2.win32.zip -OutFile iconv.zip - 7z e iconv.zip iconv.dll -r - appveyor-retry powershell Invoke-WebRequest ftp://ftp.zlatkovic.com/libxml/libxml2-2.7.8.win32.zip -OutFile libxml2.zip @@ -49,6 +49,13 @@ build_script: - set BOOST_ROOT=C:\Libraries\boost_%BOOST% - cd %BOOST_ROOT% - call bootstrap.bat - - cd C:\projects\turtle\build + - cd %APPVEYOR_BUILD_FOLDER%\build - if NOT "%CXX_STANDARD%"=="" set CXX_FLAGS=cxxflags=/std:c++%CXX_STANDARD% - call build.bat --toolset=%TOOLSET% address-model=%PLATFORM% %CXX_FLAGS% --build-type=complete %CONFIGURATION% + # CMake build + - cd %APPVEYOR_BUILD_FOLDER% + - mkdir __build + - cd __build + - cmake .. -DCMAKE_BUILD_TYPE=Debug + - cmake --build . --config Debug + - ctest --output-on-failure --build-config Debug From e13e913a1ef0f79f080db513abd2a622bcef755d Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 14 Apr 2020 10:40:28 +0200 Subject: [PATCH 02/12] Remove main.cpp and add warning free build test The main.cpp speeds up builds but fails for static boost.Test builds as it is linked before Boost.Test which removes the required symbols Enabling warning allows consumers of Turtle to build with warnings enabled --- test/CMakeLists.txt | 20 +++++++++++++++++--- test/main.cpp | 10 ---------- 2 files changed, 17 insertions(+), 13 deletions(-) delete mode 100644 test/main.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4f16ac8..a50631a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,11 +4,25 @@ find_package(Boost 1.58 REQUIRED COMPONENTS unit_test_framework thread) -add_library(TurtleTestMain STATIC main.cpp) -target_link_libraries(TurtleTestMain PUBLIC Boost::unit_test_framework Boost::disable_autolinking) +add_library(TurtleTestMain INTERFACE) +target_link_libraries(TurtleTestMain INTERFACE Boost::unit_test_framework Boost::disable_autolinking) +target_compile_definitions(TurtleTestMain INTERFACE BOOST_AUTO_TEST_MAIN) # Heuristically guess if we are compiling against dynamic boost if(NOT Boost_USE_STATIC_LIBS AND Boost_UNIT_TEST_FRAMEWORK_LIBRARY AND NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}\$") - target_compile_definitions(TurtleTestMain PUBLIC BOOST_TEST_DYN_LINK) + target_compile_definitions(TurtleTestMain INTERFACE BOOST_TEST_DYN_LINK) +endif() +# Enable warnings +option(TURTLE_WERROR "Treat warnings as errors" ON) +if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(TurtleTestMain INTERFACE -Wall -Wextra -pedantic -Wno-long-long) + if(TURTLE_WERROR) + target_compile_options(TurtleTestMain INTERFACE -Werror) + endif() +elseif(MSVC) + target_compile_options(TurtleTestMain INTERFACE /W4) + if(TURTLE_WERROR) + target_compile_options(TurtleTestMain INTERFACE /WX) + endif() endif() file(GLOB_RECURSE testFiles test_*.cpp) diff --git a/test/main.cpp b/test/main.cpp deleted file mode 100644 index 7045d4e..0000000 --- a/test/main.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// http://turtle.sourceforge.net -// -// Copyright Mathieu Champlon 2009 -// -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// http://www.boost.org/LICENSE_1_0.txt) - -#define BOOST_AUTO_TEST_MAIN -#include From 57c000f8eb76875e62e1e4b657494c5a7e3ac206 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 14 Apr 2020 10:42:15 +0200 Subject: [PATCH 03/12] Avoid unused parameter warnings --- include/turtle/detail/mutex.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/turtle/detail/mutex.hpp b/include/turtle/detail/mutex.hpp index 18ae0a5..b5dcb35 100644 --- a/include/turtle/detail/mutex.hpp +++ b/include/turtle/detail/mutex.hpp @@ -103,9 +103,9 @@ namespace detail {} ~lock() {} - lock( BOOST_RV_REF( lock ) x ) + lock( BOOST_RV_REF( lock ) ) {} - lock& operator=( BOOST_RV_REF( lock ) x ) + lock& operator=( BOOST_RV_REF( lock ) ) { return *this; } From a1a223901ace1a11246cb8b3603a656ce7f22c4e Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 14 Apr 2020 10:42:25 +0200 Subject: [PATCH 04/12] Avoid unused function warnings in tests --- test/test_log.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_log.cpp b/test/test_log.cpp index 4915534..728eb20 100644 --- a/test/test_log.cpp +++ b/test/test_log.cpp @@ -111,7 +111,7 @@ namespace { struct streamable {}; - std::ostream& operator<<( std::ostream& s, const streamable& ) + BOOST_ATTRIBUTE_UNUSED std::ostream& operator<<( std::ostream& s, const streamable& ) { BOOST_FAIL( "should not have been called" ); return s; @@ -131,7 +131,7 @@ namespace { struct mock_streamable {}; - std::ostream& operator<<( std::ostream& s, const mock_streamable& ) + BOOST_ATTRIBUTE_UNUSED std::ostream& operator<<( std::ostream& s, const mock_streamable& ) { BOOST_FAIL( "should not have been called" ); return s; @@ -271,7 +271,7 @@ namespace operator streamable() const; template< typename T > operator T() const; }; - std::ostream& operator<<( std::ostream& s, const ambiguous_convertible_streamable& ) + BOOST_ATTRIBUTE_UNUSED std::ostream& operator<<( std::ostream& s, const ambiguous_convertible_streamable& ) { BOOST_FAIL( "should not have been called" ); return s; @@ -297,7 +297,7 @@ namespace operator streamable() const; template< typename T > operator T() const; }; - std::ostream& operator<<( std::ostream& s, const ambiguous_convertible_mock_streamable& ) + BOOST_ATTRIBUTE_UNUSED std::ostream& operator<<( std::ostream& s, const ambiguous_convertible_mock_streamable& ) { BOOST_FAIL( "should not have been called" ); return s; From 3df06683145ba396bcc8fd66c2f7c4f7568d33d6 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Tue, 14 Apr 2020 10:44:36 +0200 Subject: [PATCH 05/12] Fix unknown preproccessor symbol warning --- include/turtle/constraint.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/turtle/constraint.hpp b/include/turtle/constraint.hpp index 25aa160..887a22d 100644 --- a/include/turtle/constraint.hpp +++ b/include/turtle/constraint.hpp @@ -223,7 +223,7 @@ namespace detail #ifdef MOCK_VARIADIC_MACROS -#if BOOST_MSVC +#ifdef BOOST_MSVC # define MOCK_VARIADIC_SIZE(...) \ BOOST_PP_CAT(MOCK_VARIADIC_SIZE_I(__VA_ARGS__, \ 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, \ From 233046d738f194bd288709d1d2763eeb9f35f346 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Fri, 17 Apr 2020 20:31:32 +0200 Subject: [PATCH 06/12] Fix another unused variable warning --- include/turtle/detail/expectation_template.hpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/turtle/detail/expectation_template.hpp b/include/turtle/detail/expectation_template.hpp index 030a062..20bf6f4 100644 --- a/include/turtle/detail/expectation_template.hpp +++ b/include/turtle/detail/expectation_template.hpp @@ -29,6 +29,9 @@ #define MOCK_REF_ARG(z, n, d) \ typename ref_arg< T##n >::type a##n +#define MOCK_REF_ARG_T(z, n, d) \ + typename ref_arg< T##n >::type + namespace mock { namespace detail @@ -42,7 +45,7 @@ namespace detail { private: virtual bool operator()( - BOOST_PP_ENUM(MOCK_NUM_ARGS, MOCK_REF_ARG, _) ) + BOOST_PP_ENUM(MOCK_NUM_ARGS, MOCK_REF_ARG_T, _) ) { return true; } @@ -269,4 +272,5 @@ namespace detail #undef MOCK_EXPECTATION_SERIALIZE_ANY #undef MOCK_EXPECTATION_PARAM #undef MOCK_REF_ARG +#undef MOCK_REF_ARG_T #undef MOCK_RV_REF From 6b0a4385177c6acceaa470f8fea13ee90d990536 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Fri, 17 Apr 2020 20:31:47 +0200 Subject: [PATCH 07/12] Fix link error in test_defined --- test/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a50631a..9f2cb74 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -49,7 +49,7 @@ foreach(testFile IN LISTS testFiles) target_compile_definitions(${name}_thread_safe PRIVATE MOCK_THREAD_SAFE BOOST_THREAD_USES_MOVE) endforeach() -add_executable(link-test_defined EXCLUDE_FROM_ALL defined_1.cpp defined_2.cpp) +add_executable(link-test_defined EXCLUDE_FROM_ALL test_exception.cpp defined_1.cpp defined_2.cpp) target_link_libraries(link-test_defined PRIVATE turtle::turtle TurtleTestMain) add_test(NAME link-test_defined COMMAND "${CMAKE_COMMAND}" --build ${CMAKE_BINARY_DIR} --target link-test_defined --config $) From 72722e23b341f9f0398aabac9d90469aa5b5f639 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Fri, 17 Apr 2020 21:43:18 +0200 Subject: [PATCH 08/12] Speed up appveyor build Test more in one run Factor out CMake builds Run in parallel --- appveyor.yml | 38 ++++++++++++++++++++++---------------- build/build.bat | 2 +- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 97d782a..7e127c0 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -3,6 +3,7 @@ # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # # Copyright Mathieu Champlon 2015. +# Copyright Alexander Grund 2020. skip_branch_with_pr: true @@ -24,14 +25,12 @@ environment: TOOLSET: msvc-14.1 CXX_STANDARD: 14 # CXX_STANDARD: 17 - -platform: - - 32 - - 64 - -configuration: - - debug - - release + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 + BOOST: 1_60_0 + CMAKE: true + - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 + BOOST: 1_71_0 + CMAKE: true install: - cd %APPVEYOR_BUILD_FOLDER%\doc @@ -51,11 +50,18 @@ build_script: - call bootstrap.bat - cd %APPVEYOR_BUILD_FOLDER%\build - if NOT "%CXX_STANDARD%"=="" set CXX_FLAGS=cxxflags=/std:c++%CXX_STANDARD% - - call build.bat --toolset=%TOOLSET% address-model=%PLATFORM% %CXX_FLAGS% --build-type=complete %CONFIGURATION% - # CMake build - - cd %APPVEYOR_BUILD_FOLDER% - - mkdir __build - - cd __build - - cmake .. -DCMAKE_BUILD_TYPE=Debug - - cmake --build . --config Debug - - ctest --output-on-failure --build-config Debug + - set BUILD_ARGS=address-model=32,64 variant=debug,release + - call build.bat --toolset=%TOOLSET% %CXX_FLAGS% -j3 + +for: + - matrix: + only: [CMAKE: true] + install: true + build_script: + - set BOOST_ROOT=C:\Libraries\boost_%BOOST% + - cd %APPVEYOR_BUILD_FOLDER% + - mkdir __build + - cd __build + - cmake .. -DCMAKE_BUILD_TYPE=Debug + - cmake --build . --config Debug + - ctest --output-on-failure --build-config Debug \ No newline at end of file diff --git a/build/build.bat b/build/build.bat index 2ae058b..a539b91 100644 --- a/build/build.bat +++ b/build/build.bat @@ -11,7 +11,7 @@ rem error if BOOST_ROOT not set set BOOST=%BOOST_ROOT% pushd ..\test -%BOOST%\b2.exe -q %* +%BOOST%\b2.exe -q %BUILD_ARGS% %* popd if errorlevel 1 exit /b %ERRORLEVEL% From 79ce788375e9aae2e1419bfc97c451c02b3f5d59 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Fri, 17 Apr 2020 21:49:14 +0200 Subject: [PATCH 09/12] Parallel build on travis --- .travis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 66e5fac..6b5ca40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -74,12 +74,12 @@ script: - cd $PROJECT_DIR/build - export BOOST_ROOT=$BOOST # `--coverage` flags required to generate coverage info for Coveralls - - ./build.sh --toolset=$CC "cxxflags=-std=$CXX_STANDARD -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations --coverage" "linkflags=--coverage" + - ./build.sh --toolset=$CC "cxxflags=-std=$CXX_STANDARD -Wno-unused-local-typedefs -Wno-unused-function -Wno-deprecated-declarations --coverage" "linkflags=--coverage" -j3 - cd $BOOST && ./b2 --with-test --with-thread --with-chrono --with-system --with-atomic --with-date_time -a -j3 # Build required libs - mkdir $PROJECT_DIR/__build && cd $PROJECT_DIR/__build - - export CXXFLAGS="-std=$CXX_STANDARD -Wall -Wextra" + - export CXXFLAGS="-std=$CXX_STANDARD" - cmake .. -DCMAKE_BUILD_TYPE=Debug - - cmake --build . --config Debug + - cmake --build . --config Debug -- -j3 - ctest --output-on-failure --build-config Debug after_success: From 8530f691a1f7da21eeb357a743f97d29c2760c17 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sat, 18 Apr 2020 12:09:23 +0200 Subject: [PATCH 10/12] Reduce amount of compilations Remove defined_[12].cpp from all but 1 test per test file This reduces the amount of compilations by 2*25=50 per configuration for a total of 200 (debug/release, static/shared) --- test/Jamfile.jam | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Jamfile.jam b/test/Jamfile.jam index 3eccba2..7b7cd14 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -26,11 +26,11 @@ alias mock_inspect : rule run-test ( name ) { run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : : $(name)_ ; - run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : MOCK_MAX_ARGS=21 : $(name)_max_args ; - run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : MOCK_USE_CONVERSIONS : $(name)_use_conversions ; - run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : MOCK_NO_DECLTYPE : $(name)_no_decltype ; - run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ; - run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework /boost//thread : : : MOCK_THREAD_SAFE BOOST_THREAD_USES_MOVE multi : $(name)_thread_safe ; + run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_MAX_ARGS=21 : $(name)_max_args ; + run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_USE_CONVERSIONS : $(name)_use_conversions ; + run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_NO_DECLTYPE : $(name)_no_decltype ; + run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_NO_VARIADIC_MACROS : $(name)_no_variadic_macros ; + run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : MOCK_THREAD_SAFE BOOST_THREAD_USES_MOVE multi : $(name)_thread_safe ; } rule run-tests From 87e43268835017ac6029f5108722530296359009 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sat, 18 Apr 2020 13:58:45 +0200 Subject: [PATCH 11/12] Require C++11 --- .travis.yml | 4 ---- README.md | 2 ++ 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6b5ca40..b151bcb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,6 @@ # and how it can be used with Boost libraries. # -sudo: false language: cpp branches: @@ -21,11 +20,8 @@ env: - CXX_STANDARD=c++14 BRANCH_TO_TEST=master - CXX_STANDARD=c++11 BRANCH_TO_TEST=master - CXX_STANDARD=c++11 BRANCH_TO_TEST=boost-1.58.0 - - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.58.0 - CXX_STANDARD=c++11 BRANCH_TO_TEST=boost-1.59.0 - - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.59.0 - CXX_STANDARD=c++11 BRANCH_TO_TEST=boost-1.67.0 - - CXX_STANDARD=c++98 BRANCH_TO_TEST=boost-1.67.0 compiler: - clang diff --git a/README.md b/README.md index a926488..8be3b04 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,5 @@ Distributed under the [Boost Software License, Version 1.0](http://boost.org/LIC [![Build Status](https://travis-ci.org/mat007/turtle.svg)](https://travis-ci.org/mat007/turtle) [![Build status](https://ci.appveyor.com/api/projects/status/459hvqkb5rts4hw7?svg=true)](https://ci.appveyor.com/project/mat007/turtle) [![Coverage Status](https://coveralls.io/repos/mat007/turtle/badge.png)](https://coveralls.io/r/mat007/turtle) + +Boost and a C++11 compatible compiler is required. From 70ae7674e55be95f466001090a174e51dd1b3713 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Fri, 17 Apr 2020 22:01:15 +0200 Subject: [PATCH 12/12] Disable -Wunused-function for tests --- test/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 9f2cb74..9c79747 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -15,6 +15,11 @@ endif() option(TURTLE_WERROR "Treat warnings as errors" ON) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") target_compile_options(TurtleTestMain INTERFACE -Wall -Wextra -pedantic -Wno-long-long) + include(CheckCXXCompilerFlag) + check_cxx_compiler_flag(-Wunused-function TURTLE_CXX_UNUSED_FUNCTION) + if(TURTLE_CXX_UNUSED_FUNCTION) + target_compile_options(TurtleTestMain INTERFACE -Wno-unused-function) + endif() if(TURTLE_WERROR) target_compile_options(TurtleTestMain INTERFACE -Werror) endif()