From 4fba7329f7e502c6e101567a36427f949c6a23aa Mon Sep 17 00:00:00 2001 From: Sayan Date: Sat, 26 Sep 2026 22:11:48 -0400 Subject: [PATCH 1/5] test: check that each compare header compiles on its own compare/{certain,possible,lexicographic,set,tribool}.hpp throw comparison_error, but only see its forward declaration in detail/interval_prototype.hpp. Clang rejects them when they are included standalone (incomplete type 'comparison_error'); g++ accepts them. These compile tests fail on clang until that is fixed. --- test/CMakeLists.txt | 5 +++++ test/Jamfile.v2 | 5 +++++ test/compare_certain_self_contained.cpp | 15 +++++++++++++++ test/compare_lexicographic_self_contained.cpp | 15 +++++++++++++++ test/compare_possible_self_contained.cpp | 15 +++++++++++++++ test/compare_set_self_contained.cpp | 15 +++++++++++++++ test/compare_tribool_self_contained.cpp | 15 +++++++++++++++ 7 files changed, 85 insertions(+) create mode 100644 test/compare_certain_self_contained.cpp create mode 100644 test/compare_lexicographic_self_contained.cpp create mode 100644 test/compare_possible_self_contained.cpp create mode 100644 test/compare_set_self_contained.cpp create mode 100644 test/compare_tribool_self_contained.cpp diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index cae3ff8..a182c59 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,6 +26,11 @@ set(BOOST_TEST_LINK_LIBRARIES Boost::numeric_interval Boost::core) boost_test(TYPE compile SOURCES integer.cpp) +# Each compare header must compile on its own (clang rejects them otherwise). +foreach(h certain possible lexicographic set tribool) + boost_test(TYPE compile SOURCES compare_${h}_self_contained.cpp) +endforeach() + foreach(t add det fmod mul overflow pi pow cmp cmp_exp cmp_lex cmp_set test_float) boost_test(TYPE run SOURCES ${t}.cpp) endforeach() diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 10cffa4..14b40b2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -26,6 +26,11 @@ import testing ; { test-suite numeric/interval : [ compile integer.cpp ] + [ compile compare_certain_self_contained.cpp ] + [ compile compare_possible_self_contained.cpp ] + [ compile compare_lexicographic_self_contained.cpp ] + [ compile compare_set_self_contained.cpp ] + [ compile compare_tribool_self_contained.cpp ] [ run add.cpp ] [ run det.cpp ] diff --git a/test/compare_certain_self_contained.cpp b/test/compare_certain_self_contained.cpp new file mode 100644 index 0000000..5981772 --- /dev/null +++ b/test/compare_certain_self_contained.cpp @@ -0,0 +1,15 @@ +/* Boost test/compare_certain_self_contained.cpp + * test that compare/certain.hpp compiles when included on its own + * + * Copyright 2026 Sayan Samanta + * + * 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 + +int main() { + return 0; +} diff --git a/test/compare_lexicographic_self_contained.cpp b/test/compare_lexicographic_self_contained.cpp new file mode 100644 index 0000000..1e512d2 --- /dev/null +++ b/test/compare_lexicographic_self_contained.cpp @@ -0,0 +1,15 @@ +/* Boost test/compare_lexicographic_self_contained.cpp + * test that compare/lexicographic.hpp compiles when included on its own + * + * Copyright 2026 Sayan Samanta + * + * 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 + +int main() { + return 0; +} diff --git a/test/compare_possible_self_contained.cpp b/test/compare_possible_self_contained.cpp new file mode 100644 index 0000000..58994f8 --- /dev/null +++ b/test/compare_possible_self_contained.cpp @@ -0,0 +1,15 @@ +/* Boost test/compare_possible_self_contained.cpp + * test that compare/possible.hpp compiles when included on its own + * + * Copyright 2026 Sayan Samanta + * + * 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 + +int main() { + return 0; +} diff --git a/test/compare_set_self_contained.cpp b/test/compare_set_self_contained.cpp new file mode 100644 index 0000000..d517238 --- /dev/null +++ b/test/compare_set_self_contained.cpp @@ -0,0 +1,15 @@ +/* Boost test/compare_set_self_contained.cpp + * test that compare/set.hpp compiles when included on its own + * + * Copyright 2026 Sayan Samanta + * + * 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 + +int main() { + return 0; +} diff --git a/test/compare_tribool_self_contained.cpp b/test/compare_tribool_self_contained.cpp new file mode 100644 index 0000000..da4a4ec --- /dev/null +++ b/test/compare_tribool_self_contained.cpp @@ -0,0 +1,15 @@ +/* Boost test/compare_tribool_self_contained.cpp + * test that compare/tribool.hpp compiles when included on its own + * + * Copyright 2026 Sayan Samanta + * + * 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 + +int main() { + return 0; +} From c93c13fc8c03283e1d754c8bfaed297530bb2290 Mon Sep 17 00:00:00 2001 From: Sayan Date: Sat, 26 Sep 2026 22:21:44 -0400 Subject: [PATCH 2/5] Move comparison_error into its own header so the compare headers are self-contained The compare headers throw comparison_error but only saw its forward declaration in detail/interval_prototype.hpp; the definition lived in interval.hpp. Move it to detail/comparison_error.hpp and include that from interval.hpp and from compare/{certain,possible,lexicographic,set,tribool}.hpp. The class itself is unchanged. --- .../numeric/interval/compare/certain.hpp | 1 + .../interval/compare/lexicographic.hpp | 1 + .../numeric/interval/compare/possible.hpp | 1 + .../boost/numeric/interval/compare/set.hpp | 1 + .../numeric/interval/compare/tribool.hpp | 1 + .../interval/detail/comparison_error.hpp | 33 +++++++++++++++++++ include/boost/numeric/interval/interval.hpp | 14 +------- 7 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 include/boost/numeric/interval/detail/comparison_error.hpp diff --git a/include/boost/numeric/interval/compare/certain.hpp b/include/boost/numeric/interval/compare/certain.hpp index 9232d5c..6b9f8a6 100644 --- a/include/boost/numeric/interval/compare/certain.hpp +++ b/include/boost/numeric/interval/compare/certain.hpp @@ -11,6 +11,7 @@ #define BOOST_NUMERIC_INTERVAL_COMPARE_CERTAIN_HPP #include +#include #include namespace boost { diff --git a/include/boost/numeric/interval/compare/lexicographic.hpp b/include/boost/numeric/interval/compare/lexicographic.hpp index 03f6036..4b38101 100644 --- a/include/boost/numeric/interval/compare/lexicographic.hpp +++ b/include/boost/numeric/interval/compare/lexicographic.hpp @@ -11,6 +11,7 @@ #define BOOST_NUMERIC_INTERVAL_COMPARE_LEXICOGRAPHIC_HPP #include +#include #include namespace boost { diff --git a/include/boost/numeric/interval/compare/possible.hpp b/include/boost/numeric/interval/compare/possible.hpp index 59bec31..32b748a 100644 --- a/include/boost/numeric/interval/compare/possible.hpp +++ b/include/boost/numeric/interval/compare/possible.hpp @@ -11,6 +11,7 @@ #define BOOST_NUMERIC_INTERVAL_COMPARE_POSSIBLE_HPP #include +#include #include namespace boost { diff --git a/include/boost/numeric/interval/compare/set.hpp b/include/boost/numeric/interval/compare/set.hpp index 44f4d6e..680fee8 100644 --- a/include/boost/numeric/interval/compare/set.hpp +++ b/include/boost/numeric/interval/compare/set.hpp @@ -11,6 +11,7 @@ #define BOOST_NUMERIC_INTERVAL_COMPARE_SET_HPP #include +#include #include #include diff --git a/include/boost/numeric/interval/compare/tribool.hpp b/include/boost/numeric/interval/compare/tribool.hpp index 6e4a83e..c27308f 100644 --- a/include/boost/numeric/interval/compare/tribool.hpp +++ b/include/boost/numeric/interval/compare/tribool.hpp @@ -11,6 +11,7 @@ #define BOOST_NUMERIC_INTERVAL_COMPARE_TRIBOOL_HPP #include +#include #include #include diff --git a/include/boost/numeric/interval/detail/comparison_error.hpp b/include/boost/numeric/interval/detail/comparison_error.hpp new file mode 100644 index 0000000..d6ff3e3 --- /dev/null +++ b/include/boost/numeric/interval/detail/comparison_error.hpp @@ -0,0 +1,33 @@ +/* Boost interval/detail/comparison_error.hpp file + * + * Copyright 2002-2003 Hervé Brönnimann, Guillaume Melquiond, Sylvain Pion + * Copyright 2026 Sayan Samanta + * + * 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) + */ + +#ifndef BOOST_NUMERIC_INTERVAL_DETAIL_COMPARISON_ERROR_HPP +#define BOOST_NUMERIC_INTERVAL_DETAIL_COMPARISON_ERROR_HPP + +#include + +namespace boost { +namespace numeric { +namespace interval_lib { + +class comparison_error + : public std::runtime_error +{ +public: + comparison_error() + : std::runtime_error("boost::interval: uncertain comparison") + { } +}; + +} // namespace interval_lib +} // namespace numeric +} // namespace boost + +#endif // BOOST_NUMERIC_INTERVAL_DETAIL_COMPARISON_ERROR_HPP diff --git a/include/boost/numeric/interval/interval.hpp b/include/boost/numeric/interval/interval.hpp index e89af48..10a6c40 100644 --- a/include/boost/numeric/interval/interval.hpp +++ b/include/boost/numeric/interval/interval.hpp @@ -13,23 +13,11 @@ #include #include #include +#include namespace boost { namespace numeric { -namespace interval_lib { - -class comparison_error - : public std::runtime_error -{ -public: - comparison_error() - : std::runtime_error("boost::interval: uncertain comparison") - { } -}; - -} // namespace interval_lib - /* * interval class */ From 6c279041e227a66e24efb77aa4f56ce88606b435 Mon Sep 17 00:00:00 2001 From: Sayan Date: Tue, 29 Sep 2026 07:24:19 -0400 Subject: [PATCH 3/5] Mark comparison_error with BOOST_SYMBOL_VISIBLE --- include/boost/numeric/interval/detail/comparison_error.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/boost/numeric/interval/detail/comparison_error.hpp b/include/boost/numeric/interval/detail/comparison_error.hpp index d6ff3e3..2441233 100644 --- a/include/boost/numeric/interval/detail/comparison_error.hpp +++ b/include/boost/numeric/interval/detail/comparison_error.hpp @@ -11,13 +11,14 @@ #ifndef BOOST_NUMERIC_INTERVAL_DETAIL_COMPARISON_ERROR_HPP #define BOOST_NUMERIC_INTERVAL_DETAIL_COMPARISON_ERROR_HPP +#include #include namespace boost { namespace numeric { namespace interval_lib { -class comparison_error +class BOOST_SYMBOL_VISIBLE comparison_error : public std::runtime_error { public: From c234c4dbd5e959027dd17c107799664cb79b9059 Mon Sep 17 00:00:00 2001 From: Sayan Date: Tue, 29 Sep 2026 08:04:26 -0400 Subject: [PATCH 4/5] test: check that every public header is self-contained (opt-in, enabled in one b2 and one CMake CI job) --- .github/workflows/ci.yml | 7 ++- .../ext/x86_fast_rounding_control.hpp | 3 + test/CMakeLists.txt | 48 +++++++++++++-- test/Jamfile.v2 | 58 +++++++++++++++++-- test/compare_certain_self_contained.cpp | 15 ----- test/compare_lexicographic_self_contained.cpp | 15 ----- test/compare_possible_self_contained.cpp | 15 ----- test/compare_set_self_contained.cpp | 15 ----- test/compare_tribool_self_contained.cpp | 15 ----- test/self_contained_header.cpp | 20 +++++++ 10 files changed, 124 insertions(+), 87 deletions(-) delete mode 100644 test/compare_certain_self_contained.cpp delete mode 100644 test/compare_lexicographic_self_contained.cpp delete mode 100644 test/compare_possible_self_contained.cpp delete mode 100644 test/compare_set_self_contained.cpp delete mode 100644 test/compare_tribool_self_contained.cpp create mode 100644 test/self_contained_header.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 33f7bc4..ef1356a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -92,7 +92,7 @@ jobs: - { compiler: clang-19, cxxstd: "11,14,17,20,23,2c", os: ubuntu-24.04 } - { compiler: clang-20, cxxstd: "11,14,17,20,23,2c", os: ubuntu-latest, container: "ubuntu:25.04" } - { compiler: clang-21, cxxstd: "11,14,17,20,23,2c", os: ubuntu-latest, container: "ubuntu:26.04" } - - { compiler: clang-22, cxxstd: "11,14,17,20,23,2c", os: ubuntu-latest, container: "ubuntu:26.04" } + - { compiler: clang-22, cxxstd: "11,14,17,20,23,2c", os: ubuntu-latest, container: "ubuntu:26.04", self_contained_headers: "yes" } - { compiler: icpx-2025, cxxstd: "11,14,17,20,23,2c", os: ubuntu-latest, container: "intel/oneapi-hpckit:2025.2.2-0-devel-ubuntu24.04" } # libc++ - { name: "Clang w/ sanitizers", sanitize: "yes", stdlib: "libc++", @@ -283,6 +283,7 @@ jobs: ${B2_WRAPPER:-} ./b2 libs/$SELF/test "${ARGS[@]}" env: UBSAN_OPTIONS: print_stacktrace=1,report_error_type=1 + BOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS: ${{ matrix.self_contained_headers }} BDDE_DISTRO: ${{ matrix.distro }} BDDE_EDITION: ${{ matrix.edition }} BDDE_ARCH: ${{ matrix.arch }} @@ -506,7 +507,7 @@ jobs: fail-fast: false matrix: include: - - { os: ubuntu-latest, build_shared: "ON", build_type: Debug, generator: "Unix Makefiles" } + - { os: ubuntu-latest, build_shared: "ON", build_type: Debug, generator: "Unix Makefiles", self_contained_headers: "yes" } - { os: ubuntu-latest, build_shared: "OFF", build_type: Debug, generator: "Unix Makefiles" } - { os: windows-2022, build_shared: "ON", build_type: Debug, generator: "Visual Studio 17 2022" } - { os: windows-2022, build_shared: "OFF", build_type: Debug, generator: "Visual Studio 17 2022" } @@ -574,7 +575,7 @@ jobs: run: | cd "$BOOST_ROOT" mkdir __build_cmake_test__ && cd __build_cmake_test__ - cmake -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{ matrix.build_shared }} -DBUILD_TESTING=ON -DBoost_VERBOSE=ON .. + cmake -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DBOOST_INCLUDE_LIBRARIES=$SELF -DBUILD_SHARED_LIBS=${{ matrix.build_shared }} -DBUILD_TESTING=ON -DBoost_VERBOSE=ON ${{ matrix.self_contained_headers && '-DBOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS=ON' || '' }} .. cmake --build . --target tests --config ${{ matrix.build_type }} -j3 ctest --output-on-failure --no-tests=error --build-config ${{ matrix.build_type }} diff --git a/include/boost/numeric/interval/ext/x86_fast_rounding_control.hpp b/include/boost/numeric/interval/ext/x86_fast_rounding_control.hpp index a505ead..204d18a 100644 --- a/include/boost/numeric/interval/ext/x86_fast_rounding_control.hpp +++ b/include/boost/numeric/interval/ext/x86_fast_rounding_control.hpp @@ -17,6 +17,9 @@ #ifndef BOOST_NUMERIC_INTERVAL_EXT_X86_FAST_ROUNDING_CONTROL_HPP #define BOOST_NUMERIC_INTERVAL_EXT_X86_FAST_ROUNDING_CONTROL_HPP +#include +#include + namespace boost { namespace numeric { namespace interval_lib { diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a182c59..8c222f8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,10 +26,50 @@ set(BOOST_TEST_LINK_LIBRARIES Boost::numeric_interval Boost::core) boost_test(TYPE compile SOURCES integer.cpp) -# Each compare header must compile on its own (clang rejects them otherwise). -foreach(h certain possible lexicographic set tribool) - boost_test(TYPE compile SOURCES compare_${h}_self_contained.cpp) -endforeach() +# Each public header must compile on its own. These compile-only tests are +# slow and add little per configuration, so they are off by default and CI +# turns them on in one job. Keep the list in sync with Jamfile.v2. +option(BOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS "Test that each public header compiles on its own" OFF) + +if(BOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS) + set(headers + interval.hpp + interval/arith.hpp + interval/arith2.hpp + interval/arith3.hpp + interval/checking.hpp + interval/compare.hpp + interval/compare/certain.hpp + interval/compare/explicit.hpp + interval/compare/lexicographic.hpp + interval/compare/possible.hpp + interval/compare/set.hpp + interval/compare/tribool.hpp + interval/constants.hpp + interval/ext/integer.hpp + interval/hw_rounding.hpp + interval/interval.hpp + interval/io.hpp + interval/limits.hpp + interval/policies.hpp + interval/rounded_arith.hpp + interval/rounded_transc.hpp + interval/rounding.hpp + interval/transc.hpp + interval/utility.hpp + interval/utility_fwd.hpp + ) + # x86 only by design. + if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64|x86|i[3-6]86)$") + list(APPEND headers interval/ext/x86_fast_rounding_control.hpp) + endif() + + foreach(h IN LISTS headers) + string(MAKE_C_IDENTIFIER "${h}" name) + boost_test(TYPE compile NAME self_contained-${name} SOURCES self_contained_header.cpp + COMPILE_DEFINITIONS BOOST_NUMERIC_INTERVAL_TEST_HEADER=${h}) + endforeach() +endif() foreach(t add det fmod mul overflow pi pow cmp cmp_exp cmp_lex cmp_set test_float) boost_test(TYPE run SOURCES ${t}.cpp) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 14b40b2..1d3463c 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -22,15 +22,63 @@ project # bring in rules for testing import testing ; +import os ; +import regex ; + +# Each public header must compile on its own. These compile-only tests are +# slow and add little per configuration, so they are off by default; set the +# BOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS environment variable to +# run them. Keep the list in sync with CMakeLists.txt. +local self_contained_headers = + interval.hpp + interval/arith.hpp + interval/arith2.hpp + interval/arith3.hpp + interval/checking.hpp + interval/compare.hpp + interval/compare/certain.hpp + interval/compare/explicit.hpp + interval/compare/lexicographic.hpp + interval/compare/possible.hpp + interval/compare/set.hpp + interval/compare/tribool.hpp + interval/constants.hpp + interval/ext/integer.hpp + interval/ext/x86_fast_rounding_control.hpp + interval/hw_rounding.hpp + interval/interval.hpp + interval/io.hpp + interval/limits.hpp + interval/policies.hpp + interval/rounded_arith.hpp + interval/rounded_transc.hpp + interval/rounding.hpp + interval/transc.hpp + interval/utility.hpp + interval/utility_fwd.hpp + ; + +local self_contained_tests ; +if [ os.environ BOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS ] +{ + for local h in $(self_contained_headers) + { + local requirements = BOOST_NUMERIC_INTERVAL_TEST_HEADER=$(h) ; + if $(h) = interval/ext/x86_fast_rounding_control.hpp + { + # x86 only by design. + requirements += [ check-target-builds /boost/architecture//x86 : : no ] ; + } + self_contained_tests += [ compile self_contained_header.cpp + : $(requirements) + : [ regex.replace self_contained-$(h) "[/.]" "-" ] ] ; + } +} { test-suite numeric/interval : [ compile integer.cpp ] - [ compile compare_certain_self_contained.cpp ] - [ compile compare_possible_self_contained.cpp ] - [ compile compare_lexicographic_self_contained.cpp ] - [ compile compare_set_self_contained.cpp ] - [ compile compare_tribool_self_contained.cpp ] + $(self_contained_tests) [ run add.cpp ] [ run det.cpp ] diff --git a/test/compare_certain_self_contained.cpp b/test/compare_certain_self_contained.cpp deleted file mode 100644 index 5981772..0000000 --- a/test/compare_certain_self_contained.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* Boost test/compare_certain_self_contained.cpp - * test that compare/certain.hpp compiles when included on its own - * - * Copyright 2026 Sayan Samanta - * - * 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 - -int main() { - return 0; -} diff --git a/test/compare_lexicographic_self_contained.cpp b/test/compare_lexicographic_self_contained.cpp deleted file mode 100644 index 1e512d2..0000000 --- a/test/compare_lexicographic_self_contained.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* Boost test/compare_lexicographic_self_contained.cpp - * test that compare/lexicographic.hpp compiles when included on its own - * - * Copyright 2026 Sayan Samanta - * - * 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 - -int main() { - return 0; -} diff --git a/test/compare_possible_self_contained.cpp b/test/compare_possible_self_contained.cpp deleted file mode 100644 index 58994f8..0000000 --- a/test/compare_possible_self_contained.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* Boost test/compare_possible_self_contained.cpp - * test that compare/possible.hpp compiles when included on its own - * - * Copyright 2026 Sayan Samanta - * - * 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 - -int main() { - return 0; -} diff --git a/test/compare_set_self_contained.cpp b/test/compare_set_self_contained.cpp deleted file mode 100644 index d517238..0000000 --- a/test/compare_set_self_contained.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* Boost test/compare_set_self_contained.cpp - * test that compare/set.hpp compiles when included on its own - * - * Copyright 2026 Sayan Samanta - * - * 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 - -int main() { - return 0; -} diff --git a/test/compare_tribool_self_contained.cpp b/test/compare_tribool_self_contained.cpp deleted file mode 100644 index da4a4ec..0000000 --- a/test/compare_tribool_self_contained.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* Boost test/compare_tribool_self_contained.cpp - * test that compare/tribool.hpp compiles when included on its own - * - * Copyright 2026 Sayan Samanta - * - * 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 - -int main() { - return 0; -} diff --git a/test/self_contained_header.cpp b/test/self_contained_header.cpp new file mode 100644 index 0000000..342bc8d --- /dev/null +++ b/test/self_contained_header.cpp @@ -0,0 +1,20 @@ +/* Boost test/self_contained_header.cpp + * test that a public header compiles when included on its own + * + * The header is given relative to boost/numeric by the build system in + * BOOST_NUMERIC_INTERVAL_TEST_HEADER, e.g. interval/compare/certain.hpp. + * + * Copyright 2026 Sayan Samanta + * + * 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) + */ + +#define BOOST_NUMERIC_INTERVAL_TEST_INCLUDE_HEADER() + +#include BOOST_NUMERIC_INTERVAL_TEST_INCLUDE_HEADER() + +int main() { + return 0; +} From aa48982bf844e660fc94fb0c7e7829ddce205705 Mon Sep 17 00:00:00 2001 From: Sayan Date: Tue, 29 Sep 2026 09:55:38 -0400 Subject: [PATCH 5/5] test: glob the public headers for the self-contained tests --- test/CMakeLists.txt | 36 ++++++------------------------------ test/Jamfile.v2 | 38 +++++++------------------------------- 2 files changed, 13 insertions(+), 61 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8c222f8..bf2f8b8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -28,40 +28,16 @@ boost_test(TYPE compile SOURCES integer.cpp) # Each public header must compile on its own. These compile-only tests are # slow and add little per configuration, so they are off by default and CI -# turns them on in one job. Keep the list in sync with Jamfile.v2. +# turns them on in one job. option(BOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS "Test that each public header compiles on its own" OFF) if(BOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS) - set(headers - interval.hpp - interval/arith.hpp - interval/arith2.hpp - interval/arith3.hpp - interval/checking.hpp - interval/compare.hpp - interval/compare/certain.hpp - interval/compare/explicit.hpp - interval/compare/lexicographic.hpp - interval/compare/possible.hpp - interval/compare/set.hpp - interval/compare/tribool.hpp - interval/constants.hpp - interval/ext/integer.hpp - interval/hw_rounding.hpp - interval/interval.hpp - interval/io.hpp - interval/limits.hpp - interval/policies.hpp - interval/rounded_arith.hpp - interval/rounded_transc.hpp - interval/rounding.hpp - interval/transc.hpp - interval/utility.hpp - interval/utility_fwd.hpp - ) + set(headers_path ${CMAKE_CURRENT_SOURCE_DIR}/../include/boost/numeric) + file(GLOB_RECURSE headers RELATIVE ${headers_path} CONFIGURE_DEPENDS ${headers_path}/*.hpp) + list(FILTER headers EXCLUDE REGEX "/detail/") # x86 only by design. - if(CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64|x86|i[3-6]86)$") - list(APPEND headers interval/ext/x86_fast_rounding_control.hpp) + if(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(x86_64|AMD64|amd64|x86|i[3-6]86)$") + list(REMOVE_ITEM headers interval/ext/x86_fast_rounding_control.hpp) endif() foreach(h IN LISTS headers) diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index 1d3463c..57b8885 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -23,47 +23,23 @@ project # bring in rules for testing import testing ; import os ; +import path ; import regex ; # Each public header must compile on its own. These compile-only tests are # slow and add little per configuration, so they are off by default; set the # BOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS environment variable to -# run them. Keep the list in sync with CMakeLists.txt. -local self_contained_headers = - interval.hpp - interval/arith.hpp - interval/arith2.hpp - interval/arith3.hpp - interval/checking.hpp - interval/compare.hpp - interval/compare/certain.hpp - interval/compare/explicit.hpp - interval/compare/lexicographic.hpp - interval/compare/possible.hpp - interval/compare/set.hpp - interval/compare/tribool.hpp - interval/constants.hpp - interval/ext/integer.hpp - interval/ext/x86_fast_rounding_control.hpp - interval/hw_rounding.hpp - interval/interval.hpp - interval/io.hpp - interval/limits.hpp - interval/policies.hpp - interval/rounded_arith.hpp - interval/rounded_transc.hpp - interval/rounding.hpp - interval/transc.hpp - interval/utility.hpp - interval/utility_fwd.hpp - ; +# run them. +path-constant INTERVAL_INCLUDE_DIR : ../include ; local self_contained_tests ; if [ os.environ BOOST_NUMERIC_INTERVAL_TEST_SELF_CONTAINED_HEADERS ] { - for local h in $(self_contained_headers) + local headers_path = [ path.make $(INTERVAL_INCLUDE_DIR)/boost/numeric ] ; + for local file in [ path.glob-tree $(headers_path) : *.hpp : detail ] { - local requirements = BOOST_NUMERIC_INTERVAL_TEST_HEADER=$(h) ; + local h = [ path.relative-to $(headers_path) $(file) ] ; + local requirements = BOOST_NUMERIC_INTERVAL_TEST_HEADER=$(h) $(file) ; if $(h) = interval/ext/x86_fast_rounding_control.hpp { # x86 only by design.