Merge pull request #131 from Flamefire/gha-windows

Add Windows runners to GHA CI
This commit is contained in:
Alexander Grund 2025-06-15 11:08:45 +02:00 committed by GitHub
commit ad456c684b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 79 additions and 30 deletions

View file

@ -1,4 +1,4 @@
# Copyright 2022 Alexander Grund # Copyright 2022-2025 Alexander Grund
# #
# Distributed under the Boost Software License, Version 1.0. # 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) # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@ -32,7 +32,7 @@ jobs:
with: with:
clangFormatVersion: 10 clangFormatVersion: 10
posix: Build:
defaults: defaults:
run: run:
shell: bash 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: boost-1.86.0, os: ubuntu-24.04 }
- { compiler: clang-18, cxxstd: '14,17,20', boostBranch: master, 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, - { name: Collect coverage, coverage: yes,
compiler: gcc-8, cxxstd: '14', boostBranch: boost-1.86.0, os: ubuntu-latest, container: 'ubuntu:20.04' } 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 - name: Install packages and setup env
run: | run: |
B2_TOOLSET=${{matrix.toolset}}
if [[ ! "${{matrix.os}}" == "windows-"* ]]; then
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
CXX=${{matrix.compiler}} CXX=${{matrix.compiler}}
CXX="${CXX/gcc-/g++-}" CXX="${CXX/gcc-/g++-}"
@ -108,19 +115,30 @@ jobs:
CXX="ccache ${CXX/clang-/clang++-}" CXX="ccache ${CXX/clang-/clang++-}"
echo "CXX=$CXX" >> $GITHUB_ENV echo "CXX=$CXX" >> $GITHUB_ENV
echo "CC=${{matrix.compiler}}" >> $GITHUB_ENV echo "CC=${{matrix.compiler}}" >> $GITHUB_ENV
if [[ "$CXX" =~ clang ]]; then if [[ -z $B2_TOOLSET ]]; then
B2_TOOLSET=clang if [[ "$CXX" =~ clang ]]; then
else B2_TOOLSET=clang
B2_TOOLSET=gcc else
B2_TOOLSET=gcc
fi
fi fi
echo "B2_TOOLSET=$B2_TOOLSET" >> $GITHUB_ENV [[ -z $CXX ]] || echo "using $B2_TOOLSET : : $CXX ;" > ~/user-config.jam
echo "using $B2_TOOLSET : : $CXX ;" > ~/user-config.jam fi
# Move the Boost root to a sibling folder echo "B2_TOOLSET=$B2_TOOLSET" >> $GITHUB_ENV
mv boost-root ..
echo "BOOST_ROOT=${{github.workspace}}/../boost-root" >> $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 - name: Cache ccache
uses: hendrikmuhs/ccache-action@v1 uses: hendrikmuhs/ccache-action@v1
if: startsWith(matrix.os, 'ubuntu')
with: with:
key: ${{matrix.os}}-${{matrix.compiler}}-${{matrix.boostBranch}} key: ${{matrix.os}}-${{matrix.compiler}}-${{matrix.boostBranch}}
@ -130,11 +148,17 @@ jobs:
- name: Boost build - name: Boost build
run: | run: |
B2_FLAGS="cxxstd=${{matrix.cxxstd}}" ./b2 "$GITHUB_WORKSPACE/test" -q $B2_FLAGS -j3
if [[ "${{matrix.coverage}}" == "yes" ]]; then ./b2 "$GITHUB_WORKSPACE/doc//mock_examples" -q $B2_FLAGS "$@"
B2_FLAGS="$B2_FLAGS cxxflags=--coverage linkflags=--coverage" working-directory: ${{env.BOOST_ROOT}}
fi
scripts/build.sh --toolset=$B2_TOOLSET $B2_FLAGS -j3 - 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 - name: Collect coverage
if: matrix.coverage if: matrix.coverage
@ -165,9 +189,21 @@ jobs:
run: | run: |
mkdir build && cd build mkdir build && cd build
CXX_STANDARD="${{matrix.cxxstd}}" 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
cmake --build . --config Debug -- -j3 extra_args=()
ctest --output-on-failure --build-config Debug -j3 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 - name: Cleanup Boost folder to reduce cache usage
if: ${{ always() }} if: ${{ always() }}

View file

@ -82,6 +82,7 @@ build_script:
- cd %APPVEYOR_BUILD_FOLDER% - cd %APPVEYOR_BUILD_FOLDER%
- if NOT "%CXX_STANDARD%"=="" set CXX_FLAGS=cxxstd=%CXX_STANDARD% - if NOT "%CXX_STANDARD%"=="" set CXX_FLAGS=cxxstd=%CXX_STANDARD%
- set BUILD_ARGS=address-model=%ADDRESS_MODEL% variant=%VARIANT% - set BUILD_ARGS=address-model=%ADDRESS_MODEL% variant=%VARIANT%
- set BOOST_TEST_LOG_LEVEL=all
- call scripts\build.bat --toolset=%TOOLSET% %CXX_FLAGS% -j3 - call scripts\build.bat --toolset=%TOOLSET% %CXX_FLAGS% -j3
for: for:

View file

@ -544,6 +544,7 @@ bool custom_constraint(int expected, int actual)
return expected == actual; return expected == actual;
} }
#if MOCK_CXX_VERSION < 201703L
BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_a_standard_library_functor) BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_a_standard_library_functor)
{ {
mock_class c; 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 std::bind1st(std::ptr_fun(&custom_constraint), 42)); // std::ptr_fun creates an std::unary_function
c.method(42); c.method(42);
} }
#endif
//] //]
} // namespace constraints_example_3 } // namespace constraints_example_3

View file

@ -25,8 +25,9 @@
# endif # endif
#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 # define MOCK_UNCAUGHT_EXCEPTIONS
# endif # endif
#endif #endif

View file

@ -1,6 +1,7 @@
// http://turtle.sourceforge.net // 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. // Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
@ -80,7 +81,7 @@ namespace mock { namespace detail {
typedef safe_error<R, MOCK_ERROR_POLICY<R>> error_type; typedef safe_error<R, MOCK_ERROR_POLICY<R>> error_type;
public: public:
function_impl() : context_(0), valid_(true), exceptions_(exceptions()), mutex_(std::make_shared<mutex>()) {} function_impl() : exceptions_(exceptions()), mutex_(std::make_shared<mutex>()) {}
virtual ~function_impl() virtual ~function_impl()
{ {
if(valid_ && exceptions_ >= exceptions()) if(valid_ && exceptions_ >= exceptions())
@ -314,8 +315,8 @@ namespace mock { namespace detail {
}; };
std::list<expectation_type> expectations_; std::list<expectation_type> expectations_;
context* context_; context* context_ = nullptr;
mutable bool valid_; mutable bool valid_ = true;
const int exceptions_; const int exceptions_;
const std::shared_ptr<mutex> mutex_; const std::shared_ptr<mutex> mutex_;
}; };

View file

@ -19,16 +19,24 @@ path-constant parent : .. ;
run /boost/tools/inspect//inspect/<variant>release : $(parent) -text -brief : : <test-info>always_show_run_output : inspect ; run /boost/tools/inspect//inspect/<variant>release : $(parent) -text -brief : : <test-info>always_show_run_output : inspect ;
explicit 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) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : $(options) : $(name)_ ;
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ; run $(name) undefined.cpp /boost//unit_test_framework : : : $(options) <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ;
run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : <define>MOCK_THREAD_SAFE <define>BOOST_THREAD_USES_MOVE <threading>multi : $(name)_thread_safe ; run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : $(options) <define>MOCK_THREAD_SAFE <define>BOOST_THREAD_USES_MOVE <threading>multi : $(name)_thread_safe ;
} }
rule run-tests 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 :
<toolset>gcc,<target-os>windows:<inlining>on
<toolset>gcc,<target-os>windows:<optimization>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 ] ; alias mock_tests : [ run-tests ] ;