From 1c6eb890a0e3e8a2c882adefc374209d45197c2f Mon Sep 17 00:00:00 2001 From: Zhe Feng Date: Sat, 21 Nov 2026 13:08:10 +0000 Subject: [PATCH 1/2] tests: doctest programs speak the mtest protocol (mcpplibs.mtest.doctest) The root package and tests/dll take mcpplibs.mtest.doctest 0.11.1 as a dev-dependency: doctest's implementation and main are compiled once in the package, and mcpp test --cases / --case / --failed / --split case act on each doctest case (#7). The 139 test files and the two port generators drop DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN (about 1.5 s per file under GCC). mcpp links the adapter into every test and its main into every test whose text defines none, so: - co_main.cpp and the three Boost.Test header-form tests, whose main comes from a header, declare it as that header does. - The ports relied on doctest's implementation for , , , and ; port_examples.py adds the C header a case uses (C_NAMES) and the generated files have it; three hand-written files include theirs. - asio/custom_types and geometry/api_reference compare with contains(): a CHECK against std::string::npos in a TU that only imports std makes GCC 16 emit npos as a strong symbol, which now meets libstdc++.a's string-inst.o. test_coverage.py reads the cases a protocol program lists from mcpp's record (listed): such a program reports --list-test-cases to mcpp, not to its output. CI runs the same command. --- docs/architecture.md | 6 ++++- docs/architecture.zh.md | 5 +++- mcpp.toml | 1 + tests/algorithm/api_sequences.cpp | 1 - tests/algorithm/api_string.cpp | 1 - tests/algorithm/custom_types.cpp | 1 - tests/algorithm/examples.cpp | 1 - tests/algorithm/include_string_regex.cpp | 1 - tests/any/api.cpp | 1 - tests/any/custom_types.cpp | 1 - tests/any/examples.cpp | 1 - tests/asio/api_overview.cpp | 1 - tests/asio/custom_types.cpp | 3 +-- tests/asio/examples_cpp11.cpp | 1 - tests/asio/examples_cpp14.cpp | 1 - tests/asio/examples_cpp20.cpp | 1 - tests/asio/network_cpp11.cpp | 2 +- tests/asio/network_cpp14_cpp20.cpp | 2 +- tests/asio/network_http.cpp | 2 +- tests/asio/network_serialization.cpp | 1 - tests/beast/custom_types.cpp | 1 - tests/beast/doc.cpp | 1 - tests/beast/examples_http.cpp | 1 - tests/beast/examples_websocket.cpp | 2 +- tests/bimap/api.cpp | 1 - tests/bimap/custom_types.cpp | 1 - tests/bimap/examples.cpp | 1 - tests/bimap/examples_with_boost.cpp | 1 - tests/bimap/include_with_boost.cpp | 1 - tests/bloom/api.cpp | 1 - tests/bloom/custom_types.cpp | 1 - tests/bloom/examples.cpp | 1 - tests/bloom/genome.cpp | 1 - tests/callable_traits/custom_types.cpp | 1 - tests/callable_traits/examples.cpp | 1 - tests/charconv/api.cpp | 1 - tests/circular_buffer/api.cpp | 1 - tests/circular_buffer/custom_types.cpp | 1 - tests/circular_buffer/examples.cpp | 1 - tests/cobalt/co_main.cpp | 5 ++++ tests/cobalt/custom_types.cpp | 1 - tests/cobalt/doc.cpp | 1 - tests/cobalt/examples.cpp | 1 - tests/compat/api.cpp | 1 - tests/compat/custom_types.cpp | 1 - tests/container/api.cpp | 1 - tests/container/custom_types.cpp | 1 - tests/container/examples.cpp | 1 - tests/container_hash/custom_types.cpp | 1 - tests/container_hash/examples.cpp | 1 - tests/container_hash/include_describe.cpp | 1 - tests/container_hash/mixed_describe.cpp | 1 - tests/conversion/api.cpp | 1 - tests/conversion/custom_types.cpp | 1 - tests/conversion/examples.cpp | 1 - tests/convert/custom_types.cpp | 1 - tests/convert/examples_default_converter.cpp | 1 - tests/convert/examples_lexical_cast.cpp | 1 - tests/convert/examples_stream.cpp | 2 +- tests/convert/include_spirit.cpp | 1 - tests/core/api.cpp | 1 - tests/core/custom_types.cpp | 1 - tests/core/include_macros.cpp | 1 - tests/crc/api.cpp | 1 - tests/crc/custom_types.cpp | 1 - tests/crc/examples.cpp | 1 - tests/decimal/api_cmath_io.cpp | 2 +- tests/decimal/api_types.cpp | 1 - tests/decimal/custom_types.cpp | 1 - tests/decimal/examples.cpp | 1 - tests/describe/examples_json.cpp | 1 - tests/describe/examples_serialization.cpp | 1 - tests/describe/include_custom_types.cpp | 1 - tests/describe/include_examples.cpp | 1 - tests/dll/custom_types.cpp | 1 - tests/dll/examples.cpp | 1 - tests/dll/mcpp.toml | 1 + tests/dll/self.cpp | 1 - tests/dynamic_bitset/api.cpp | 1 - tests/dynamic_bitset/custom_types.cpp | 1 - tests/dynamic_bitset/examples.cpp | 1 - tests/geometry/api_index.cpp | 1 - tests/geometry/api_reference.cpp | 5 ++-- tests/geometry/custom_types.cpp | 1 - tests/geometry/examples.cpp | 2 +- tests/geometry/examples_2.cpp | 1 - tests/geometry/examples_3.cpp | 1 - tests/geometry/examples_algorithms.cpp | 2 +- tests/geometry/examples_core_geometries.cpp | 1 - tests/geometry/examples_core_geometries_2.cpp | 1 - tests/geometry/examples_core_geometries_3.cpp | 1 - tests/geometry/examples_core_geometries_4.cpp | 1 - tests/geometry/examples_core_geometries_5.cpp | 1 - tests/geometry/examples_core_geometries_6.cpp | 1 - tests/geometry/examples_index.cpp | 1 - tests/geometry/examples_strategies_io.cpp | 1 - tests/hash2/api.cpp | 1 - tests/hash2/custom_types.cpp | 1 - tests/hash2/examples.cpp | 1 - tests/hash2/mixed_describe.cpp | 1 - tests/json/custom_types.cpp | 1 - tests/json/doc_background.cpp | 1 - tests/json/doc_forward_conversion.cpp | 1 - tests/json/doc_parsing.cpp | 1 - tests/json/doc_quick_look.cpp | 1 - tests/json/doc_serializing.cpp | 1 - tests/json/doc_snippets.cpp | 1 - tests/json/doc_storage_ptr.cpp | 1 - tests/json/doc_uses_allocator.cpp | 1 - tests/json/doc_using_numbers.cpp | 1 - tests/json/examples.cpp | 2 +- tests/json/mixed_describe.cpp | 1 - tests/math/custom_types.cpp | 1 - tests/math/doc_distributions.cpp | 1 - tests/math/doc_numerics.cpp | 1 - tests/math/doc_policies.cpp | 1 - tests/math/doc_sf.cpp | 1 - tests/math/doc_tools.cpp | 2 +- tests/math/examples_1.cpp | 1 - tests/math/examples_2.cpp | 2 +- tests/math/examples_3.cpp | 1 - tests/math/examples_4.cpp | 1 - tests/mqtt5/custom_types.cpp | 1 - tests/mqtt5/doc.cpp | 1 - tests/mqtt5/examples.cpp | 3 ++- tests/regex/api.cpp | 1 - tests/regex/custom_types.cpp | 1 - tests/regex/examples.cpp | 1 - tests/regex/examples_grep.cpp | 1 - tests/regex/posix_api.cpp | 1 - tests/test/custom_types.cpp | 3 +++ tests/test/included/doc_reference.cpp | 3 +++ tests/test/included/smoke.cpp | 3 +++ tests/unordered/api.cpp | 1 - tests/unordered/custom_types.cpp | 1 - tests/unordered/examples.cpp | 1 - tests/unordered/include_stats.cpp | 1 - tests/url/custom_types.cpp | 1 - tests/url/doc_doc_3_urls.cpp | 1 - tests/url/doc_doc_grammar.cpp | 1 - tests/url/doc_snippets.cpp | 1 - tests/url/examples.cpp | 1 - tests/uuid/api.cpp | 1 - tests/uuid/custom_types.cpp | 1 - tests/variant2/api.cpp | 1 - tests/variant2/custom_types.cpp | 1 - tests/variant2/examples.cpp | 1 - tools/ci/test_coverage.py | 15 +++++++++++ tools/port_tests/libs/callable_traits.py | 1 - tools/port_tests/port_examples.py | 25 +++++++++++++++++-- 150 files changed, 79 insertions(+), 147 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 952b70ad..d55ebda1 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -291,7 +291,11 @@ keeps byte-identical notices. 1.92.0 release to a case or a reason; `tools/ci/test_coverage.py check` runs in CI, and on the linux-gcc x86_64 legs also checks each case against the cases the built test programs list (doctest `--list-test-cases`, Boost.Test - `--list_content`). The mechanically ported files (their header says so) are generator + `--list_content`). The doctest programs speak the mtest test protocol through + the `mcpplibs.mtest.doctest` dev-dependency, which compiles doctest's + implementation and `main` once: a test file includes `` and + defines no `DOCTEST_CONFIG_IMPLEMENT*`, and `mcpp test --cases` / `--case` act on + their cases. The mechanically ported files (their header says so) are generator output: `tools/port_tests/regen.py` re-creates them from the release archive and the oracle, after a Boost upgrade followed by `test_coverage.py scan` and `link`. `tests/dll/` (with plugin shared libraries) and `tests/test/utf/` diff --git a/docs/architecture.zh.md b/docs/architecture.zh.md index 4dd005c6..70d82471 100644 --- a/docs/architecture.zh.md +++ b/docs/architecture.zh.md @@ -257,7 +257,10 @@ feature(两种 Boost.Test 形态绝不能链接在一起)。 文档中的代码(`doc*.cpp`、`api*.cpp`)、各定制点上的自定义类型(`custom_types.cpp`), 以及 `coverage.toml`:1.92.0 发布包中每个示例和文档章节都映射到一个用例或写明理由; CI 运行 `tools/ci/test_coverage.py check`,并在 linux-gcc x86_64 腿上按构建出的测试程序 - 列出的用例(doctest `--list-test-cases`、Boost.Test `--list_content`)核对每个用例。机械移植的文件(头注释写明)是生成结果: + 列出的用例(doctest `--list-test-cases`、Boost.Test `--list_content`)核对每个用例。 + doctest 程序经由 dev-dependency `mcpplibs.mtest.doctest` 实现 mtest 测试协议,doctest 的实现与 + `main` 只编译一次:测试文件只包含 ``,不定义 `DOCTEST_CONFIG_IMPLEMENT*`, + `mcpp test --cases` / `--case` 作用于其中的用例。机械移植的文件(头注释写明)是生成结果: `tools/port_tests/regen.py` 从发布包和 oracle 重新生成它们(升级 Boost 后运行, 再跑 `test_coverage.py scan` / `link`)。`tests/dll/`(带插件共享库)与 `tests/test/utf/`(Boost.Test 的编译形态)是独立工程,被根清单的 `[test] discover` diff --git a/mcpp.toml b/mcpp.toml index 675517af..fce45594 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -737,6 +737,7 @@ kind = "lib" # The test programs under tests// are doctest programs, one per file. [dev-dependencies] compat.doctest = "2.4.12" +mcpplibs.mtest.doctest = "0.11.1" # tests/dll/ (shared-library plugins) and tests/test/utf/ (the compiled # Boost.Test form, which needs the unit-test-framework feature on) are projects diff --git a/tests/algorithm/api_sequences.cpp b/tests/algorithm/api_sequences.cpp index 65e3c21f..78a45f62 100644 --- a/tests/algorithm/api_sequences.cpp +++ b/tests/algorithm/api_sequences.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.algorithm — the sequence algorithms (cxx11/14/17, // searching, hex, gather, clamp, ordering, permutation) through the module. // Cases named "doc:
" carry the Examples of libs/algorithm/doc/.qbk. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.algorithm; diff --git a/tests/algorithm/api_string.cpp b/tests/algorithm/api_string.cpp index 35bcf961..a6b82c79 100644 --- a/tests/algorithm/api_string.cpp +++ b/tests/algorithm/api_string.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.algorithm — the string algorithms (boost/algorithm/ // string.hpp, trim_all) through the module: case conversion, trimming, // predicates, find/replace/erase families, split/join, finders and formatters. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.algorithm; diff --git a/tests/algorithm/custom_types.cpp b/tests/algorithm/custom_types.cpp index b4b114b4..dd3ef2e5 100644 --- a/tests/algorithm/custom_types.cpp +++ b/tests/algorithm/custom_types.cpp @@ -3,7 +3,6 @@ // comparators (function objects, function pointers, lambdas), user iterators // (a bidirectional list-like container), and string algorithms over a user // character sequence. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.algorithm; diff --git a/tests/algorithm/examples.cpp b/tests/algorithm/examples.cpp index a6474c3f..3773c063 100644 --- a/tests/algorithm/examples.cpp +++ b/tests/algorithm/examples.cpp @@ -3,7 +3,6 @@ // case keeps the example's data and calls and turns what it prints into // checks. string/example/regex_example.cpp is include_string_regex.cpp: the // *_regex family is not in the module (tools/export_policy.toml [algorithm]). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.algorithm; diff --git a/tests/algorithm/include_string_regex.cpp b/tests/algorithm/include_string_regex.cpp index abaa6932..1afda757 100644 --- a/tests/algorithm/include_string_regex.cpp +++ b/tests/algorithm/include_string_regex.cpp @@ -4,7 +4,6 @@ // as headers. No import in this TU (gcc include+import ODR rule). Covers // libs/algorithm/string/example/regex_example.cpp; regex's compiled TUs come // from the package's base source list. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/any/api.cpp b/tests/any/api.cpp index de22705e..3d3f0527 100644 --- a/tests/any/api.cpp +++ b/tests/any/api.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.any — boost::any, boost::anys::basic_any and // boost::anys::unique_any: construction, assignment, swap, the any_cast // family (value, reference, pointer, rvalue), unsafe_any_cast, type queries. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.any; diff --git a/tests/any/custom_types.cpp b/tests/any/custom_types.cpp index fddb2113..4875716f 100644 --- a/tests/any/custom_types.cpp +++ b/tests/any/custom_types.cpp @@ -3,7 +3,6 @@ // move-only allowed for unique_any), small-object storage vs heap storage, // a throwing copy constructor leaving the target unchanged, and destructors // running exactly once. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.any; diff --git a/tests/any/examples.cpp b/tests/any/examples.cpp index 81e1d7c0..f474946e 100644 --- a/tests/any/examples.cpp +++ b/tests/any/examples.cpp @@ -1,6 +1,5 @@ // mcpplibs.mwrap.boost.any — the documentation examples of Boost.Any // (libs/any/doc/any.qbk, sections "Examples" and "C++20 module") as test cases. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.any; diff --git a/tests/asio/api_overview.cpp b/tests/asio/api_overview.cpp index cdab7bf4..f6470d7d 100644 --- a/tests/asio/api_overview.cpp +++ b/tests/asio/api_overview.cpp @@ -2,7 +2,6 @@ // (libs/asio/doc/overview/*.qbk, std_executors.qbk, using.qbk), one case per // page: the features they describe, exercised in-process (loopback sockets, // pipes, timers, signals) through the module. Cases are "doc: #". -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include // BOOST_ASIO_HAS_* feature macros diff --git a/tests/asio/custom_types.cpp b/tests/asio/custom_types.cpp index 36ab53c3..8e83e539 100644 --- a/tests/asio/custom_types.cpp +++ b/tests/asio/custom_types.cpp @@ -7,7 +7,6 @@ // IoObjectService, a user CancellationHandler, user SyncRandomAccessRead/ // WriteDevice types for read_at / write_at, and a user asynchronous // operation built with async_initiate (asynchronous_operations.qbk). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include import std; @@ -161,7 +160,7 @@ TEST_CASE("a user completion token") { user::async_sum(t, 1, 1, user::log_token{&log}); ctx.run(); REQUIRE(log.size() == 1); - CHECK(log[0].find("[2]") != std::string::npos); + CHECK(log[0].contains("[2]")); } TEST_CASE("doc: WaitToken#WaitToken") { diff --git a/tests/asio/examples_cpp11.cpp b/tests/asio/examples_cpp11.cpp index 0d1813c6..3c59ee12 100644 --- a/tests/asio/examples_cpp11.cpp +++ b/tests/asio/examples_cpp11.cpp @@ -21,7 +21,6 @@ // C library's own text for it differs between platforms); programs that need // a POSIX stream_descriptor or socketpair are compiled only where asio has them. // The actor benchmark passes its token 500 thousand times, not 50 million. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/asio/examples_cpp14.cpp b/tests/asio/examples_cpp14.cpp index 9c90f36b..d3d319a3 100644 --- a/tests/asio/examples_cpp14.cpp +++ b/tests/asio/examples_cpp14.cpp @@ -21,7 +21,6 @@ // C library's own text for it differs between platforms); programs that need // a POSIX stream_descriptor or socketpair are compiled only where asio has them. // The actor benchmark passes its token 500 thousand times, not 50 million. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/asio/examples_cpp20.cpp b/tests/asio/examples_cpp20.cpp index dcd628b4..19924c23 100644 --- a/tests/asio/examples_cpp20.cpp +++ b/tests/asio/examples_cpp20.cpp @@ -21,7 +21,6 @@ // C library's own text for it differs between platforms); programs that need // a POSIX stream_descriptor or socketpair are compiled only where asio has them. // The actor benchmark passes its token 500 thousand times, not 50 million. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/asio/network_cpp11.cpp b/tests/asio/network_cpp11.cpp index 298c2be1..605f4ee8 100644 --- a/tests/asio/network_cpp11.cpp +++ b/tests/asio/network_cpp11.cpp @@ -14,7 +14,6 @@ #include #include #endif -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include @@ -23,6 +22,7 @@ #include #include #include +#include import std; import mcpplibs.mwrap.boost.asio; diff --git a/tests/asio/network_cpp14_cpp20.cpp b/tests/asio/network_cpp14_cpp20.cpp index 995bd9e8..83c8676e 100644 --- a/tests/asio/network_cpp14_cpp20.cpp +++ b/tests/asio/network_cpp14_cpp20.cpp @@ -8,7 +8,6 @@ // ports (13, 55555, 54321) are replaced by the free one, "daytime"/"http" // service names by its number, and output that carries the time of day is // not compared. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include @@ -16,6 +15,7 @@ #include #include #include +#include import std; import mcpplibs.mwrap.boost.asio; diff --git a/tests/asio/network_http.cpp b/tests/asio/network_http.cpp index 3bba7e2d..30f93520 100644 --- a/tests/asio/network_http.cpp +++ b/tests/asio/network_http.cpp @@ -8,12 +8,12 @@ // ports (13, 55555, 54321) are replaced by the free one, "daytime"/"http" // service names by its number, and output that carries the time of day is // not compared. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include #include #include +#include import std; import mcpplibs.mwrap.boost.asio; diff --git a/tests/asio/network_serialization.cpp b/tests/asio/network_serialization.cpp index 8ac8ce69..84aafbbc 100644 --- a/tests/asio/network_serialization.cpp +++ b/tests/asio/network_serialization.cpp @@ -8,7 +8,6 @@ // ports (13, 55555, 54321) are replaced by the free one, "daytime"/"http" // service names by its number, and output that carries the time of day is // not compared. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/beast/custom_types.cpp b/tests/beast/custom_types.cpp index d3df9cf5..42da6b3a 100644 --- a/tests/beast/custom_types.cpp +++ b/tests/beast/custom_types.cpp @@ -5,7 +5,6 @@ // websocket::stream with its own teardown / async_teardown / // beast_close_socket overloads, and the // compile-time traits rejecting types that do not model the concepts. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.beast; diff --git a/tests/beast/doc.cpp b/tests/beast/doc.cpp index 4d2ddac3..78122d70 100644 --- a/tests/beast/doc.cpp +++ b/tests/beast/doc.cpp @@ -6,7 +6,6 @@ // lists for the chunk callbacks), the WebSocket handshake (the RFC 6455 key and // accept pair), the Body and BuffersGenerator concepts, and the message // container design. Everything runs over beast::test::stream, in memory. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.beast; diff --git a/tests/beast/examples_http.cpp b/tests/beast/examples_http.cpp index 72c493b9..053f7484 100644 --- a/tests/beast/examples_http.cpp +++ b/tests/beast/examples_http.cpp @@ -8,7 +8,6 @@ // is what the same code printed when built from upstream/boost headers alone. // Response headers that carry the build (Server: Boost.Beast/) or the // time are left out by the harness. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/beast/examples_websocket.cpp b/tests/beast/examples_websocket.cpp index 3106609b..8a230055 100644 --- a/tests/beast/examples_websocket.cpp +++ b/tests/beast/examples_websocket.cpp @@ -8,7 +8,6 @@ // is what the same code printed when built from upstream/boost headers alone. // Response headers that carry the build (Server: Boost.Beast/) or the // time are left out by the harness. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include @@ -20,6 +19,7 @@ #include #include #include +#include import std; import mcpplibs.mwrap.boost.asio; import mcpplibs.mwrap.boost.beast; diff --git a/tests/bimap/api.cpp b/tests/bimap/api.cpp index 4a02aded..a3f75cfd 100644 --- a/tests/bimap/api.cpp +++ b/tests/bimap/api.cpp @@ -2,7 +2,6 @@ // Boost.Bimap documentation (libs/bimap/doc/{quick_tutorial,tutorial, // rationale}.qbk) whose code is written inline; sections that import an // example are covered by that example's case (coverage.toml). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.bimap; diff --git a/tests/bimap/custom_types.cpp b/tests/bimap/custom_types.cpp index 9d572533..f16c2dd0 100644 --- a/tests/bimap/custom_types.cpp +++ b/tests/bimap/custom_types.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.bimap — user types on both sides: a user key with its // own ordering and hashing, user comparators and hashers passed to the set // types, user tags, user info payloads, modify/replace with user functors. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.bimap; diff --git a/tests/bimap/examples.cpp b/tests/bimap/examples.cpp index ce4efc76..5f1a4607 100644 --- a/tests/bimap/examples.cpp +++ b/tests/bimap/examples.cpp @@ -4,7 +4,6 @@ // alone. Interactive examples read a fixed stdin. population_bimap.cpp, // mi_hashed_indices.cpp and the bimap_and_boost/ examples are // examples_with_boost.cpp and include_with_boost.cpp. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/bimap/examples_with_boost.cpp b/tests/bimap/examples_with_boost.cpp index 7c4e15d2..4f4893e6 100644 --- a/tests/bimap/examples_with_boost.cpp +++ b/tests/bimap/examples_with_boost.cpp @@ -15,7 +15,6 @@ // The range module exports boost::count_if, which range.cpp's own count_if // meets through `using namespace boost` (the original includes only the range // headers it needs); the port calls the example's count_if qualified. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/bimap/include_with_boost.cpp b/tests/bimap/include_with_boost.cpp index c4538173..d748032f 100644 --- a/tests/bimap/include_with_boost.cpp +++ b/tests/bimap/include_with_boost.cpp @@ -2,7 +2,6 @@ // {foreach,typeof,xpressive}.cpp exercise BOOST_FOREACH, BOOST_TYPEOF / // BOOST_AUTO and xpressive actions, which no module can carry, so this TU // includes everything and imports nothing. Same output oracle as examples.cpp. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/bloom/api.cpp b/tests/bloom/api.cpp index 8a6929b7..eab66aef 100644 --- a/tests/bloom/api.cpp +++ b/tests/bloom/api.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.bloom — the tutorial of Boost.Bloom // (libs/bloom/doc/bloom/tutorial.adoc) section by section, plus the subfilter // family and the filter's construction/assignment/comparison members. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.bloom; diff --git a/tests/bloom/custom_types.cpp b/tests/bloom/custom_types.cpp index 9d87c16a..c21f0f7b 100644 --- a/tests/bloom/custom_types.cpp +++ b/tests/bloom/custom_types.cpp @@ -2,7 +2,6 @@ // struct hashed through boost::hash (hash_value found by ADL), a user hasher // marked as avalanching (is_avalanching, so the filter skips its own mixing), // a user hasher without the mark (mixed by the filter), and a user allocator. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.bloom; diff --git a/tests/bloom/examples.cpp b/tests/bloom/examples.cpp index fac7b7ea..d03553a2 100644 --- a/tests/bloom/examples.cpp +++ b/tests/bloom/examples.cpp @@ -5,7 +5,6 @@ // of ./filter.bin, and keeps its #include of boost/core/detail/splitmix64.hpp // (a detail header no module exports). genome.cpp reads a 140 MB genome // download: genome.cpp in this directory runs it on a small FASTA fixture. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/bloom/genome.cpp b/tests/bloom/genome.cpp index ade61184..a8f93f51 100644 --- a/tests/bloom/genome.cpp +++ b/tests/bloom/genome.cpp @@ -3,7 +3,6 @@ // k-mer filter code (copied unchanged below) on a small FASTA fixture holding // the three sequences the example expects to find, and checks the example's // expected answers: 1 1 1 0 0. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/callable_traits/custom_types.cpp b/tests/callable_traits/custom_types.cpp index dfd53f9a..442d1cbb 100644 --- a/tests/callable_traits/custom_types.cpp +++ b/tests/callable_traits/custom_types.cpp @@ -3,7 +3,6 @@ // (including generic and overloaded ones), user function pointers, and the // FAQ's point (libs/callable_traits/doc/callable_traits.qbk#faq): one trait // replaces the hand-written partial specializations per callable shape. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.callable_traits; diff --git a/tests/callable_traits/examples.cpp b/tests/callable_traits/examples.cpp index a1acb1bc..50dd307d 100644 --- a/tests/callable_traits/examples.cpp +++ b/tests/callable_traits/examples.cpp @@ -6,7 +6,6 @@ // and transaction_safe (GCC's -fgnu-tm) is off: the three *_transaction_safe // examples compile to an empty main upstream then, and are excluded in // coverage.toml. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.callable_traits; diff --git a/tests/charconv/api.cpp b/tests/charconv/api.cpp index b30e224b..c0adbadb 100644 --- a/tests/charconv/api.cpp +++ b/tests/charconv/api.cpp @@ -4,7 +4,6 @@ // from_chars_erange, every base, every chars_format). The library has no // user-type customization point. to_chars does not null-terminate, so results // are compared as [first, ptr) instead of with strcmp. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.charconv; diff --git a/tests/circular_buffer/api.cpp b/tests/circular_buffer/api.cpp index 1d011d39..6cd005fc 100644 --- a/tests/circular_buffer/api.cpp +++ b/tests/circular_buffer/api.cpp @@ -3,7 +3,6 @@ // at both ends with overwrite, rotation and linearization, array_one/array_two, // insert/erase/rinsert/rerase, assign, set_capacity / rset_capacity, resize, // comparison and swap. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.circular_buffer; diff --git a/tests/circular_buffer/custom_types.cpp b/tests/circular_buffer/custom_types.cpp index df8129fc..0e50f11f 100644 --- a/tests/circular_buffer/custom_types.cpp +++ b/tests/circular_buffer/custom_types.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.circular_buffer — user element types: non-trivial // destructors run exactly once when elements are overwritten or popped, // move-only elements, a user allocator, and a user aggregate with an ordering. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.circular_buffer; diff --git a/tests/circular_buffer/examples.cpp b/tests/circular_buffer/examples.cpp index 4aa0e724..53cd186d 100644 --- a/tests/circular_buffer/examples.cpp +++ b/tests/circular_buffer/examples.cpp @@ -4,7 +4,6 @@ // counts and without boost::timer (they are timing comparisons upstream; the // test keeps the FIFO behavior). boost::call_traits::param_type is spelled // `const T&` (the int / std::string case it resolves to). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.circular_buffer; diff --git a/tests/cobalt/co_main.cpp b/tests/cobalt/co_main.cpp index eb862e78..bac7ff93 100644 --- a/tests/cobalt/co_main.cpp +++ b/tests/cobalt/co_main.cpp @@ -5,6 +5,11 @@ // on a fresh io_context and returns co_main's result. #include #include "../test_assert.hpp" + +// The header defines main; mcpp reads this file's text for a main of its own, +// and a test with none begins at the doctest adapter's entry (test-main), whose +// main would then be a second definition. The header declares main the same way. +int main(int argc, char* argv[]); import mcpplibs.mwrap.boost.cobalt; namespace { diff --git a/tests/cobalt/custom_types.cpp b/tests/cobalt/custom_types.cpp index 40e50ccd..cb87bd34 100644 --- a/tests/cobalt/custom_types.cpp +++ b/tests/cobalt/custom_types.cpp @@ -5,7 +5,6 @@ // generator / channel carrying a move-only user type, and a user executor // (the properties any_io_executor needs) that cobalt::spawn runs a task on; // the concepts rejecting non-awaitables. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/cobalt/doc.cpp b/tests/cobalt/doc.cpp index 50f0aacd..f03a6d77 100644 --- a/tests/cobalt/doc.cpp +++ b/tests/cobalt/doc.cpp @@ -8,7 +8,6 @@ // generator of the tutorial. Declarations the pages leave undefined // (do_the_thing, gen1, some_data_source, ...) are given small bodies; printf // output goes to a string the cases compare. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/cobalt/examples.cpp b/tests/cobalt/examples.cpp index 8848db3e..1d4300e1 100644 --- a/tests/cobalt/examples.cpp +++ b/tests/cobalt/examples.cpp @@ -8,7 +8,6 @@ // a harness client exchanges one message with it; delay / delay_op get a // 10 ms delay as argv[1]. The output of thread and thread_pool (worker // threads) is not compared. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/compat/api.cpp b/tests/compat/api.cpp index 29f12d56..2bb7ea5e 100644 --- a/tests/compat/api.cpp +++ b/tests/compat/api.cpp @@ -3,7 +3,6 @@ // integer_sequence, invoke and its traits, latch, mem_fn, move_only_function, // nontype, shared_lock, to_array, to_underlying. Cases are named // "doc: #
" after the documentation section they exercise. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.compat; diff --git a/tests/compat/custom_types.cpp b/tests/compat/custom_types.cpp index 927104eb..04d4efb4 100644 --- a/tests/compat/custom_types.cpp +++ b/tests/compat/custom_types.cpp @@ -3,7 +3,6 @@ // over user function objects (stateful, move-only, overloaded on value // category), bind_front/bind_back/invoke over user member functions and data // members, to_underlying on user enums, shared_lock over a user SharedMutex. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.compat; diff --git a/tests/container/api.cpp b/tests/container/api.cpp index 2ffa55b0..b7ccaf36 100644 --- a/tests/container/api.cpp +++ b/tests/container/api.cpp @@ -3,7 +3,6 @@ // devector, stable_vector, small/static_vector, deque, list/slist, the flat // associative containers, string, hub, the pmr aliases and memory resources, // const-reference parameters into the same container, null iterators. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.container; diff --git a/tests/container/custom_types.cpp b/tests/container/custom_types.cpp index 285a9d78..292ff914 100644 --- a/tests/container/custom_types.cpp +++ b/tests/container/custom_types.cpp @@ -4,7 +4,6 @@ // allocator through allocator_traits, vector/deque/small_vector options // (growth factor, stored size, block size, inplace alignment), and a user // memory_resource for the pmr aliases. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.container; diff --git a/tests/container/examples.cpp b/tests/container/examples.cpp index fdf7701d..6e6f6885 100644 --- a/tests/container/examples.cpp +++ b/tests/container/examples.cpp @@ -7,7 +7,6 @@ // included before the imports (docs/usage.md, macros). doc_extended_allocators // needs the dlmalloc-based allocators, which the package does not build // (tools/gen_features.py: alloc_lib.c is a C TU): coverage.toml, gap. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/container_hash/custom_types.cpp b/tests/container_hash/custom_types.cpp index 33b2c184..e8ac9e5f 100644 --- a/tests/container_hash/custom_types.cpp +++ b/tests/container_hash/custom_types.cpp @@ -5,7 +5,6 @@ // a user tuple-like type (tuple_size/get) and the is_tuple_like trait, the // is_unordered_range trait for a user set type, and hash_combine-based // composition of user types inside std containers. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.container_hash; diff --git a/tests/container_hash/examples.cpp b/tests/container_hash/examples.cpp index 866f5c03..dcf89e64 100644 --- a/tests/container_hash/examples.cpp +++ b/tests/container_hash/examples.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.container_hash — the official examples // (libs/container_hash/examples/*.cpp) as test cases. point2.cpp, which // describes its class with BOOST_DESCRIBE_CLASS, is include_describe.cpp. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.container_hash; diff --git a/tests/container_hash/include_describe.cpp b/tests/container_hash/include_describe.cpp index 2344a2ab..c2147db8 100644 --- a/tests/container_hash/include_describe.cpp +++ b/tests/container_hash/include_describe.cpp @@ -3,7 +3,6 @@ // class is hashed in a TU that includes container_hash too. Covers // libs/container_hash/examples/point2.cpp; mixed_describe.cpp checks the same // with the container_hash module imported. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/container_hash/mixed_describe.cpp b/tests/container_hash/mixed_describe.cpp index 9c82622e..8a3aa971 100644 --- a/tests/container_hash/mixed_describe.cpp +++ b/tests/container_hash/mixed_describe.cpp @@ -3,7 +3,6 @@ // hashing from `import mcpplibs.mwrap.boost.container_hash;`, which exports // boost::container_hash::is_described_class. This is the include+import mix // of design §4.4; the includes precede every import. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include import std; diff --git a/tests/conversion/api.cpp b/tests/conversion/api.cpp index 4dce9ce8..6923781b 100644 --- a/tests/conversion/api.cpp +++ b/tests/conversion/api.cpp @@ -3,7 +3,6 @@ // polymorphic_pointer_downcast over raw, std and boost smart pointers, and // implicit_cast (constexpr, no explicit conversions), after // libs/conversion/test/{cast_test,polymorphic_cast_test,implicit_cast}.cpp. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.conversion; diff --git a/tests/conversion/custom_types.cpp b/tests/conversion/custom_types.cpp index e3dfc3c5..49b43a5e 100644 --- a/tests/conversion/custom_types.cpp +++ b/tests/conversion/custom_types.cpp @@ -2,7 +2,6 @@ // smart pointer that opts into polymorphic_pointer_cast through ADL overloads // of static_pointer_cast / dynamic_pointer_cast (the documented customization // point), and implicit_cast through user conversion operators. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.conversion; diff --git a/tests/conversion/examples.cpp b/tests/conversion/examples.cpp index d4745535..2b9fc9bd 100644 --- a/tests/conversion/examples.cpp +++ b/tests/conversion/examples.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.conversion — the documentation examples of // Boost.Conversion (libs/conversion/doc/conversion.qbk) through the module // that the 2026-11-09 hardening added (design §5.3). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.conversion; diff --git a/tests/convert/custom_types.cpp b/tests/convert/custom_types.cpp index a4a3daa7..6c413f8c 100644 --- a/tests/convert/custom_types.cpp +++ b/tests/convert/custom_types.cpp @@ -5,7 +5,6 @@ // without a default constructor through boost::make_default; boost::cnv::apply // with a user converter in an algorithm; a string-to-string transforming // converter (other.qbk "Beyond Basic Conversions"). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.convert; diff --git a/tests/convert/examples_default_converter.cpp b/tests/convert/examples_default_converter.cpp index 124f4706..2ab1ef7b 100644 --- a/tests/convert/examples_default_converter.cpp +++ b/tests/convert/examples_default_converter.cpp @@ -2,7 +2,6 @@ // a user-defined default converter (a cstream configured for uppercase hex). // default_converter_fail.cpp is a compile-failure demonstration (no default // converter defined) and is excluded in coverage.toml. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.convert; diff --git a/tests/convert/examples_lexical_cast.cpp b/tests/convert/examples_lexical_cast.cpp index 434f2535..e01c57e7 100644 --- a/tests/convert/examples_lexical_cast.cpp +++ b/tests/convert/examples_lexical_cast.cpp @@ -4,7 +4,6 @@ // boost::cnv::by_default once, so the examples are grouped by the default // they define: examples_stream.cpp and examples_default_converter.cpp hold // the others. The spirit converter of getting_started is include_spirit.cpp. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.convert; diff --git a/tests/convert/examples_stream.cpp b/tests/convert/examples_stream.cpp index e5909ca5..89f7dda4 100644 --- a/tests/convert/examples_stream.cpp +++ b/tests/convert/examples_stream.cpp @@ -2,8 +2,8 @@ // converter is boost::cnv::cstream (libs/convert/example/getting_serious.cpp, // stream.cpp) and the converter-agnostic algorithms.cpp, plus the design-note // snippets of libs/convert/doc/design_notes.qbk. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include +#include import std; import mcpplibs.mwrap.boost.convert; diff --git a/tests/convert/include_spirit.cpp b/tests/convert/include_spirit.cpp index 8925c5d6..5eff7144 100644 --- a/tests/convert/include_spirit.cpp +++ b/tests/convert/include_spirit.cpp @@ -3,7 +3,6 @@ // module (tools/export_policy.toml [convert]); this TU uses headers only. // Covers the spirit part of libs/convert/example/getting_started.cpp // (example3) and the stream_converter page's default-constructible note. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/core/api.cpp b/tests/core/api.cpp index 832323eb..36c4a0fa 100644 --- a/tests/core/api.cpp +++ b/tests/core/api.cpp @@ -6,7 +6,6 @@ // pointer_in_range, pointer_traits, snprintf, span, typeinfo, // uncaught_exceptions, use_default, verbose_terminate_handler. The macro // components are include_macros.cpp. Cases are "doc: #
". -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include import std; diff --git a/tests/core/custom_types.cpp b/tests/core/custom_types.cpp index 891c51cc..3289b164 100644 --- a/tests/core/custom_types.cpp +++ b/tests/core/custom_types.cpp @@ -5,7 +5,6 @@ // allocator_access, empty_value compressing user empty types, invoke_swap // finding a user swap by ADL, ref/unwrap_ref, span over a user contiguous // container, functor<> over a user function, and demangle of user templates. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.core; diff --git a/tests/core/include_macros.cpp b/tests/core/include_macros.cpp index 64936ce9..483f1411 100644 --- a/tests/core/include_macros.cpp +++ b/tests/core/include_macros.cpp @@ -8,7 +8,6 @@ // returns; the last case (cases run in declaration order) checks that count. // Two failures are made on purpose (BOOST_ERROR, a failing BOOST_TEST_NE) // to see them counted; lightweight_test reports them on stderr. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/crc/api.cpp b/tests/crc/api.cpp index 5986d090..6db31ef9 100644 --- a/tests/crc/api.cpp +++ b/tests/crc/api.cpp @@ -2,7 +2,6 @@ // augmented_crc(), crc_basic (theoretical computer), crc_optimal (table // driven), the predefined samples checked against the CRC catalogue values for // "123456789", and the member functions of both computer templates. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.crc; diff --git a/tests/crc/custom_types.cpp b/tests/crc/custom_types.cpp index 3fb0baa9..7062c1c2 100644 --- a/tests/crc/custom_types.cpp +++ b/tests/crc/custom_types.cpp @@ -2,7 +2,6 @@ // crc_optimal / crc_basic instantiated with parameters the library does not // predefine (CRC-8, CRC-32C, CRC-64/XZ from the CRC catalogue), optimal and // basic agreeing on them, and CRCs over user-defined record types. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.crc; diff --git a/tests/crc/examples.cpp b/tests/crc/examples.cpp index 24f69ca0..918e11ff 100644 --- a/tests/crc/examples.cpp +++ b/tests/crc/examples.cpp @@ -2,7 +2,6 @@ // cases: libs/crc/crc_example.cpp (CRC-32 of files, read in blocks) and the // three snippets of libs/crc/doc/crc_examples.cpp. is included for // the va_* macros, which no module can export. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include import std; diff --git a/tests/decimal/api_cmath_io.cpp b/tests/decimal/api_cmath_io.cpp index 98a3ecb0..efc1c8c9 100644 --- a/tests/decimal/api_cmath_io.cpp +++ b/tests/decimal/api_cmath_io.cpp @@ -4,8 +4,8 @@ // functions (quantize, samequantum, decompose, frexp10, normalize, payloads, // comparetotal, rescale), , string conversions, rounding modes, // stream input of non-finite values, and std::format. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include +#include import std; import mcpplibs.mwrap.boost.decimal; diff --git a/tests/decimal/api_types.cpp b/tests/decimal/api_types.cpp index 0a994e05..cc9d73ed 100644 --- a/tests/decimal/api_types.cpp +++ b/tests/decimal/api_types.cpp @@ -3,7 +3,6 @@ // decimal_fast{32,64,128}_t.adoc): each section's members are checked by a // function template, instantiated once per type under the case name of that // type's page section, plus the fast_types and generic_decimal operator pages. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.decimal; diff --git a/tests/decimal/custom_types.cpp b/tests/decimal/custom_types.cpp index c461869f..b05473c3 100644 --- a/tests/decimal/custom_types.cpp +++ b/tests/decimal/custom_types.cpp @@ -4,7 +4,6 @@ // own rounding and streaming, decimals as keys of user containers (std::hash, // ordering), user conversion between the user type and strings via // , and the numeric_limits a user algorithm relies on. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.decimal; diff --git a/tests/decimal/examples.cpp b/tests/decimal/examples.cpp index 5acebe81..5c5c3d5a 100644 --- a/tests/decimal/examples.cpp +++ b/tests/decimal/examples.cpp @@ -12,7 +12,6 @@ // to_from_file draws its values from std::uniform_int_distribution, whose // sequence is the standard library's own, so only its round-trip result is // checked (the program verifies the values it reads back). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/describe/examples_json.cpp b/tests/describe/examples_json.cpp index 0150039f..2802fe57 100644 --- a/tests/describe/examples_json.cpp +++ b/tests/describe/examples_json.cpp @@ -7,7 +7,6 @@ // boost/json/src.hpp). // console.cpp reads a fixed stdin, and its endless loop stops at the end of // input (an added 'if (!std::cin) break;', also in the oracle's copy). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/describe/examples_serialization.cpp b/tests/describe/examples_serialization.cpp index 510cb060..247492f2 100644 --- a/tests/describe/examples_serialization.cpp +++ b/tests/describe/examples_serialization.cpp @@ -2,7 +2,6 @@ // serialization.cpp: described classes serialized through a generic // serialize() written with describe_members, archives from the module. // Output must equal the original program's. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/describe/include_custom_types.cpp b/tests/describe/include_custom_types.cpp index 3a41b4b5..519f7fb8 100644 --- a/tests/describe/include_custom_types.cpp +++ b/tests/describe/include_custom_types.cpp @@ -3,7 +3,6 @@ // (libs/describe/doc/describe/{classes,enums}.adoc) plus the queries over the // descriptors (members, bases, modifiers, static and function members, // overloads, nested enums). Pure include: describe has no module. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/describe/include_examples.cpp b/tests/describe/include_examples.cpp index 14338942..774d71de 100644 --- a/tests/describe/include_examples.cpp +++ b/tests/describe/include_examples.cpp @@ -9,7 +9,6 @@ // vendored). // pm_to_string.cpp names its own ::detail namespace; in the port it is the // case namespace's detail. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/dll/custom_types.cpp b/tests/dll/custom_types.cpp index 21fbdb25..d1ce4daa 100644 --- a/tests/dll/custom_types.cpp +++ b/tests/dll/custom_types.cpp @@ -6,7 +6,6 @@ // library it came from; and library_info listing the user section. The // exports are this program's own (-rdynamic, tests/dll/mcpp.toml), with the // macro header included next to the module import (design §4.4). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include // BOOST_SYMBOL_VISIBLE #include // BOOST_DLL_ALIAS, BOOST_DLL_ALIAS_SECTIONED diff --git a/tests/dll/examples.cpp b/tests/dll/examples.cpp index 4d698374..ab8aa3f8 100644 --- a/tests/dll/examples.cpp +++ b/tests/dll/examples.cpp @@ -6,7 +6,6 @@ // printed is captured and compared with what the example's documentation // shows. The plugin API headers (tutorial_common, tutorial8) are written out // here as the importer sees them: the dll module is imported, not included. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include // BOOST_SYMBOL_VISIBLE import std; diff --git a/tests/dll/mcpp.toml b/tests/dll/mcpp.toml index e6ba0674..7c29c18d 100644 --- a/tests/dll/mcpp.toml +++ b/tests/dll/mcpp.toml @@ -19,6 +19,7 @@ mcpplibs.mwrap.boost = { path = "../..", default-features = false, features = [" [dev-dependencies] compat.doctest = "2.4.12" +mcpplibs.mtest.doctest = "0.11.1" # The plugins: one package per shared library (a shared target is built from # its package's sources); as dev-dependencies they are built next to the test # programs, which find them in their own directory. diff --git a/tests/dll/self.cpp b/tests/dll/self.cpp index bcdb6639..b0f1d4b8 100644 --- a/tests/dll/self.cpp +++ b/tests/dll/self.cpp @@ -9,7 +9,6 @@ // §4.4); the program exports its symbols (-rdynamic, tests/dll/mcpp.toml) for // the dynamic loader to find them. #define BOOST_DLL_FORCE_ALIAS_INSTANTIATION -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include // BOOST_SYMBOL_VISIBLE #include // BOOST_DLL_ALIAS diff --git a/tests/dynamic_bitset/api.cpp b/tests/dynamic_bitset/api.cpp index 327c58df..ae2a6025 100644 --- a/tests/dynamic_bitset/api.cpp +++ b/tests/dynamic_bitset/api.cpp @@ -3,7 +3,6 @@ // bitwise and shift operators, set algebra (subset, intersects), searches // (find_first/find_next), resizing, block conversion, comparison, hashing and // string conversion. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.dynamic_bitset; diff --git a/tests/dynamic_bitset/custom_types.cpp b/tests/dynamic_bitset/custom_types.cpp index 74e5dbe2..c53f7712 100644 --- a/tests/dynamic_bitset/custom_types.cpp +++ b/tests/dynamic_bitset/custom_types.cpp @@ -2,7 +2,6 @@ // points: user-chosen Block types (unsigned char, std::uint16_t, unsigned // long long) and a user allocator (counting allocations), plus block-range // round trips through a user container. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.dynamic_bitset; diff --git a/tests/dynamic_bitset/examples.cpp b/tests/dynamic_bitset/examples.cpp index 55b497db..70f7d843 100644 --- a/tests/dynamic_bitset/examples.cpp +++ b/tests/dynamic_bitset/examples.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.dynamic_bitset — libs/dynamic_bitset/example/ // example1..3.cpp as test cases (example3 reads std::cin; it reads a string // stream here). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.dynamic_bitset; diff --git a/tests/geometry/api_index.cpp b/tests/geometry/api_index.cpp index 5c84dc5c..774d78f3 100644 --- a/tests/geometry/api_index.cpp +++ b/tests/geometry/api_index.cpp @@ -5,7 +5,6 @@ // spatial predicates, nearest, satisfies, negation and conjunction, breaking // out of a nearest iteration, query results as a range), and the reference of // predicates.qbk, rtree.qbk and rtree_functions.qbk. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.geometry; diff --git a/tests/geometry/api_reference.cpp b/tests/geometry/api_reference.cpp index b40aa43e..9c2177a7 100644 --- a/tests/geometry/api_reference.cpp +++ b/tests/geometry/api_reference.cpp @@ -4,7 +4,6 @@ // de9im masks, svg_mapper, and every strategy page (area, buffer, centroid, // densify, distance, line_interpolate, side, simplify, transform, within), // each constructed as its synopsis shows and used through its algorithm. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.geometry; @@ -258,8 +257,8 @@ TEST_CASE("doc: svg_mapper") { mapper.text(point(1, 1), "label", "font-size:8pt"); } CHECK(svg.str().starts_with("\n")); } diff --git a/tests/geometry/custom_types.cpp b/tests/geometry/custom_types.cpp index aa70fdd4..f1e6304b 100644 --- a/tests/geometry/custom_types.cpp +++ b/tests/geometry/custom_types.cpp @@ -7,7 +7,6 @@ // #included before the import: macros are not exported), and a user // coordinate type; algorithms on each, and the traits telling a non-geometry // apart. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/geometry/examples.cpp b/tests/geometry/examples.cpp index 6d4d3f45..56b7e18e 100644 --- a/tests/geometry/examples.cpp +++ b/tests/geometry/examples.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include // the macros of (its declarations are in the module) @@ -68,6 +67,7 @@ #include #include #include +#include import std; import mcpplibs.mwrap.boost.geometry; import mcpplibs.mwrap.boost.algorithm; diff --git a/tests/geometry/examples_2.cpp b/tests/geometry/examples_2.cpp index 6e8947fa..e89317ab 100644 --- a/tests/geometry/examples_2.cpp +++ b/tests/geometry/examples_2.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/geometry/examples_3.cpp b/tests/geometry/examples_3.cpp index 298d7fb3..85192811 100644 --- a/tests/geometry/examples_3.cpp +++ b/tests/geometry/examples_3.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/geometry/examples_algorithms.cpp b/tests/geometry/examples_algorithms.cpp index 7abb2677..c9b94ce6 100644 --- a/tests/geometry/examples_algorithms.cpp +++ b/tests/geometry/examples_algorithms.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include // the macros of (its declarations are in the module) @@ -52,6 +51,7 @@ }}} #endif +#include import std; import mcpplibs.mwrap.boost.geometry; import mcpplibs.mwrap.boost.algorithm; diff --git a/tests/geometry/examples_core_geometries.cpp b/tests/geometry/examples_core_geometries.cpp index c64cc751..963859fe 100644 --- a/tests/geometry/examples_core_geometries.cpp +++ b/tests/geometry/examples_core_geometries.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/geometry/examples_core_geometries_2.cpp b/tests/geometry/examples_core_geometries_2.cpp index e82f998b..f048c039 100644 --- a/tests/geometry/examples_core_geometries_2.cpp +++ b/tests/geometry/examples_core_geometries_2.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include // the macros of (its declarations are in the module) diff --git a/tests/geometry/examples_core_geometries_3.cpp b/tests/geometry/examples_core_geometries_3.cpp index aa176327..10e438a7 100644 --- a/tests/geometry/examples_core_geometries_3.cpp +++ b/tests/geometry/examples_core_geometries_3.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include // the macros of (its declarations are in the module) diff --git a/tests/geometry/examples_core_geometries_4.cpp b/tests/geometry/examples_core_geometries_4.cpp index c2d606dc..d1f949cd 100644 --- a/tests/geometry/examples_core_geometries_4.cpp +++ b/tests/geometry/examples_core_geometries_4.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include // the macros of (its declarations are in the module) diff --git a/tests/geometry/examples_core_geometries_5.cpp b/tests/geometry/examples_core_geometries_5.cpp index 2880a6f0..2ff9a01e 100644 --- a/tests/geometry/examples_core_geometries_5.cpp +++ b/tests/geometry/examples_core_geometries_5.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/geometry/examples_core_geometries_6.cpp b/tests/geometry/examples_core_geometries_6.cpp index 65aaa32d..b85512fa 100644 --- a/tests/geometry/examples_core_geometries_6.cpp +++ b/tests/geometry/examples_core_geometries_6.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/geometry/examples_index.cpp b/tests/geometry/examples_index.cpp index d84890dc..d80520fb 100644 --- a/tests/geometry/examples_index.cpp +++ b/tests/geometry/examples_index.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/geometry/examples_strategies_io.cpp b/tests/geometry/examples_strategies_io.cpp index 75a92857..e96d2509 100644 --- a/tests/geometry/examples_strategies_io.cpp +++ b/tests/geometry/examples_strategies_io.cpp @@ -17,7 +17,6 @@ // (and mapped_file, whose file outlives a run). // boost_range/uniqued.cpp does not compile upstream (coverage.toml). The examples' SVG helpers are inlined; // they write SVG only under HAVE_SVG, which the cases do not define. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/hash2/api.cpp b/tests/hash2/api.cpp index d0b3ec0a..06d305d4 100644 --- a/tests/hash2/api.cpp +++ b/tests/hash2/api.cpp @@ -3,7 +3,6 @@ // HashAlgorithm requirements over every provided algorithm, update/result // semantics, compile-time hashing, and hash_append over each kind of type. // Described classes are mixed_describe.cpp, user types custom_types.cpp. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include import std; diff --git a/tests/hash2/custom_types.cpp b/tests/hash2/custom_types.cpp index eb0245aa..59778c66 100644 --- a/tests/hash2/custom_types.cpp +++ b/tests/hash2/custom_types.cpp @@ -4,7 +4,6 @@ // the documented requirements and used with hash_append and the result // helpers, a user flavor (byte order and size_type), and a user hash adapter // for unordered containers (examples.adoc#use-with-unordered-containers). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include import std; diff --git a/tests/hash2/examples.cpp b/tests/hash2/examples.cpp index 85831639..baa5b79d 100644 --- a/tests/hash2/examples.cpp +++ b/tests/hash2/examples.cpp @@ -4,7 +4,6 @@ // md5sum and hash2sum (command-line tools) run on two files written to the // temporary directory, named relative to it (the output prints them); json_value hashes a boost::json::value through the // json module and adds its hash_append overload to namespace boost. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/hash2/mixed_describe.cpp b/tests/hash2/mixed_describe.cpp index dcb64b76..f4ca8965 100644 --- a/tests/hash2/mixed_describe.cpp +++ b/tests/hash2/mixed_describe.cpp @@ -3,7 +3,6 @@ // #include (no module carries them), hash_append from the hash2 module, which // hashes a described class member by member and base by base (design §4.4: // includes precede imports). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include import std; diff --git a/tests/json/custom_types.cpp b/tests/json/custom_types.cpp index 5f3b773d..26c56c75 100644 --- a/tests/json/custom_types.cpp +++ b/tests/json/custom_types.cpp @@ -5,7 +5,6 @@ // like and variant-like through the standard ones, conversion contexts // (a user context selecting a representation), and a user memory_resource // behind storage_ptr. Described types are mixed_describe.cpp. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.json; diff --git a/tests/json/doc_background.cpp b/tests/json/doc_background.cpp index 72716561..c04a6a22 100644 --- a/tests/json/doc_background.cpp +++ b/tests/json/doc_background.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.json — libs/json/test/doc_background.cpp, the code the // documentation pages include, unchanged except that its includes are imports // and its test macros come from doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/json/doc_forward_conversion.cpp b/tests/json/doc_forward_conversion.cpp index 99fbe0fa..ddeb484f 100644 --- a/tests/json/doc_forward_conversion.cpp +++ b/tests/json/doc_forward_conversion.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.json — libs/json/test/doc_forward_conversion.cpp, the code the // documentation pages include, unchanged except that its includes are imports // and its test macros come from doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/json/doc_parsing.cpp b/tests/json/doc_parsing.cpp index 8d013c9c..9fc9b51f 100644 --- a/tests/json/doc_parsing.cpp +++ b/tests/json/doc_parsing.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.json — libs/json/test/doc_parsing.cpp, the code the // documentation pages include, unchanged except that its includes are imports // and its test macros come from doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/json/doc_quick_look.cpp b/tests/json/doc_quick_look.cpp index 9d50325a..f6f69b8d 100644 --- a/tests/json/doc_quick_look.cpp +++ b/tests/json/doc_quick_look.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.json — libs/json/test/doc_quick_look.cpp, the code the // documentation pages include, unchanged except that its includes are imports // and its test macros come from doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/json/doc_serializing.cpp b/tests/json/doc_serializing.cpp index d56b1f24..e8ead45d 100644 --- a/tests/json/doc_serializing.cpp +++ b/tests/json/doc_serializing.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.json — libs/json/test/doc_serializing.cpp, the code the // documentation pages include, unchanged except that its includes are imports // and its test macros come from doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/json/doc_snippets.cpp b/tests/json/doc_snippets.cpp index 5e75020c..473cb94e 100644 --- a/tests/json/doc_snippets.cpp +++ b/tests/json/doc_snippets.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.json — libs/json/test/snippets.cpp, the code the // documentation pages include, unchanged except that its includes are imports // and its test macros come from doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/json/doc_storage_ptr.cpp b/tests/json/doc_storage_ptr.cpp index 5e9dc2c6..cd01de09 100644 --- a/tests/json/doc_storage_ptr.cpp +++ b/tests/json/doc_storage_ptr.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.json — libs/json/test/doc_storage_ptr.cpp, the code the // documentation pages include, unchanged except that its includes are imports // and its test macros come from doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/json/doc_uses_allocator.cpp b/tests/json/doc_uses_allocator.cpp index 7148ea6b..24dba4ba 100644 --- a/tests/json/doc_uses_allocator.cpp +++ b/tests/json/doc_uses_allocator.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.json — libs/json/test/doc_uses_allocator.cpp, the code the // documentation pages include, unchanged except that its includes are imports // and its test macros come from doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/json/doc_using_numbers.cpp b/tests/json/doc_using_numbers.cpp index dd8e2f50..6ca24c1a 100644 --- a/tests/json/doc_using_numbers.cpp +++ b/tests/json/doc_using_numbers.cpp @@ -1,7 +1,6 @@ // mcpplibs.mwrap.boost.json — libs/json/test/doc_using_numbers.cpp, the code the // documentation pages include, unchanged except that its includes are imports // and its test macros come from doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/json/examples.cpp b/tests/json/examples.cpp index 2e0f6839..10881c9e 100644 --- a/tests/json/examples.cpp +++ b/tests/json/examples.cpp @@ -7,11 +7,11 @@ // BOOST_JSON_UNREACHABLE() (an internal macro) is std::unreachable(). parse_into_canada and // parse_into_citm_catalog and parse_into are timing benchmarks over data files the release // does not ship (excluded in coverage.toml). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include #include +#include import std; import mcpplibs.mwrap.boost.json; import mcpplibs.mwrap.boost.container; diff --git a/tests/json/mixed_describe.cpp b/tests/json/mixed_describe.cpp index ed863f45..4237f630 100644 --- a/tests/json/mixed_describe.cpp +++ b/tests/json/mixed_describe.cpp @@ -3,7 +3,6 @@ // a described struct. The BOOST_DESCRIBE_* macros come from #include (no // module carries them) and Boost.JSON from its module (design §4.4: the // includes precede the imports). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include import std; diff --git a/tests/math/custom_types.cpp b/tests/math/custom_types.cpp index e491a5ca..8309150c 100644 --- a/tests/math/custom_types.cpp +++ b/tests/math/custom_types.cpp @@ -6,7 +6,6 @@ // precision); user functors for the root finders, the minimiser and the // series / continued-fraction tools; a user distribution-like object with // find_location; and the traits rejecting unsuitable types. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.math; diff --git a/tests/math/doc_distributions.cpp b/tests/math/doc_distributions.cpp index 01d99281..74305e8f 100644 --- a/tests/math/doc_distributions.cpp +++ b/tests/math/doc_distributions.cpp @@ -4,7 +4,6 @@ // with closed forms, complements, and the non-member properties; plus the // tutorial pages (distribution objects, complements, the algorithms that find // parameters, the empirical CDF). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.math; diff --git a/tests/math/doc_numerics.cpp b/tests/math/doc_numerics.cpp index 748c956c..6883a19b 100644 --- a/tests/math/doc_numerics.cpp +++ b/tests/math/doc_numerics.cpp @@ -4,7 +4,6 @@ // polynomials, rational functions, recurrences, minimax, expansions, AGM, // color maps, ...). Each case runs the documented call on a problem with a // known answer. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.math; diff --git a/tests/math/doc_policies.cpp b/tests/math/doc_policies.cpp index be9b93f0..3e389ea8 100644 --- a/tests/math/doc_policies.cpp +++ b/tests/math/doc_policies.cpp @@ -5,7 +5,6 @@ // and performance notes. Policies are passed as arguments and through // make_policy; the BOOST_MATH_*_POLICY macros of a translation unit cannot // reach a module built once (docs/usage.md). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include // BOOST_MATH_DECLARE_SPECIAL_FUNCTIONS #include // BOOST_FLOAT64_C and friends diff --git a/tests/math/doc_sf.cpp b/tests/math/doc_sf.cpp index e86d9827..2668eae2 100644 --- a/tests/math/doc_sf.cpp +++ b/tests/math/doc_sf.cpp @@ -2,7 +2,6 @@ // one case per section, each calling the functions it documents at points // with known values (closed forms, tabulated values from DLMF / A&S) or // through identities between them. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include // math before std: the math module's global fragment and the std module both // define MSVC's ppltasks (), and with std imported first clang merges diff --git a/tests/math/doc_tools.cpp b/tests/math/doc_tools.cpp index 7e7deaaf..13807120 100644 --- a/tests/math/doc_tools.cpp +++ b/tests/math/doc_tools.cpp @@ -3,8 +3,8 @@ // complex-tr1.qbk, quaternions and octonions, condition numbers and norms. // (The C99 / TR1 pages describe extern "C" functions of the compiled // libboost_math_tr1, which the package does not build: coverage.toml, gap.) -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include +#include import std; import mcpplibs.mwrap.boost.math; diff --git a/tests/math/examples_1.cpp b/tests/math/examples_1.cpp index 9ad428ec..0f3d9473 100644 --- a/tests/math/examples_1.cpp +++ b/tests/math/examples_1.cpp @@ -15,7 +15,6 @@ #else #define EX_OUTPUT_PLATFORM 0 #endif -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/math/examples_2.cpp b/tests/math/examples_2.cpp index dee2448b..2df6c568 100644 --- a/tests/math/examples_2.cpp +++ b/tests/math/examples_2.cpp @@ -15,7 +15,6 @@ #else #define EX_OUTPUT_PLATFORM 0 #endif -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include import std; import mcpplibs.mwrap.boost.math; import mcpplibs.mwrap.boost.multiprecision; diff --git a/tests/math/examples_3.cpp b/tests/math/examples_3.cpp index e731f498..3b52526a 100644 --- a/tests/math/examples_3.cpp +++ b/tests/math/examples_3.cpp @@ -15,7 +15,6 @@ #else #define EX_OUTPUT_PLATFORM 0 #endif -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/math/examples_4.cpp b/tests/math/examples_4.cpp index 51ea1a9c..9b679571 100644 --- a/tests/math/examples_4.cpp +++ b/tests/math/examples_4.cpp @@ -15,7 +15,6 @@ #else #define EX_OUTPUT_PLATFORM 0 #endif -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/mqtt5/custom_types.cpp b/tests/mqtt5/custom_types.cpp index f2b05949..0ebe007c 100644 --- a/tests/mqtt5/custom_types.cpp +++ b/tests/mqtt5/custom_types.cpp @@ -5,7 +5,6 @@ // authenticator for enhanced authentication (async_auth and method), all // against the in-process broker of broker.hpp; the traits rejecting types // without the hooks. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.asio; diff --git a/tests/mqtt5/doc.cpp b/tests/mqtt5/doc.cpp index fb59828f..16355723 100644 --- a/tests/mqtt5/doc.cpp +++ b/tests/mqtt5/doc.cpp @@ -4,7 +4,6 @@ // client, per-operation cancellation and executors. "" is // the in-process broker of broker.hpp on a free port; the pages' std::cout // output goes to a string the cases compare. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.asio; diff --git a/tests/mqtt5/examples.cpp b/tests/mqtt5/examples.cpp index c087a1f3..083ca6bb 100644 --- a/tests/mqtt5/examples.cpp +++ b/tests/mqtt5/examples.cpp @@ -7,7 +7,6 @@ // differs between platforms); the programs that run until SIGINT stop as on // SIGINT (their signal_set is cancelled) after their first message // (receiver, publisher) or their fifth completion (multiflight_client). The TLS examples need OpenSSL and are excluded. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include @@ -15,6 +14,8 @@ #include #include #include +#include +#include import std; import mcpplibs.mwrap.boost.asio; import mcpplibs.mwrap.boost.beast; diff --git a/tests/regex/api.cpp b/tests/regex/api.cpp index d6b680b7..54a55de8 100644 --- a/tests/regex/api.cpp +++ b/tests/regex/api.cpp @@ -4,7 +4,6 @@ // features, the POSIX basic / extended syntax options, the error_type codes, // the Unicode iterators, and the "C++20 module" page (upstream's // `import boost.regex;`, here this package's module). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.regex; diff --git a/tests/regex/custom_types.cpp b/tests/regex/custom_types.cpp index 6acc34d4..f807fdf5 100644 --- a/tests/regex/custom_types.cpp +++ b/tests/regex/custom_types.cpp @@ -3,7 +3,6 @@ // boost::regex_traits, searches over user iterator types (a deque, a user // bidirectional container), a match_results with a user allocator, a user // formatter functor for regex_replace, and a user callback for regex_grep. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.regex; diff --git a/tests/regex/examples.cpp b/tests/regex/examples.cpp index 6929ef19..f9246b36 100644 --- a/tests/regex/examples.cpp +++ b/tests/regex/examples.cpp @@ -11,7 +11,6 @@ // excluded); icu_example and mfc_example need ICU and MFC, captures_example a // regex library built with BOOST_REGEX_MATCH_EXTRA, regex_grep_example_4 // Borland's __closure (all excluded in coverage.toml). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/regex/examples_grep.cpp b/tests/regex/examples_grep.cpp index 74465a95..12714f2a 100644 --- a/tests/regex/examples_grep.cpp +++ b/tests/regex/examples_grep.cpp @@ -3,7 +3,6 @@ // with -n -i "class|line" and with -c -E: its output must equal what the same // code printed when built from upstream/boost headers alone. The file path is // the program's own printing of its input, so the cases print it too. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/regex/posix_api.cpp b/tests/regex/posix_api.cpp index 89f8e50d..6733c2c1 100644 --- a/tests/regex/posix_api.cpp +++ b/tests/regex/posix_api.cpp @@ -4,7 +4,6 @@ // a consumer includes for them, as here; the functions are // the ones the package compiles (libs/regex/src/posix_api.cpp) and the // module's C++ API is imported alongside. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include import std; diff --git a/tests/test/custom_types.cpp b/tests/test/custom_types.cpp index f7d4b50b..6590002c 100644 --- a/tests/test/custom_types.cpp +++ b/tests/test/custom_types.cpp @@ -11,6 +11,9 @@ int main() { return 0; } #else #define BOOST_TEST_MODULE boost_test_custom_types #include +// The header defines main; mcpp reads this file's text for a main of its own, +// and a test with none begins at the doctest adapter's entry (test-main). +int main(int argc, char* argv[]); #include #include #include diff --git a/tests/test/included/doc_reference.cpp b/tests/test/included/doc_reference.cpp index 49bb4a9c..93bc1d8f 100644 --- a/tests/test/included/doc_reference.cpp +++ b/tests/test/included/doc_reference.cpp @@ -13,6 +13,9 @@ int main() { return 0; } #else #define BOOST_TEST_MODULE boost_test_doc_reference #include +// The header defines main; mcpp reads this file's text for a main of its own, +// and a test with none begins at the doctest adapter's entry (test-main). +int main(int argc, char* argv[]); #include #include #include diff --git a/tests/test/included/smoke.cpp b/tests/test/included/smoke.cpp index 100c63ed..92a01b7f 100644 --- a/tests/test/included/smoke.cpp +++ b/tests/test/included/smoke.cpp @@ -19,6 +19,9 @@ int main() { return 0; } #define BOOST_TEST_MODULE boost_test_included_smoke #include +// The header defines main; mcpp reads this file's text for a main of its own, +// and a test with none begins at the doctest adapter's entry (test-main). +int main(int argc, char* argv[]); BOOST_AUTO_TEST_CASE(included_arithmetic) { BOOST_TEST(2 + 2 == 4); diff --git a/tests/unordered/api.cpp b/tests/unordered/api.cpp index e6f299e0..d71660a4 100644 --- a/tests/unordered/api.cpp +++ b/tests/unordered/api.cpp @@ -4,7 +4,6 @@ // reserve/rehash, piecewise emplacement, the concurrent containers' // visitation API, bulk visitation and interoperability with the // non-concurrent containers, and erase_if / merge / extract. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.unordered; diff --git a/tests/unordered/custom_types.cpp b/tests/unordered/custom_types.cpp index 0f3bbe77..086c179e 100644 --- a/tests/unordered/custom_types.cpp +++ b/tests/unordered/custom_types.cpp @@ -4,7 +4,6 @@ // is_avalanching, transparent user hashers for heterogeneous lookup, a user // allocator, and move-only / non-default-constructible mapped types; the // node and concurrent containers holding user types. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.unordered; diff --git a/tests/unordered/examples.cpp b/tests/unordered/examples.cpp index c072eaf9..1dea1535 100644 --- a/tests/unordered/examples.cpp +++ b/tests/unordered/examples.cpp @@ -4,7 +4,6 @@ // boost::algorithm::iequals) is copied into the case namespace, and its // BOOST_TEST checks are doctest CHECKs (the same conditions); both keep the // TU on imports only. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.unordered; diff --git a/tests/unordered/include_stats.cpp b/tests/unordered/include_stats.cpp index b219e371..0c688adc 100644 --- a/tests/unordered/include_stats.cpp +++ b/tests/unordered/include_stats.cpp @@ -3,7 +3,6 @@ // needs BOOST_UNORDERED_ENABLE_STATS defined before the headers, which changes // the containers' layout; the module is built without it, so this TU uses the // headers alone (and does not import). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #define BOOST_UNORDERED_ENABLE_STATS #include diff --git a/tests/url/custom_types.cpp b/tests/url/custom_types.cpp index 1c5537ca..9a5d5962 100644 --- a/tests/url/custom_types.cpp +++ b/tests/url/custom_types.cpp @@ -5,7 +5,6 @@ // (CharSet concept), a user StringToken for decoding into a user buffer, and // url_view / url used as members of user types. The grammar index page's // `using namespace boost::urls::grammar;` is how this file names the grammar. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.url; diff --git a/tests/url/doc_doc_3_urls.cpp b/tests/url/doc_doc_3_urls.cpp index 36273463..85bcbb4e 100644 --- a/tests/url/doc_doc_3_urls.cpp +++ b/tests/url/doc_doc_3_urls.cpp @@ -2,7 +2,6 @@ // the documentation's own code (the snippets the pages quote), unchanged // except that its includes are imports and its test macros come from // doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/url/doc_doc_grammar.cpp b/tests/url/doc_doc_grammar.cpp index 2b0597e1..434d42b8 100644 --- a/tests/url/doc_doc_grammar.cpp +++ b/tests/url/doc_doc_grammar.cpp @@ -2,7 +2,6 @@ // the documentation's own code (the snippets the pages quote), unchanged // except that its includes are imports and its test macros come from // doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/url/doc_snippets.cpp b/tests/url/doc_snippets.cpp index eae3cca1..87c77d29 100644 --- a/tests/url/doc_snippets.cpp +++ b/tests/url/doc_snippets.cpp @@ -2,7 +2,6 @@ // the documentation's own code (the snippets the pages quote), unchanged // except that its includes are imports and its test macros come from // doc_test_suite.hpp (doctest). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include "doc_test_suite.hpp" #include diff --git a/tests/url/examples.cpp b/tests/url/examples.cpp index 6f80bb45..12f18632 100644 --- a/tests/url/examples.cpp +++ b/tests/url/examples.cpp @@ -7,7 +7,6 @@ // the temporary directory; the examples' own headers are inlined; finicky's CHECK macro is EX_CHECK here (doctest's // CHECK). router and file_router are beast HTTP servers (excluded in // coverage.toml). -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include #include #include diff --git a/tests/uuid/api.cpp b/tests/uuid/api.cpp index a355315a..0640b7e6 100644 --- a/tests/uuid/api.cpp +++ b/tests/uuid/api.cpp @@ -4,7 +4,6 @@ // serialization), the generators (nil, string, name md5/sha1, random, // basic_random, time v1/v6/v7), uuid_clock, namespaces, constants and the I/O // functions. Cases are "doc: #
". -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.uuid; diff --git a/tests/uuid/custom_types.cpp b/tests/uuid/custom_types.cpp index 338a0a05..a69321be 100644 --- a/tests/uuid/custom_types.cpp +++ b/tests/uuid/custom_types.cpp @@ -3,7 +3,6 @@ // namespace UUID for the name generators, uuids as keys in user containers // and members of user types (with hashing), time_generator_v1 over a user // node id and a shared std::atomic state, and to_chars into a user buffer. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.uuid; diff --git a/tests/variant2/api.cpp b/tests/variant2/api.cpp index 7bc27715..cea68cf1 100644 --- a/tests/variant2/api.cpp +++ b/tests/variant2/api.cpp @@ -2,7 +2,6 @@ // (in_place_type / in_place_index), emplace, swap, relational operators, // get / get_if / unsafe_get / holds_alternative, visit, visit_by_index, // variant_size / variant_alternative, subset<>(), operator<< and hashing. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.variant2; diff --git a/tests/variant2/custom_types.cpp b/tests/variant2/custom_types.cpp index d71d9fce..7406bb8b 100644 --- a/tests/variant2/custom_types.cpp +++ b/tests/variant2/custom_types.cpp @@ -4,7 +4,6 @@ // place, user visitors (overload sets, visitors with state, multi-variant // visits), user ordering/streaming/hashing used by the variant's own // operators, and recursive data through an indirection. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.variant2; diff --git a/tests/variant2/examples.cpp b/tests/variant2/examples.cpp index f07478ef..be60a357 100644 --- a/tests/variant2/examples.cpp +++ b/tests/variant2/examples.cpp @@ -1,6 +1,5 @@ // mcpplibs.mwrap.boost.variant2 — the overview examples of Boost.Variant2 // (libs/variant2/doc/variant2/overview.adoc) as test cases. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.variant2; diff --git a/tools/ci/test_coverage.py b/tools/ci/test_coverage.py index 1e22b449..9040ba3c 100644 --- a/tools/ci/test_coverage.py +++ b/tools/ci/test_coverage.py @@ -43,6 +43,10 @@ -- --list_content -- --list-test-cases > listing.ndjson python3 tools/ci/test_coverage.py check --listing listing.ndjson +A doctest program speaks the mtest protocol (mcpplibs.mtest.doctest): it +reports what it lists to mcpp, whose record of it holds the cases (``listed``); +the others print their listing (``run_output``). + An entry whose test is in no listing is reported as not verified: CI lists the root tests on a leg without the unit-test-framework feature (with it, the tests/test/included programs are stubs) and tests/dll on a leg that has it. @@ -409,6 +413,11 @@ def program_cases(output): heads = (l.split(": ", 1)[0] for l in lines) names = {h.strip()[:-1] for h in heads if h.endswith("*") and h.strip() != "*"} | {"program"} + return with_templates(names) + + +def with_templates(names): + """`names` and the case each template instance (`name`) is of.""" return names | {n.partition("<")[0] for n in names if n.endswith(">") and n.partition("<")[0]} @@ -444,6 +453,12 @@ def listing_cases(paths): raise SystemExit("{}: member {!r} is not a workspace member under " "tests/".format(path, member)) test = (dirs[member] + "/" if member else "") + record["test"] + if "listed" in record: + # A test-protocol program (doctest through mcpplibs.mtest.doctest) + # reports the cases it lists to mcpp, not to its output. + found[test] = (found.get(test) or set()) | with_templates( + {case["name"] for case in record["listed"]}) + continue if record["status"] not in ("pass", "run_fail"): found.setdefault(test, None) continue diff --git a/tools/port_tests/libs/callable_traits.py b/tools/port_tests/libs/callable_traits.py index 9caf170c..5e4ffe04 100644 --- a/tools/port_tests/libs/callable_traits.py +++ b/tools/port_tests/libs/callable_traits.py @@ -45,7 +45,6 @@ def unifdef(lines): // and transaction_safe (GCC's -fgnu-tm) is off: the three *_transaction_safe // examples compile to an empty main upstream then, and are excluded in // coverage.toml. -#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include import std; import mcpplibs.mwrap.boost.callable_traits; diff --git a/tools/port_tests/port_examples.py b/tools/port_tests/port_examples.py index 650ed28f..c5b93ff9 100755 --- a/tools/port_tests/port_examples.py +++ b/tools/port_tests/port_examples.py @@ -28,6 +28,26 @@ ROOT = common.ROOT INC = common.INC KEEP_STD = {"cassert", "cstdio", "cstdlib", "cmath", "cstdarg", "climits", "cfloat", "cstddef", "cerrno", "csignal"} +# What a port uses from a C header that `import std` does not give: its macros +# (SIGINT, errno, INT_MAX, FP_ZERO) and its names in the global namespace +# (::sin, ::uint16_t). The example had them from a Boost header the port +# removes; the header is added when no header the port keeps is it. (Until +# 2026-11-21 doctest's implementation, compiled in each test file, supplied +# them; the mtest doctest adapter compiles it once, outside the file.) +C_NAMES = [ + ("csignal", r"\bSIG(INT|TERM|HUP|QUIT|ABRT|SEGV|ILL|FPE|USR1|USR2|PIPE|CHLD|ALRM)\b|(?])signal\s*\("), + ("cerrno", r"\berrno\b"), + ("climits", r"\b(U?INT|U?LONG|U?LLONG|U?SHRT|S?CHAR|UCHAR)_(MAX|MIN)\b|\bCHAR_BIT\b"), + ("cmath", r"\bFP_(ZERO|NAN|INFINITE|NORMAL|SUBNORMAL)\b|\bHUGE_VAL[FL]?\b|" + r"(?])(sin|cos|tan|asin|acos|atan|atan2|sqrt|cbrt|floor|ceil|fabs|pow|exp|log|log10|fmod|round|trunc|hypot)\s*\("), + ("cstdint", r"(?` lines of C_NAMES the cases need and `kept` lacks.""" + return ["#include <%s>" % h for h, pat in C_NAMES + if "#include <%s>" % h not in kept and re.search(pat, cases_text)] ORACLE_PARTS = {} @@ -582,8 +602,9 @@ def main(): else: repl.append(k) kept_all = repl - head = args.header + """#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN -#include + if not (args.pure or args.std_includes): + kept_all += c_headers_used("\n".join(cases), kept_all) + head = args.header + """#include %s %s%s // Output of the ported examples is captured here; each case compares it with From eca52932ea2643b679780a92175ff8d0ef658bbe Mon Sep 17 00:00:00 2001 From: Zhe Feng Date: Sat, 21 Nov 2026 13:08:10 +0000 Subject: [PATCH 2/2] docs(agents): record the move of the doctest tests onto mcpplibs.mtest.doctest --- ...2026-11-21-mtest-doctest-adapter-design.md | 132 ++++++++++++++++++ .agents/docs/README.md | 5 +- 2 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 .agents/docs/2026-11-21-mtest-doctest-adapter-design.md diff --git a/.agents/docs/2026-11-21-mtest-doctest-adapter-design.md b/.agents/docs/2026-11-21-mtest-doctest-adapter-design.md new file mode 100644 index 00000000..91cf004c --- /dev/null +++ b/.agents/docs/2026-11-21-mtest-doctest-adapter-design.md @@ -0,0 +1,132 @@ +--- +subject: tests +status: active +--- + +# doctest 测试接入 mtest 协议:改用上游适配器 `mcpplibs.mtest.doctest` + +> 日期:2026-11-21 · mcpp 2026.11.20.1 · mtest 0.11.1 · doctest 2.4.12 +> +> 来源:[mcpplibs/boost-m#7](https://github.com/mcpplibs/boost-m/issues/7) 的调查与计划; +> mcpp `docs/specs/test.md`(SPEC-017)B6;mtest 0.11.0(mcpp-community/mtest#26)。 + +## 0. 结论 + +#7 计划的第一项"写 doctest 适配器入口包"由上游完成:mtest 0.11.0 发布了 +`mcpplibs.mtest.doctest`(L1)。它是入口包(`test-protocol = 1`、`test-main = true`), +doctest 的实现和 `main` 只在包里编译一次,依赖只有 `compat.doctest` 2.4.12 与 +`nlohmann.json`,不经过 mtest 库、`mcpplibs.os` 与 openkal。 + +本仓库直接使用它,不再自写适配器:根包与 `tests/dll` 的 `[dev-dependencies]` 加上 +`mcpplibs.mtest.doctest = "0.11.1"`,删去全部 139 处 `DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN` +(含两个移植生成器的模板)。本地(Linux x86_64,gcc 16.1.0)根包 417 个测试程序与 +`tests/dll` 的 4 个全部通过;llvm@22.1.8 抽查 6 个受影响最大的文件通过。 + +[2026-11-09 设计记录](2026-11-09-module-test-hardening-design.md) §4.1 中"每个测试文件 +自己定义 `main`"的约定由本记录取代:测试文件只 `#include `,不定义 +`DOCTEST_CONFIG_IMPLEMENT*`。 + +## 1. 只能一次全部迁移 + +mcpp 对待入口包的方式决定了不能逐库试点: + +- 适配器包的库源 `src/protocol.cpp`(doctest 实现 + reporter)链接进根包的**每个**测试 + 程序,包括冒烟测试与 Boost.Test 测试。仍保留 `IMPLEMENT_WITH_MAIN` 的文件因此重复 + 定义 doctest 的全部符号。 +- 入口 `src/main.cpp` 链接进"不定义 `main`"的测试。mcpp 判断这一点靠扫描源文件的 + **文本**(`plan.cppm` 的 `source_defines_main`:去掉注释与字面量,按预处理条件取舍, + 找 `int main(` / `auto main(`)。由宏或头文件给出 `main` 的文件被判为没有 `main`。 + +后者涉及 4 个文件:`tests/cobalt/co_main.cpp`(`main` 在 ``)与 +Boost.Test 头文件形态的 `tests/test/custom_types.cpp`、`tests/test/included/{smoke,doc_reference}.cpp` +(`main` 在 ``;`#ifdef MCPP_FEATURE_UNIT_TEST_FRAMEWORK` +分支里的 `int main()` 被扫描当作不编译)。处理:在文件中写出与头文件相同的声明 +`int main(int argc, char* argv[]);`(cobalt 的 `detail/main.hpp:31` 就有同一声明), +Boost.Test 文件写在 `#else` 分支里。 + +非 doctest 程序链接了 `protocol.o`,但 Linux 上 `--gc-sections` 去掉了其中的 +`mtest-protocol=1` 标记(实测 `accumulators`、`asio/smoke`、`test/included/smoke`、 +`cobalt/co_main` 中均无)。mcpp 判断协议程序看的是入口声明,不看标记,记录中这些程序的 +`protocol` 为 `null`。 + +## 2. doctest 实现曾替测试提供的 C 头文件 + +`DOCTEST_CONFIG_IMPLEMENT` 让 doctest.h 包含 ``、``、``、 +``、`` 等。移植的上游示例原本经由 Boost 头文件得到它们,移植时 Boost +头文件被模块取代,于是一直靠 doctest 实现兜底。删去实现后 11 个文件编译失败: + +| 缺少 | 文件 | +|---|---| +| `SIGINT`、`SIGTERM`、`signal` | asio/network_cpp14_cpp20、asio/network_http、beast/examples_websocket、math/examples_2、mqtt5/examples | +| `errno` | json/examples | +| `INT_MAX`、`INT_MIN` | convert/examples_stream(手写) | +| `FP_ZERO` | decimal/api_cmath_io、math/doc_tools(手写) | +| `::sin`、`::cos`、`::floor` | geometry/examples、geometry/examples_algorithms | +| `::uint16_t` | mqtt5/examples | + +这些是宏或全局命名空间中的 C 名字,`import std` 不提供。`tools/port_tests/port_examples.py` +新增 `C_NAMES`:`import std` 形态的移植在用例中用到这些名字、而保留的头文件里没有对应头时, +补上 `#include`。已提交的生成文件按同一规则补齐(另有 `asio/network_cpp11` 多得一个 +``,无害);`regen.py` 需要发布包与 oracle 构建,本轮未重跑。手写的 3 个文件直接补 +`#include`。 + +## 3. GCC 16:`npos` 的强定义 + +`asio/custom_types` 与 `geometry/api_reference` 链接时 `std::string::npos` 重复定义,另一方是 +`libstdc++.a(string-inst.o)`。这两个翻译单元只 `import std`,`CHECK(s.find(..) != std::string::npos)` +经 doctest 的表达式分解按 `const&` 绑定 `npos`(ODR 使用),GCC 16 为它发出了不在 COMDAT 组 +中的 `GLOBAL` 定义(`basic_string` 有显式实例化声明,本不应发出)。以前没有其他目标 +文件需要 `string-inst.o`;`protocol.o` 需要,静态 libstdc++ 于是把它拉进来。在文件中文本包含 +`` 无效。处理:改写为 `s.contains(..)`(C++23),不再 ODR 使用 `npos`。仓库中另有 +14 处同类写法,它们的目标文件没有强定义,未改。 + +## 4. 覆盖率核对 + +`tools/ci/test_coverage.py check --listing` 原先从程序输出(`run_output`)解析 doctest 的 +`--list-test-cases`。在 mcpp 之下,适配器把 reporter 换成自己的,doctest 列表模式调用它的 +`report_query`,用例作为协议的 `case` 事件交给 mcpp,进入记录的 `listed` 字段,输出为空。 +`listing_cases` 改为优先读 `listed`(`name` 即 doctest 的用例名,模板实例同样补出模板名)。 +CI 的命令不变。对照:旧脚本读新的列表报 1791 处"程序未列出该用例",新脚本通过。 + +## 5. 实测 + +**编译时间**(gcc 16.1.0,dev,单线程,同一条编译命令加与不加 +`-DDOCTEST_CONFIG_IMPLEMENT_WITH_MAIN`): + +| 文件 | 现在 | 原先 | 节省 | +|---|---:|---:|---:| +| algorithm/api_string | 2.32 s | 3.75 s | 1.44 s | +| json/custom_types | 1.65 s | 3.02 s | 1.37 s | +| math/doc_sf | 4.58 s | 6.11 s | 1.53 s | +| asio/api_overview | 9.00 s | 10.57 s | 1.57 s | +| geometry/api_reference | 17.13 s | 18.49 s | 1.35 s | +| core/api | 1.17 s | 2.60 s | 1.43 s | +| beast/doc | 10.70 s | 12.79 s | 2.09 s | +| container/api | 3.17 s | 4.75 s | 1.59 s | + +平均每个文件 1.55 s,与 #7 §3 的估计一致;139 个文件约 3.6 分钟 CPU 时间每条 gcc 腿。 + +**协议**(临时探测程序,未提交):`--cases` 列出用例与位置;`--case` 逐字节选择,含 `*` 与 +逗号的名字也正确;失败带文件与行;`--failed` 只重跑失败的用例;用例中 `raise(SIGSEGV)` +时整体运行报到该用例,`--split case` 下其余用例照常运行;`doctest::skip()` 报为跳过, +`may_fail` 通过。asio 已有的 `ex_case_names` 看门狗 listener 与适配器共存。全量运行得到 +136 个协议程序、1815 个用例记录。 + +#7 提到的"`--cases` 把 L0 程序报成失败"在 mcpp 2026.11.20.1 中不再出现(报为 +"one case, its exit status")。 + +## 6. 尚未验证 + +- windows llvm-msvc 与 arm64 musl 腿:本轮以 CI 为准。Windows 上 lld-link 是否同样去掉 + 非 doctest 程序中的协议标记也待 CI 观察(不影响 mcpp,只影响独立运行的 mtest 引擎)。 +- `regen.py` 重新生成与已提交文件逐字节一致(§2)。 + +## 7. 上游适配器的缺口(向 mcpp-community/mtest 反馈) + +- 同名用例得到相同 ID(P3.2 要求确定的去重):`--case duplicate` 运行两个,`--split case` + 合成一个进程。 +- 读取后未从环境中清除 `MTEST_*`(P2.2),子进程会继承。 +- P3.3 调度提示只映射了 `skip`;`timeout`、`may_fail`、`should_fail`、`expected_failures` 未映射。 +- 异常与崩溃的 `failure` 事件 `file` 为空、`line` 为 0。 +- 程序在 mcpp 之外运行且设置了 `MTEST_PROTOCOL` 时,doctest 的 `--list-test-cases` 不再打印到 + 标准输出(本仓库已改为读 `listed`,记此备查)。 diff --git a/.agents/docs/README.md b/.agents/docs/README.md index 8932950e..5eafcc7b 100644 --- a/.agents/docs/README.md +++ b/.agents/docs/README.md @@ -27,11 +27,12 @@ - `todos/` 放尚未完成的工作项,它们不是决定的记录。 - 移动或改名用 `tools/doc-tools/move_record.py`,它同时改写仓库中对该文件的引用。 -共 28 篇记录(其中 0 篇已归档),1 项待办。 +共 29 篇记录(其中 0 篇已归档),1 项待办。 ## 进行中 - [PR #5 第二轮评审的 [nit] 修复:覆盖率按测试程序列出的用例核对](2026-11-21-pr5-review-nits-design.md) — active +- [doctest 测试接入 mtest 协议:改用上游适配器 `mcpplibs.mtest.doctest`](2026-11-21-mtest-doctest-adapter-design.md) — active - [子工程复用根工程的构建产物,mcpp 升级到 2026.11.20.1](2026-11-20-sub-project-build-reuse-design.md) — active - [模块测试加固的发现复盘:封装层缺陷与上游 Boost 问题(对照 1.93.0.beta1)](2026-11-12-module-tests-findings-and-upstream-bugs-analysis.md) — active @@ -46,6 +47,7 @@ ### tests - [PR #5 第二轮评审的 [nit] 修复:覆盖率按测试程序列出的用例核对](2026-11-21-pr5-review-nits-design.md) — active +- [doctest 测试接入 mtest 协议:改用上游适配器 `mcpplibs.mtest.doctest`](2026-11-21-mtest-doctest-adapter-design.md) — active - [子工程复用根工程的构建产物,mcpp 升级到 2026.11.20.1](2026-11-20-sub-project-build-reuse-design.md) — active - [windows-llvm-msvc 上的进程崩溃:两个 clang 模块缺陷](2026-11-18-windows-msvc-module-crashes-analysis.md) — landed - [示例移植脚本进入 `tools/port_tests/`:升级 Boost 时重跑上游测试的移植](2026-11-18-port-tests-tools-design.md) — landed @@ -61,6 +63,7 @@ ### 2026-11 - [PR #5 第二轮评审的 [nit] 修复:覆盖率按测试程序列出的用例核对](2026-11-21-pr5-review-nits-design.md) — active +- [doctest 测试接入 mtest 协议:改用上游适配器 `mcpplibs.mtest.doctest`](2026-11-21-mtest-doctest-adapter-design.md) — active - [子工程复用根工程的构建产物,mcpp 升级到 2026.11.20.1](2026-11-20-sub-project-build-reuse-design.md) — active - [windows-llvm-msvc 上的进程崩溃:两个 clang 模块缺陷](2026-11-18-windows-msvc-module-crashes-analysis.md) — landed - [示例移植脚本进入 `tools/port_tests/`:升级 Boost 时重跑上游测试的移植](2026-11-18-port-tests-tools-design.md) — landed