Run all the tests in CMake, add CMake runs into CI. Drop dependency on Boost.SmartPtr as it is not used by the library for some time (#31)

This commit is contained in:
Antony Polukhin
2025-10-07 20:26:12 +03:00
committed by GitHub
parent b74a4c34cb
commit 6632ca9309
6 changed files with 58 additions and 10 deletions

View File

@@ -17,6 +17,9 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- toolset: gcc-14 # Do not remove! It is the only toolset that tests CMake tests down below
cxxstd: "03,11,14,17,20"
os: ubuntu-24.04
- toolset: gcc-12 - toolset: gcc-12
cxxstd: "03,11,14,17,2a" cxxstd: "03,11,14,17,2a"
os: ubuntu-22.04 os: ubuntu-22.04
@@ -59,9 +62,20 @@ jobs:
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--depth 10 --jobs 3" $LIBRARY python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--depth 10 --jobs 3" $LIBRARY
./bootstrap.sh ./bootstrap.sh
./b2 -d0 headers
./b2 -j4 variant=debug tools/inspect ./b2 -j4 variant=debug tools/inspect
- name: Run CMake tests
if: ${{matrix.toolset == 'gcc-14'}}
run: |
cd ../boost-root/
mkdir __build
cd __build
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=conversion -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_C_COMPILER=gcc-14 ..
cmake --build . --target tests
ctest --output-on-failure --no-tests=error
cd ..
rm -rf __build
- name: Run tests - name: Run tests
run: | run: |
cd ../boost-root cd ../boost-root
@@ -101,14 +115,14 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
include: include:
- toolset: msvc-14.2 - toolset: msvc-14.3
cxxstd: "14,17,latest" cxxstd: "14,17,latest"
addrmd: 32,64 addrmd: 32,64
os: windows-2019 os: windows-2025
- toolset: gcc - toolset: gcc
cxxstd: "03,11,14,17,2a" cxxstd: "03,11,14,17,2a"
addrmd: 64 addrmd: 64
os: windows-2019 os: windows-2025
runs-on: ${{matrix.os}} runs-on: ${{matrix.os}}
@@ -135,7 +149,21 @@ jobs:
git submodule update --init tools/boostdep git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--jobs 3" %LIBRARY% python tools/boostdep/depinst/depinst.py --include benchmark --include example --include examples --include tools --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap cmd /c bootstrap
b2 -d0 headers
- name: Run CMake tests
if: ${{matrix.toolset == 'msvc-14.3'}}
shell: cmd
run: |
choco install --no-progress ninja
call "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvarsall.bat" x64
cd ../boost-root/
mkdir __build
cd __build
cmake -DBUILD_TESTING=1 -DBOOST_INCLUDE_LIBRARIES=conversion ..
cmake --build . --target tests --config Debug
ctest --output-on-failure --no-tests=error -C Debug
cd ..
rm -rf __build
- name: Run tests - name: Run tests
shell: cmd shell: cmd

View File

@@ -2,7 +2,7 @@
# 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 https://www.boost.org/LICENSE_1_0.txt # See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required( VERSION 3.5...3.20 ) cmake_minimum_required( VERSION 3.5...4.20 )
project( boost_conversion VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX ) project( boost_conversion VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX )
add_library( boost_conversion INTERFACE ) add_library( boost_conversion INTERFACE )
@@ -14,6 +14,9 @@ target_link_libraries( boost_conversion
INTERFACE INTERFACE
Boost::assert Boost::assert
Boost::config Boost::config
Boost::smart_ptr
Boost::throw_exception Boost::throw_exception
) )
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@@ -8,7 +8,6 @@ require-b2 5.2 ;
constant boost_dependencies : constant boost_dependencies :
/boost/assert//boost_assert /boost/assert//boost_assert
/boost/config//boost_config /boost/config//boost_config
/boost/smart_ptr//boost_smart_ptr
/boost/throw_exception//boost_throw_exception ; /boost/throw_exception//boost_throw_exception ;
project /boost/conversion project /boost/conversion

17
test/CMakeLists.txt Normal file
View File

@@ -0,0 +1,17 @@
# Copyright (c) 2016-2025 Antony Polukhin
# 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
include(BoostTest OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(NOT HAVE_BOOST_TEST)
return()
endif()
set(BOOST_TEST_LINK_LIBRARIES Boost::conversion Boost::core)
boost_test(TYPE run SOURCES cast_test.cpp)
boost_test(TYPE run SOURCES implicit_cast.cpp)
boost_test(TYPE compile-fail SOURCES implicit_cast_fail.cpp)
boost_test(TYPE compile-fail SOURCES implicit_cast_fail2.cpp)
boost_test(TYPE run SOURCES polymorphic_cast_test.cpp LINK_LIBRARIES Boost::smart_ptr)

View File

@@ -26,6 +26,6 @@ test-suite conversion
: [ run implicit_cast.cpp ] : [ run implicit_cast.cpp ]
[ compile-fail implicit_cast_fail.cpp ] [ compile-fail implicit_cast_fail.cpp ]
[ run cast_test.cpp ] [ run cast_test.cpp ]
[ run polymorphic_cast_test.cpp ] [ run polymorphic_cast_test.cpp : : : <library>/boost/smart_ptr//boost_smart_ptr ]
[ compile-fail implicit_cast_fail2.cpp ] [ compile-fail implicit_cast_fail2.cpp ]
; ;

View File

@@ -4,8 +4,9 @@
// http://www.boost.org/LICENSE_1_0.txt) // http://www.boost.org/LICENSE_1_0.txt)
#include <boost/implicit_cast.hpp> #include <boost/implicit_cast.hpp>
#include <boost/detail/lightweight_test.hpp> #include <boost/core/lightweight_test.hpp>
#include <boost/type.hpp> #include <boost/type.hpp>
using boost::implicit_cast; using boost::implicit_cast;
using boost::type; using boost::type;