From 1d2fb3f3dfd4b3c30a11996d748a1db67f106dc2 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 1 Jun 2025 12:51:43 +0200 Subject: [PATCH 01/10] GHA: Add Windows builds --- .github/workflows/ci.yml | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9c8331f..67c73b5 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: 'Visual Studio 16 2019' } + - { 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,23 @@ 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 + # 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}} @@ -165,7 +176,12 @@ 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 + if [[ "${{matrix.os}}" == "windows-"* ]]; then + compiler_launcher_arg= + else + compiler_launcher_arg=-DCMAKE_CXX_COMPILER_LAUNCHER=ccache + fi + cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD="${CXX_STANDARD##*,}" $compiler_launcher_arg -DCMAKE_VERBOSE_MAKEFILE=ON cmake --build . --config Debug -- -j3 ctest --output-on-failure --build-config Debug -j3 From 29c7e2d067c8a4b53dab47a823373acaa714fe5e Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 1 Jun 2025 14:05:03 +0200 Subject: [PATCH 02/10] GHA: Separate out doc and inspect builds Don't run doc build on Windows due to missing dependencies. Use separate steps for different builds to easier differentiate them. --- .github/workflows/ci.yml | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 67c73b5..04a50c1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -125,6 +125,13 @@ jobs: [[ -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 @@ -141,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 From 0d4a9f1e33cf8804e5a5d99bb962a026bfedc885 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 1 Jun 2025 14:26:16 +0200 Subject: [PATCH 03/10] Remove std::bind1st test for C++17 --- doc/example/reference.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/example/reference.cpp b/doc/example/reference.cpp index 2b19a4e..33d71b5 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 From 6683b829c3fdcf56534975553b1913b35bc2af25 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Sun, 1 Jun 2025 14:55:30 +0200 Subject: [PATCH 04/10] CI: Add Boost debug output to CMake search --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 04a50c1..a9c1b5a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -194,7 +194,7 @@ jobs: else compiler_launcher_arg=-DCMAKE_CXX_COMPILER_LAUNCHER=ccache fi - cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD="${CXX_STANDARD##*,}" $compiler_launcher_arg -DCMAKE_VERBOSE_MAKEFILE=ON + cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD="${CXX_STANDARD##*,}" $compiler_launcher_arg -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_VERBOSE=ON cmake --build . --config Debug -- -j3 ctest --output-on-failure --build-config Debug -j3 From 66bfbe115cb9ada3d14265490e3cf71510337981 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 9 Jun 2025 12:09:05 +0200 Subject: [PATCH 05/10] Set stage dir as boost root --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a9c1b5a..762b8e6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -194,7 +194,7 @@ jobs: else compiler_launcher_arg=-DCMAKE_CXX_COMPILER_LAUNCHER=ccache fi - cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_STANDARD="${CXX_STANDARD##*,}" $compiler_launcher_arg -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_VERBOSE=ON + cmake .. -DCMAKE_BUILD_TYPE=Debug -DBoost_ROOT="$BOOST_ROOT/stage" -DCMAKE_CXX_STANDARD="${CXX_STANDARD##*,}" $compiler_launcher_arg -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_VERBOSE=ON cmake --build . --config Debug -- -j3 ctest --output-on-failure --build-config Debug -j3 From 3980cc97e138236814964dd12cd242f9ce29b3ff Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 9 Jun 2025 14:17:49 +0200 Subject: [PATCH 06/10] Fix CMake parallel flag for MSVC --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 762b8e6..c283a79 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -195,8 +195,8 @@ jobs: compiler_launcher_arg=-DCMAKE_CXX_COMPILER_LAUNCHER=ccache fi cmake .. -DCMAKE_BUILD_TYPE=Debug -DBoost_ROOT="$BOOST_ROOT/stage" -DCMAKE_CXX_STANDARD="${CXX_STANDARD##*,}" $compiler_launcher_arg -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_VERBOSE=ON - cmake --build . --config Debug -- -j3 - ctest --output-on-failure --build-config Debug -j3 + cmake --build . --config Debug --parallel 3 + ctest --output-on-failure --build-config Debug --parallel 3 - name: Cleanup Boost folder to reduce cache usage if: ${{ always() }} From d8809dca2ae7d96177cf2717cd125bfaa2d371ec Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 9 Jun 2025 12:19:12 +0200 Subject: [PATCH 07/10] Improve check for std::uncaught_exceptions GCC 8 on MinGW still warns about that. Check the version of the feature macro and add parens to ensure correct evaluation. --- include/turtle/config.hpp | 5 +++-- include/turtle/detail/function_impl.hpp | 9 +++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/turtle/config.hpp b/include/turtle/config.hpp index 8e42051..9395005 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 e3524a2..c11f386 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_; }; From 2f02e9c8706f10023ad5b8d5bec887ea4c058ef7 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 9 Jun 2025 20:13:46 +0200 Subject: [PATCH 08/10] Use MinGW generator for GCC on Windows --- .github/workflows/ci.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c283a79..06769cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -55,7 +55,7 @@ jobs: # Windows - { toolset: msvc-14.2, os: windows-2019, cxxstd: 14, generator: 'Visual Studio 16 2019' } - - { toolset: gcc, os: windows-2019, cxxstd: 17, 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, @@ -190,13 +190,17 @@ jobs: mkdir build && cd build CXX_STANDARD="${{matrix.cxxstd}}" if [[ "${{matrix.os}}" == "windows-"* ]]; then - compiler_launcher_arg= + extra_args=() else - compiler_launcher_arg=-DCMAKE_CXX_COMPILER_LAUNCHER=ccache + extra_args=(-DCMAKE_CXX_COMPILER_LAUNCHER=ccache) fi - cmake .. -DCMAKE_BUILD_TYPE=Debug -DBoost_ROOT="$BOOST_ROOT/stage" -DCMAKE_CXX_STANDARD="${CXX_STANDARD##*,}" $compiler_launcher_arg -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_VERBOSE=ON + if [[ -n "${{matrix.generator}}" ]]; then + extra_args+=(-G "${{matrix.generator}}") + 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 --parallel 3 + ctest --output-on-failure --build-config Debug - name: Cleanup Boost folder to reduce cache usage if: ${{ always() }} From 68e66eefb44befe6d75b77e5fbf15195a0be626d Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Mon, 9 Jun 2025 14:17:35 +0200 Subject: [PATCH 09/10] Workaround file-too-big error on MinGW CI --- .github/workflows/ci.yml | 3 +++ test/Jamfile.jam | 18 +++++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 06769cd..818356f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -197,6 +197,9 @@ jobs: 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 diff --git a/test/Jamfile.jam b/test/Jamfile.jam index 4cbca98..31a4292 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 ] ; From f974db3b08cabb42c522426ee731752084938874 Mon Sep 17 00:00:00 2001 From: Alexander Grund Date: Fri, 13 Jun 2025 15:40:37 +0200 Subject: [PATCH 10/10] Increase verbosity of Boost tests in Appveyor --- appveyor.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/appveyor.yml b/appveyor.yml index e36753b..c02348d 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: