Repository navigation
tests: doctest programs speak the mtest protocol (mcpplibs.mtest.doctest) - #8
Open
ZheFeng7110 wants to merge 2 commits into
Open
ZheFeng7110 wants to merge 2 commits into
ZheFeng7110 wants to merge 2 commits into
Conversation
…est) 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 (mcpplibs#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 <csignal>, <cerrno>, <climits>, <cmath> and <cstdint>; 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the first items of #7. Upstream mtest 0.11.0 shipped
mcpplibs.mtest.doctest, a level-1 adapter that is an entry package (test-protocol = 1,test-main = true). This PR uses it instead of a local adapter. Design record:.agents/docs/2026-11-21-mtest-doctest-adapter-design.md.Changes
tests/dlltakemcpplibs.mtest.doctest = "0.11.1"as a dev-dependency. It depends only oncompat.doctest2.4.12 andnlohmann.json, not on the mtest library,mcpplibs.osor openkal.DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN. doctest's implementation andmainare compiled once, in the adapter package.mcpp test --cases,--case <id>,--failed,--split caseand--message-format jsonnow work on individual doctest cases. Case IDs are<suite>/<name>, or<name>outside a suite.What had to change for that
mcpp links the adapter into every test, and links its
maininto every test whose source text defines nomain. So the migration has to be done for all files at once, and:cobalt/co_main.cpp,test/custom_types.cpp,test/included/{smoke,doc_reference}.cppgetmainfrom a header. mcpp's text scan does not see it, so the entry'smainis a second definitionint main(int argc, char* argv[]);as the header doesSIGINT,errno,INT_MAX,FP_ZERO,::sin,::uint16_t, which only doctest's implementation had been includingport_examples.pyadds the C header a case uses (C_NAMES); the generated files have it; three hand-written files include itasio/custom_types,geometry/api_reference: with GCC 16,CHECK(s.find(..) != std::string::npos)in a TU that onlyimport stds emitsnposas a strong symbol, which now conflicts withlibstdc++.a(string-inst.o)s.contains(..)--list-test-casesto mcpp (the record'slisted), not to its outputtest_coverage.pyreadslisted. The CI command is unchangedLocal results (Linux x86_64)
tests/dllprograms pass.test_coverage.py checkpasses. With the old script, the new listing reports 1791 missing cases.json/custom_types,asio/custom_types,geometry/api_reference,cobalt/co_main,test/custom_types,math/examples_2); all pass.--casematches names containing*and,exactly;--failedreruns only the failed cases;SIGSEGVis reported against its case, and with--split casethe other cases still run;doctest::skip()is reported as skipped;ex_case_nameswatchdog listener still works alongside the adapter.Not yet verified
regen.pyoutput: the generated files were patched with the same rule as the generator, not regenerated (that needs the release archive and the oracle build).Gaps in the upstream adapter (duplicate case IDs,
MTEST_*not cleared, onlyskipmapped of the P3.3 hints, exception failures located at:0) are listed in the design record §7 and will be reported to mcpp-community/mtest.