Add CMake tests

This commit is contained in:
Peter Dimov
2019-12-28 18:44:22 +02:00
parent cab10beccd
commit 38d5273ad7
8 changed files with 129 additions and 1 deletions

View File

@ -305,6 +305,37 @@ matrix:
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
- os: linux
env: CMAKE=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_DEBUG=1 ..
- ctest --output-on-failure -R boost_throw_exception
- os: linux
env: CMAKE_SUBDIR=1
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH https://github.com/boostorg/core.git ../core
script:
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
- os: linux
env: CMAKE_INSTALL=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_DEBUG=1 -DBOOST_INCLUDE_LIBRARIES="assert;config;throw_exception" -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/throw_exception/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..

View File

@ -22,3 +22,9 @@ if(BOOST_SUPERPROJECT_VERSION)
boost_install(TARGETS boost_throw_exception HEADER_DIRECTORY include/)
endif()
if(BUILD_TESTING)
add_subdirectory(test)
endif()

17
test/CMakeLists.txt Normal file
View File

@ -0,0 +1,17 @@
# Copyright 2018, 2019 Peter Dimov
# 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(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(HAVE_BOOST_TEST)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::throw_exception Boost::core Boost::exception)
endif()
#run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>static : throw_from_library_static ;
#run throw_from_library_test.cpp lib1_throw lib2_throw lib3_throw : : : <link>shared : throw_from_library_shared ;
#run throw_exception_nx_test.cpp : : : <exception-handling>off ;
#run throw_exception_nx_test2.cpp : : : <exception-handling>off ;

View File

@ -20,7 +20,8 @@ run throw_exception_no_exceptions_test.cpp ;
run throw_exception_no_integration_test.cpp ;
run throw_exception_no_both_test.cpp ;
compile-fail throw_exception_fail.cpp : <warnings-as-errors>off ;
compile-fail throw_exception_fail.cpp
: <warnings-as-errors>off ;
run throw_exception_test2.cpp ;
run throw_exception_test3.cpp ;

View File

@ -0,0 +1,17 @@
# Copyright 2018 Peter Dimov
# 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
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_throw_exception REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main Boost::throw_exception)
enable_testing()
add_test(NAME main COMMAND main)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -0,0 +1,19 @@
// Copyright 2019 Peter Dimov
// 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 <boost/throw_exception.hpp>
#include <stdexcept>
int main()
{
try
{
boost::throw_exception( std::runtime_error( "" ) );
return 1;
}
catch( std::runtime_error const& )
{
return 0;
}
}

View File

@ -0,0 +1,18 @@
# Copyright 2018 Peter Dimov
# 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
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../../../assert boostorg/assert)
add_subdirectory(../../../config boostorg/config)
add_executable(main main.cpp)
target_link_libraries(main Boost::throw_exception)
enable_testing()
add_test(NAME main COMMAND main)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@ -0,0 +1,19 @@
// Copyright 2019 Peter Dimov
// 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 <boost/throw_exception.hpp>
#include <stdexcept>
int main()
{
try
{
boost::throw_exception( std::runtime_error( "" ) );
return 1;
}
catch( std::runtime_error const& )
{
return 0;
}
}