From 127c3aaa4e8309c8d74f87dbd83e228d811e08a9 Mon Sep 17 00:00:00 2001 From: Andrey Semashev Date: Mon, 5 Feb 2024 00:03:54 +0300 Subject: [PATCH] Enabled warnings-as-errors for tests. --- test/CMakeLists.txt | 16 ++++++++++++++-- test/Jamfile | 12 ++++++++++-- test/run/unique_resource.cpp | 2 +- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ab63b5c..6518f0f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,11 +1,11 @@ # Copyright 2023 Peter Dimov -# Copyright 2023 Andrey Semashev +# Copyright 2023-2024 Andrey Semashev # 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) +if (NOT HAVE_BOOST_TEST) return() endif() @@ -19,12 +19,24 @@ set(BOOST_TEST_COMPILE_FEATURES cxx_uniform_initialization ) +if (WIN32) + set(BOOST_TEST_COMPILE_DEFINITIONS "_CRT_SECURE_NO_WARNINGS" "_CRT_SECURE_NO_DEPRECATE") +endif() + +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set(BOOST_TEST_COMPILE_OPTIONS "-Wall" "-Wextra" "-Werror") +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + set(BOOST_TEST_COMPILE_OPTIONS "/W4" "/WX") +endif() + file(GLOB RUN_TESTS LIST_DIRECTORIES OFF CONFIGURE_DEPENDS run/*.cpp) foreach(TEST IN LISTS RUN_TESTS) boost_test(TYPE run SOURCES ${TEST}) endforeach() +unset(BOOST_TEST_COMPILE_OPTIONS) + file(GLOB COMPILE_TESTS LIST_DIRECTORIES OFF CONFIGURE_DEPENDS compile/*.cpp) foreach(TEST IN LISTS COMPILE_TESTS) diff --git a/test/Jamfile b/test/Jamfile index 9a4d0b0..9481d5a 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -1,4 +1,4 @@ -# Copyright 2023 Andrey Semashev +# Copyright 2023-2024 Andrey Semashev # # Distributed under the Boost Software License, Version 1.0. # (See accompanying file LICENSE_1_0.txt or copy at @@ -38,6 +38,9 @@ project cxx11_unified_initialization_syntax cxx11_hdr_system_error ] + + windows:_CRT_SECURE_NO_WARNINGS + windows:_CRT_SECURE_NO_DEPRECATE ; # this rule enumerates through all the sources and invokes @@ -75,7 +78,12 @@ rule test_all } for file in [ glob run/*.cpp ] { - all_rules += [ run $(file) ] ; + all_rules += [ run $(file) : : : + extra + msvc:on + clang:on + gcc:on + ] ; } #ECHO All rules: $(all_rules) ; diff --git a/test/run/unique_resource.cpp b/test/run/unique_resource.cpp index a496775..96ffff6 100644 --- a/test/run/unique_resource.cpp +++ b/test/run/unique_resource.cpp @@ -24,7 +24,7 @@ template< typename Resource > struct empty_resource_deleter { - void operator() (Resource const& res) const noexcept + void operator() (Resource const&) const noexcept { } };