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.
# (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 [[ -z $B2_TOOLSET ]]; then
if [[ "$CXX" =~ clang ]]; then
B2_TOOLSET=clang
else
B2_TOOLSET=gcc
fi
fi
[[ -z $CXX ]] || echo "using $B2_TOOLSET : : $CXX ;" > ~/user-config.jam
fi
echo "B2_TOOLSET=$B2_TOOLSET" >> $GITHUB_ENV
echo "using $B2_TOOLSET : : $CXX ;" > ~/user-config.jam
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() }}

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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<R, MOCK_ERROR_POLICY<R>> error_type;
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()
{
if(valid_ && exceptions_ >= exceptions())
@ -314,8 +315,8 @@ namespace mock { namespace detail {
};
std::list<expectation_type> expectations_;
context* context_;
mutable bool valid_;
context* context_ = nullptr;
mutable bool valid_ = true;
const int exceptions_;
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 ;
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 : : : <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) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : $(options) : $(name)_ ;
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 : : : $(options) <define>MOCK_THREAD_SAFE <define>BOOST_THREAD_USES_MOVE <threading>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 :
<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 ] ;