diff --git a/.travis.yml b/.travis.yml index 66e5fac..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 @@ -74,12 +70,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: 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. diff --git a/appveyor.yml b/appveyor.yml index f20a17e..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,17 +25,15 @@ 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 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 +48,20 @@ 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% + - 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% 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, \ 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 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; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4f16ac8..9c79747 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -4,11 +4,30 @@ 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) + 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() +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) @@ -35,7 +54,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 $) 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 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 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;