diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c8331f1..818356f9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,4 +1,4 @@ -# Copyright 2022 Alexander Grund +# Copyright 2022-2025 Alexander Grund # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) @@ -32,7 +32,7 @@ jobs: with: clangFormatVersion: 10 - posix: + Build: defaults: run: shell: bash @@ -53,6 +53,11 @@ jobs: - { compiler: clang-18, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-24.04 } - { compiler: clang-18, cxxstd: '14,17,20', boostBranch: master, os: ubuntu-24.04 } + # Windows + - { toolset: msvc-14.2, os: windows-2019, cxxstd: 14, generator: 'Visual Studio 16 2019' } + - { toolset: gcc, os: windows-2019, cxxstd: 17, generator: 'MinGW Makefiles' } + - { toolset: msvc-14.3, os: windows-2022, cxxstd: 20, generator: 'Visual Studio 17 2022' } + - { name: Collect coverage, coverage: yes, compiler: gcc-8, cxxstd: '14', boostBranch: boost-1.86.0, os: ubuntu-latest, container: 'ubuntu:20.04' } @@ -99,6 +104,8 @@ jobs: - name: Install packages and setup env run: | + B2_TOOLSET=${{matrix.toolset}} + if [[ ! "${{matrix.os}}" == "windows-"* ]]; then sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update CXX=${{matrix.compiler}} CXX="${CXX/gcc-/g++-}" @@ -108,19 +115,30 @@ jobs: CXX="ccache ${CXX/clang-/clang++-}" echo "CXX=$CXX" >> $GITHUB_ENV echo "CC=${{matrix.compiler}}" >> $GITHUB_ENV - if [[ "$CXX" =~ clang ]]; then - B2_TOOLSET=clang - else - B2_TOOLSET=gcc + if [[ -z $B2_TOOLSET ]]; then + if [[ "$CXX" =~ clang ]]; then + B2_TOOLSET=clang + else + B2_TOOLSET=gcc + fi fi - echo "B2_TOOLSET=$B2_TOOLSET" >> $GITHUB_ENV - echo "using $B2_TOOLSET : : $CXX ;" > ~/user-config.jam - # Move the Boost root to a sibling folder - mv boost-root .. - echo "BOOST_ROOT=${{github.workspace}}/../boost-root" >> $GITHUB_ENV + [[ -z $CXX ]] || echo "using $B2_TOOLSET : : $CXX ;" > ~/user-config.jam + fi + echo "B2_TOOLSET=$B2_TOOLSET" >> $GITHUB_ENV + + B2_FLAGS+=" --toolset=$B2_TOOLSET cxxstd=${{matrix.cxxstd}}" + if [[ "${{matrix.coverage}}" == "yes" ]]; then + B2_FLAGS+=" cxxflags=--coverage linkflags=--coverage" + fi + echo "B2_FLAGS=$B2_FLAGS" >> $GITHUB_ENV + + # Move the Boost root to a sibling folder + mv boost-root .. + echo "BOOST_ROOT=${{github.workspace}}/../boost-root" >> $GITHUB_ENV - name: Cache ccache uses: hendrikmuhs/ccache-action@v1 + if: startsWith(matrix.os, 'ubuntu') with: key: ${{matrix.os}}-${{matrix.compiler}}-${{matrix.boostBranch}} @@ -130,11 +148,17 @@ jobs: - name: Boost build run: | - B2_FLAGS="cxxstd=${{matrix.cxxstd}}" - if [[ "${{matrix.coverage}}" == "yes" ]]; then - B2_FLAGS="$B2_FLAGS cxxflags=--coverage linkflags=--coverage" - fi - scripts/build.sh --toolset=$B2_TOOLSET $B2_FLAGS -j3 + ./b2 "$GITHUB_WORKSPACE/test" -q $B2_FLAGS -j3 + ./b2 "$GITHUB_WORKSPACE/doc//mock_examples" -q $B2_FLAGS "$@" + working-directory: ${{env.BOOST_ROOT}} + + - name: Run inspect check + run: ./b2 "$GITHUB_WORKSPACE/test//inspect" -q $B2_FLAGS + working-directory: ${{env.BOOST_ROOT}} + + - name: Build doc + if: startsWith(matrix.os, 'ubuntu') + run: scripts/build_doc.sh $B2_FLAGS -j3 - name: Collect coverage if: matrix.coverage @@ -165,9 +189,21 @@ jobs: run: | mkdir build && cd build CXX_STANDARD="${{matrix.cxxstd}}" - cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-std=c++${CXX_STANDARD##*,}" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_VERBOSE_MAKEFILE=ON - cmake --build . --config Debug -- -j3 - ctest --output-on-failure --build-config Debug -j3 + if [[ "${{matrix.os}}" == "windows-"* ]]; then + extra_args=() + else + extra_args=(-DCMAKE_CXX_COMPILER_LAUNCHER=ccache) + fi + if [[ -n "${{matrix.generator}}" ]]; then + extra_args+=(-G "${{matrix.generator}}") + fi + if [[ "${{matrix.generator}}" == "MinGW"* ]]; then + extra_args+=(-DCMAKE_CXX_FLAGS="-Wa,-mbig-obj") + fi + echo "Using extra args: ${extra_args[*]}" + cmake .. -DCMAKE_BUILD_TYPE=Debug -DBoost_ROOT="$BOOST_ROOT/stage" -DCMAKE_CXX_STANDARD="${CXX_STANDARD##*,}" "${extra_args[@]}" -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_VERBOSE=ON + cmake --build . --config Debug --parallel 3 + ctest --output-on-failure --build-config Debug - name: Cleanup Boost folder to reduce cache usage if: ${{ always() }} diff --git a/appveyor.yml b/appveyor.yml index e36753b6..c02348df 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -82,6 +82,7 @@ build_script: - cd %APPVEYOR_BUILD_FOLDER% - if NOT "%CXX_STANDARD%"=="" set CXX_FLAGS=cxxstd=%CXX_STANDARD% - set BUILD_ARGS=address-model=%ADDRESS_MODEL% variant=%VARIANT% + - set BOOST_TEST_LOG_LEVEL=all - call scripts\build.bat --toolset=%TOOLSET% %CXX_FLAGS% -j3 for: diff --git a/doc/example/reference.cpp b/doc/example/reference.cpp index 2b19a4ed..33d71b52 100644 --- a/doc/example/reference.cpp +++ b/doc/example/reference.cpp @@ -544,6 +544,7 @@ bool custom_constraint(int expected, int actual) return expected == actual; } +#if MOCK_CXX_VERSION < 201703L BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_a_standard_library_functor) { mock_class c; @@ -551,6 +552,7 @@ BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_a_standard_lib std::bind1st(std::ptr_fun(&custom_constraint), 42)); // std::ptr_fun creates an std::unary_function c.method(42); } +#endif //] } // namespace constraints_example_3 diff --git a/include/turtle/config.hpp b/include/turtle/config.hpp index 8e420511..9395005c 100644 --- a/include/turtle/config.hpp +++ b/include/turtle/config.hpp @@ -25,8 +25,9 @@ # endif #endif -#if defined(__cpp_lib_uncaught_exceptions) || defined(_MSC_VER) && (_MSC_VER >= 1900) -# ifndef MOCK_NO_UNCAUGHT_EXCEPTIONS +#ifndef MOCK_NO_UNCAUGHT_EXCEPTIONS +# if(defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \ + (defined(_MSC_VER) && _MSC_VER >= 1900) # define MOCK_UNCAUGHT_EXCEPTIONS # endif #endif diff --git a/include/turtle/detail/function_impl.hpp b/include/turtle/detail/function_impl.hpp index e3524a29..c11f3862 100644 --- a/include/turtle/detail/function_impl.hpp +++ b/include/turtle/detail/function_impl.hpp @@ -1,6 +1,7 @@ // http://turtle.sourceforge.net // -// Copyright Mathieu Champlon 2012 +// Copyright 2012 Mathieu Champlon +// Copyright 2025 Alexander Grund // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt or copy at @@ -80,7 +81,7 @@ namespace mock { namespace detail { typedef safe_error> error_type; public: - function_impl() : context_(0), valid_(true), exceptions_(exceptions()), mutex_(std::make_shared()) {} + function_impl() : exceptions_(exceptions()), mutex_(std::make_shared()) {} virtual ~function_impl() { if(valid_ && exceptions_ >= exceptions()) @@ -314,8 +315,8 @@ namespace mock { namespace detail { }; std::list expectations_; - context* context_; - mutable bool valid_; + context* context_ = nullptr; + mutable bool valid_ = true; const int exceptions_; const std::shared_ptr mutex_; }; diff --git a/test/Jamfile.jam b/test/Jamfile.jam index 4cbca985..31a42921 100644 --- a/test/Jamfile.jam +++ b/test/Jamfile.jam @@ -19,16 +19,24 @@ path-constant parent : .. ; run /boost/tools/inspect//inspect/release : $(parent) -text -brief : : always_show_run_output : inspect ; explicit inspect ; -rule run-test ( name ) +rule run-test ( name : options * ) { - run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : : $(name)_ ; - run $(name) undefined.cpp /boost//unit_test_framework : : : MOCK_USE_CONVERSIONS : $(name)_use_conversions ; - run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : MOCK_THREAD_SAFE BOOST_THREAD_USES_MOVE multi : $(name)_thread_safe ; + run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : $(options) : $(name)_ ; + run $(name) undefined.cpp /boost//unit_test_framework : : : $(options) MOCK_USE_CONVERSIONS : $(name)_use_conversions ; + run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : $(options) MOCK_THREAD_SAFE BOOST_THREAD_USES_MOVE multi : $(name)_thread_safe ; } rule run-tests { - for name in [ glob test_*.cpp detail/test_*.cpp ] { run-test $(name) ; } + for name in [ glob test_*.cpp ] { run-test $(name) ; } + # Avoid object file getting to big on MinGW + run-test detail/test_function.cpp : + gcc,windows:on + gcc,windows:space ; + run-test detail/test_invocation.cpp ; + run-test detail/test_is_functor.cpp ; + run-test detail/test_signature.cpp ; + run-test detail/test_type_name.cpp ; } alias mock_tests : [ run-tests ] ;