Skip to content

[BUILD,INTERNAL] Move the class-test framework into its own library (OpenMSTestFramework) - #9919

Closed
timosachsenberg wants to merge 17 commits into
developfrom
claude/openms-test-framework-refactor-ssutqy
Closed

timosachsenberg wants to merge 17 commits into
developfrom
claude/openms-test-framework-refactor-ssutqy

Conversation

@timosachsenberg

@timosachsenberg timosachsenberg commented Aug 14, 2026 •

Copy link
Copy Markdown
Contributor

Description

Extracts the class-test framework from libOpenMS into a standalone static library, as prework for splitting libOpenMS into smaller libraries. Today every test of every library — including OpenSwathAlgo's — has to link all of libOpenMS just to get the TEST_* macros; after this change the framework stands on its own.

No test file changes are required by the move: the headers keep their install paths, so #include <OpenMS/CONCEPT/ClassTest.h> works unchanged in all ~720 tests.

The removal of tools/checker.php, cpplint and ENABLE_STYLE_TESTING was split out into #9923 — it was incidental cleanup and accounted for 8,777 of this PR's deletions. The two are independent and can merge in either order (they touch src/tests/coding/createcpplinttests.cmake and the CHANGELOG in common, resolvable trivially).

What moves

ClassTest.h/.cpp, FuzzyStringComparator.h/.cpp and MacrosTest.h move to src/testframework/ and are built as the static library OpenMSTestFramework (git mv, so history follows).

Static is deliberate: the framework is per-executable global state, so there is nothing to share between processes, no new runtime artifact ships, and no OPENMS_DLLAPI decorations are needed. Its ~55 symbols are consequently no longer exported from libOpenMS.

Breaking the dependency on the upper layers

The framework previously called into the FORMAT layer — a CONCEPT component depending on FORMAT, which is backwards, and the reason it could not be separated. Two pieces of behavior were involved:

behavior now
XML schema validation of NEW_TMP_FILE output at END_TEST header-only helper <OpenMS/TestFileValidation.h> in the class-test project; tests call VALIDATE_TMP_FILES (or VALIDATE_FILE(f)) explicitly
UniqueIdGenerator seeding at START_TEST called directly — UniqueIdGenerator is CONCEPT level, the same layer the framework already uses for StringUtils/Exception

The result has no callbacks and no support library. OpenMSTestFramework's only external symbols are ten from libOpenMS's CONCEPT/DATASTRUCTURES layers (Exception, StringUtils, UniqueIdGenerator) and it needs no third-party headers at all — so when libOpenMS is split, its dependency simply becomes the future core library.

Which tests need the explicit validation call was determined by measurement, not inspection: all 57 tests combining NEW_TMP_FILE with a validatable format were built and run against the previous automatic-validation build to record what each actually validated. 26 validate files and got the call; the other 31 produce nothing validatable. Each of the 26 validates exactly the same files as before — note that files whose type has no schema validator (e.g. pepXML) were skipped before this PR too, and still are.

Note this makes validation opt-in: a new test that writes an XML file is not schema-checked unless its author adds VALIDATE_TMP_FILES. The macro documents when to use it.

Link requirements

Class-test executables link OpenMSTestFramework, then libOpenMS, then (for the Arrow tests) the static Arrow/Parquet archives. Two distinct requirements are involved, and they are handled differently:

1. libOpenMS must survive --as-needed. The framework archive references Exception/StringUtils/UniqueIdGenerator, but a test whose own object references nothing from libOpenMS (e.g. RAIICleanup_test) would let the linker drop it. This used to depend on the order of target_link_libraries arguments, protected only by a comment. It is now stated outright with a user-defined link feature (cmake/compiler_flags.cmake):

target_link_libraries(mytest OpenMSTestFramework "$<LINK_LIBRARY:needed,OpenMS>")

which wraps just libOpenMS in --push-state,--no-as-needed,…,--pop-state. Verified by reversing the arguments so libOpenMS comes first: it still links and still records libOpenMS.so as DT_NEEDED, whereas the same reversed order without the feature fails on exactly those undefined references. On Apple and Windows, which have no --as-needed, the feature passes the library through unchanged.

For the GUI tests, OpenMS_GUI links OpenMS publicly, so OpenMS also arrives transitively without a feature — which CMake rejects as a conflict. LINK_LIBRARY_OVERRIDE_OpenMS settles the feature for every path by which OpenMS reaches the target.

This is why the CMake minimum moves from 3.21 to 3.24, the first release with $<LINK_LIBRARY:...> and user-defined link features. The Windows installation instructions and AGENTS.md already stated 3.24, so this only makes cmake_minimum_required agree with them; Ubuntu 24.04 LTS ships 3.28.

2. libOpenMS must precede the static Arrow/Parquet archives, or the linker resolves the Arrow symbols from those archives and pulls their objects — including Thrift's static enum tables — into each test binary, inflating it ~24× and duplicating static objects that libOpenMS already owns. Those duplicates were then destroyed twice at process exit, corrupting the heap. This one is still positional (appending keeps it true) and remains documented at the call site.

openms_hide_static_archive_symbols() (--exclude-libs,ALL, GNU ld/lld only) additionally keeps static-archive symbols out of test executables' dynamic tables, so duplicated statics cannot be interposed even if something is pulled in later.

Also included

  • FuzzyDiff links the framework (it wraps FuzzyStringComparator); the ~1600 TOPP tests that use it are unaffected.
  • AGENTS.md's style-check instructions pointed at a test_style build target that does not exist in the build system.

Testing

Green on all five CI platforms (ubuntu g++/clang++, ubuntu-arm g++, macOS, Windows) with the full suite, plus all four wheel builds and the 20 wheel-install jobs. build-sphinx is red on this and every other open PR: ruff-action installs an unpinned latest ruff that flags files under doc/pyopenms/, which this branch does not touch.

Locally verified in a clang Release build with static Arrow (the CI configuration): ConsensusMapArrowExport_test is 890,872 bytes with 0 Thrift symbols, against 19.5 MB and 504 when the link order is wrong. The 26 validating tests, the OpenSwathAlgo tests, RAIICleanup_test, UniqueIdGenerator_test and TOPP_FuzzyDiff all pass.

Checklist

  • Make sure that you are listed in the AUTHORS file
  • Add relevant changes and new features to the CHANGELOG file
  • I have commented my code, particularly in hard-to-understand areas
  • New and existing unit tests pass locally with my changes
  • Updated or added python bindings for changed or new classes (Tick if no updates were necessary.)

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as outdated.

Copy link
Copy Markdown
Contributor Author

Root cause of the Subprocess aborted failures — found and fixed

The CI diagnostics gave a complete answer. Summary: this PR reordered the test link lines, which duplicated Apache Thrift static objects into the test executables; they were then destroyed twice at process exit.

What the diagnostics showed

The tests themselves all pass — the abort happens at teardown, after PASSED. The core-dump backtrace (clang, x64):

#7  malloc_consolidate(): invalid chunk size
#10 __GI___libc_free
#11 ___kmp_free ()           <- OpenMP shutdown, innocent bystander
#16 _dl_call_fini / #17 _dl_fini

Valgrind named the actual defect, identically on clang/x64 and gcc/arm:

Invalid read of size 8
   at  std::map<int, char const*>::~map()   (in the test executable)
   by  __cxa_finalize
   by  ??? (in libOpenMS.so)                <- second destruction
 Address ... free'd
   by  std::map<int, char const*>::~map()   (in the test executable)
   by  __run_exit_handlers                  <- first destruction
 Block was alloc'd at
   by  std::map<int, char const*>::map<apache::thrift::TEnumIterator>(...)
   by  __static_initialization_and_destruction_0 (in the test executable)

The mechanism

Comparing the built binaries against develop made it precise:

develop this PR (before fix)
Thrift symbols in test executable 0 504
Exported (.dynsym) Thrift symbols 0 391
ConsensusMapArrowExport_test size 806 KB 19.5 MB
Result passes 5/5 aborts 3/3

libOpenMS.so is identical in both (382 defined / 10 undefined Thrift symbols). The difference is purely link order:

  • develop: libOpenMS.so … libarrow.a libparquet.a — the Arrow/Parquet references are already satisfied by libOpenMS.so, so no archive members are pulled in.
  • this PR: libOpenMSTestFramework.a libarrow.a libparquet.a … libOpenMS.so — declaring OpenMS a link dependency of the new OpenMSTestFramework forced CMake to place libOpenMS.so after it, and hence behind the static archives. The linker satisfied Arrow/Parquet from the archives, dragging their objects — including the Thrift enum-name statics — into every affected test executable.

Both binaries then contained (and exported) the same weak Thrift statics. The executable wins global symbol resolution, so libOpenMS.so bound to the executable's copy and registered an atexit destructor for it → destroyed once by the executable's exit handlers and once by __cxa_finalize() during dlclose/_dl_fini → heap corruption → the next free() (from libomp's shutdown) aborts.

This also explains the platform pattern: it needs ARROW_USE_STATIC=ON (the default) plus ELF symbol interposition, so macOS and Windows were unaffected, and on ARM it was intermittent (OpenSwathExport_test's plain rerun exited 0 there while valgrind still caught the double free).

Fixes (61cfde0, 58d92f7)

  1. Restore the link order — the framework propagates OpenMS' include dirs and compile definitions as usage requirements instead of a link edge, so libOpenMS.so precedes the static archives again. The OpenSwathAlgo tests, which relied on the transitive dependency, now name OpenMS explicitly (after the framework archive — their own sources reference no OpenMS symbols, so --as-needed would otherwise drop it).
  2. Defense in depth — new openms_hide_static_archive_symbols() links class tests with --exclude-libs,ALL, so archive symbols stay out of the executable's dynamic table even if something is pulled in later. GNU ld/lld only.

Verified locally with clang + static Arrow (the CI configuration): ConsensusMapArrowExport_test back to 902 KB with 0 Thrift symbols, and the Arrow, OpenSwathAlgo, framework, XML-format and TOPP_FuzzyDiff tests all pass.

Note the temporary diagnostic step in test.yml (b2587c9) is still on the branch and must be reverted before merge — I'll drop it once this round of CI confirms green.


Generated by Claude Code

@timosachsenberg timosachsenberg changed the title [BUILD,INTERNAL] Move class-test framework into new static OpenMSTestFramework library [BUILD,INTERNAL] Move the class-test framework into its own library (OpenMSTestFramework) Aug 15, 2026
@OpenMS OpenMS deleted a comment from coderabbitai Bot Aug 16, 2026
@coderabbitai

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as outdated.

claude added 17 commits August 17, 2026 08:04
…Framework library

Extract ClassTest.h, FuzzyStringComparator and MacrosTest.h from libOpenMS
into src/testframework/ (static library OpenMSTestFramework) as prework for
splitting libOpenMS into smaller libraries. Include paths and installed
header locations are unchanged, so the 700+ existing tests need no changes.

- ClassTest no longer hardwires the FORMAT layer: XML schema validation of
  NEW_TMP_FILE files at END_TEST and UniqueIdGenerator seeding at START_TEST
  are injected via setTmpFileValidator()/setTestInitHook(), registered by
  the new OpenMSTestSupport object library, which is linked into the openms
  and openms_gui class tests. This removes the framework's inverted
  CONCEPT -> FORMAT dependency.
- FuzzyStringComparator uses a local CRLF-stripping getLine and
  std::filesystem instead of TextFile/File, cutting its FORMAT/SYSTEM
  dependencies; the FuzzyDiff tool links the new static library.
- OpenSwathAlgo class tests now link OpenSwathAlgo + OpenMSTestFramework
  (libOpenMS only transitively, until the core split).
- testTrue/testFalse in ClassTest.h are now inline: test executables gain a
  second TU that includes the header (OpenMSTestSupport), which would
  otherwise be an ODR violation.
- The framework's symbols are no longer exported from libOpenMS
  (OPENMS_DLLAPI removed); the static archive is installed and exported as
  CMake target OpenMSTestFramework.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
Explain in plain language why the class-test framework is a standalone
static library, which behavior is injected via the two hooks, and how the
OpenMSTestSupport registration works.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
The include pruning in ClassTest.cpp / FuzzyStringComparator.cpp removed the
FORMAT/SYSTEM headers that had transitively pulled in several std headers.
libstdc++ still provides them through the remaining includes, libc++ (macOS)
does not: std::exception_ptr in printLastException() was an incomplete type,
failing the macos-15 CI job. Include everything used directly.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
The pyOpenMS wheel builds (and any other minimal install flow) build only
'ninja OpenMS OpenSwathAlgo' and install component-wise. Exporting the
test-framework target made their installed OpenMSTargets.cmake reference
lib/libOpenMSTestFramework.a, which is never built/installed there, so every
downstream find_package(OpenMS) failed.

The archive now installs under its own component (OpenMSTestFramework) and
the target is no longer registered in the OpenMS export set; in-tree
consumers (class tests, FuzzyDiff) link the target directly.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
…ORE MERGE

Re-runs the three aborting tests on the failing Linux jobs and captures gdb
backtraces from core dumps, a run under glibc malloc debugging, and a
valgrind run with origin tracking. Gated on job failure, Linux only.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
With ARROW_USE_STATIC=ON (the default) the Arrow/Parquet archives, including
the Thrift code bundled inside them, are linked into libOpenMS.so *and* into
every test executable that links Arrow/Parquet directly. Both binaries then
export the same weak Thrift template statics (the enum-name maps built from
apache::thrift::TEnumIterator). The executable is searched first when the
dynamic linker resolves global symbols, so libOpenMS.so binds to the
executable's copy and registers an atexit destructor for it: the object is
destroyed twice at teardown -- once via the executable's exit handlers, once
via __cxa_finalize() when libOpenMS.so is unloaded. That corrupts the heap and
aborts the process with "malloc_consolidate(): invalid chunk size" after all
subtests have already passed.

This is what made ConsensusMapArrowExport_test / QPXFile_test (clang++, x64)
and OpenSwathExport_test (g++, arm) abort in CI. Diagnosis came from valgrind
and core-dump backtraces captured in the failing jobs; the double free is
visible as a use-after-free of the Thrift map, first freed from
__run_exit_handlers and read again from __cxa_finalize.

New helper openms_hide_static_archive_symbols() links the class tests with
--exclude-libs,ALL so archive symbols stay out of the executable's dynamic
symbol table and each binary uses its own copy. Verified locally with a
static-Arrow build: exported Thrift symbols drop from 391 to 10 and
ConsensusMapArrowExport_test goes from aborting 3/3 to passing 3/3.

GNU ld and lld only -- the Apple linker has no equivalent option and Windows
does not have symbol interposition.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
… linking tests

Root cause of the CI aborts, found by comparing the failing binaries against
develop: on develop the test executables contain no Thrift symbols at all,
on this branch they contained 504 of them.

Declaring OpenMS a link dependency of the new OpenMSTestFramework forced CMake
to order libOpenMS.so *after* libOpenMSTestFramework.a on every consumer's link
line -- and thereby behind the static libarrow.a/libparquet.a that the
Arrow-related class tests link explicitly. The linker then satisfied the
Arrow/Parquet references from those archives instead of from libOpenMS.so and
pulled their objects, including the Thrift enum-name statics, into each test
executable. Those duplicated statics were the objects destroyed twice at exit
(see previous commit), and they also inflated the affected test binaries 24x
(ConsensusMapArrowExport_test: 0.8 MB -> 19.5 MB).

The framework now propagates OpenMS' include directories and compile
definitions as usage requirements without the link edge, restoring develop's
link order. Consumers link OpenMS themselves; the OpenSwathAlgo tests, which
relied on getting it transitively, now name it explicitly -- after the
framework archive, since their own sources reference no OpenMS symbols and the
linker's default --as-needed would otherwise drop libOpenMS.so before the
archive's references are seen.

Verified with clang + static Arrow (the CI configuration):
ConsensusMapArrowExport_test is back to 902 KB with 0 Thrift symbols, and the
Arrow, OpenSwathAlgo, framework, XML-format and TOPP_FuzzyDiff tests all pass.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
…rary

The class-test framework no longer needs any injected behavior:

- UniqueIdGenerator seeding now happens directly in ClassTest.cpp. The
  generator is CONCEPT level, the same layer the framework already uses for
  StringUtils/Exception/DataValue, so this adds no coupling it did not have.
  Boost::boost is declared on the target because UniqueIdGenerator.h includes
  boost/random headers (header-only, so no link-line entry and no effect on
  the link ordering the previous commit established).
- XML schema validation, which does need the FORMAT layer, moved into the
  class-test project as the header-only OpenMS/TestFileValidation.h. Tests
  that write mzML/featureXML/idXML/consensusXML/INI/transformationXML call
  VALIDATE_TMP_FILES before END_TEST; VALIDATE_FILE(f) validates a single
  file and reports at the call site.

setTestInitHook()/setTmpFileValidator() and the OpenMSTestSupport object
library are gone, along with the static-initializer registration.

Which tests need the explicit call was determined empirically, not guessed:
all 57 tests that combine NEW_TMP_FILE with a validatable format were built
and run against the previous hook-based build to record what each validated.
26 validate files and got the call; the other 31 produce nothing validatable.
The openms_gui and openswathalgo tests use NEW_TMP_FILE zero times, so they
only lose a link-line entry.

Verified: each of the 26 validates exactly the same number of files as
before, and 33 affected tests plus the TOPP_FuzzyDiff tests pass.

Note this makes validation opt-in: a new test that writes an XML file is not
schema-checked unless its author adds VALIDATE_TMP_FILES.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
The g++ CI jobs failed to link RAIICleanup_test after the support library was
removed:

  libOpenMSTestFramework.a(ClassTest.cpp.o): undefined reference to
  `OpenMS::UniqueIdGenerator::setSeed(unsigned long)'

The framework archive was listed after libOpenMS.so. With the linker's default
--as-needed, libOpenMS.so is only kept if something already seen requires it;
for a test whose own object references nothing from libOpenMS (RAIICleanup is
header-only) it was dropped, and the archive's later references to Exception,
StringUtils and UniqueIdGenerator then had nothing to resolve against.

Until now OpenMSTestSupport masked this: its object referenced the FORMAT layer
and so kept libOpenMS alive for every test. clang++, macOS and Windows were
unaffected, which is why only the two g++ jobs failed.

The link line is now: framework archive, libOpenMS, then (for the Arrow tests)
the static Arrow/Parquet archives. That satisfies both ordering constraints at
once -- verified: RAIICleanup_test links, and ConsensusMapArrowExport_test still
has 0 Thrift symbols at 890 KB rather than 19.5 MB. 40 tests pass, including the
26 with explicit validation, the OpenSwathAlgo tests and TOPP_FuzzyDiff.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
Comments left over from developing this branch referred to intermediate states
(the removed support library and its callbacks, includes that no longer exist).
Reword them to state the current design, fix a comment that named
OpenMS::absolutePath() instead of OpenMS::File::absolutePath(), and make the
reason ClassTest.h's testTrue/testFalse must be inline precise (ClassTest.cpp in
the archive is the second translation unit).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
- ClassTest.h: 2-space indent in isRealType(const ParamValue&)
- FuzzyStringComparator.h: realign wrapped parameters left over from
  removing OPENMS_DLLAPI
- Doxyfile_dot.in: drop the GENERATE_XML = YES assignment and its
  comment. It was overridden by GENERATE_XML = NO further down, so the
  comment claimed an XML output that this config never produced; the
  tools read the xml_output/ of the doc_xml target (Doxyfile_xml).

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
VALIDATE_TMP_FILES runs FileHandler::getType() on each temporary file and
only schema-checks the types validateTmpFiles() has a case for; anything
else is reported as skipped. PepXMLFile_test makes that visible: five of
its six temporary files are pepXML and are skipped, and the macro earns
its place there through the sixth, an idXML file that is validated.

The previous wording implied every file written above gets checked. Same
comment in all 26 tests, so it is updated in all of them.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
cmake_minimum_required said 3.21 while the Windows installation
instructions and AGENTS.md both already stated 3.24, so this makes the
build agree with the documentation rather than raising the bar on users.

3.24 is the first release with the $<LINK_LIBRARY:...> generator
expression and user-defined link features
(CMAKE_LINK_LIBRARY_USING_<FEATURE>). Those let a link requirement be
stated directly -- for instance wrapping a library in
--no-as-needed -- instead of encoding it in the order of
target_link_libraries arguments, which is how the class tests currently
keep libOpenMS alive ahead of the test-framework archive.

Verified: configures clean with no policy warnings, the test count is
unchanged at 2732, and nothing recompiles, so CMP0128 does not alter the
language-standard flags. CMP0135, the notable new policy in 3.24, only
affects URL-based downloads and every FetchContent_Declare here uses
GIT_REPOSITORY.

The subdirectory CMakeLists.txt files that still declare 3.15 are left
alone: raising them would switch policy defaults in those scopes and
deserves its own change.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
…gument order

The class tests kept libOpenMS on the link line only because
libOpenMSTestFramework.a -- which references Exception, StringUtils and
UniqueIdGenerator -- happened to be listed first: with the linker's
default --as-needed, a test whose own object needs nothing from libOpenMS
(RAIICleanup_test) would otherwise drop it. That made the order of
target_link_libraries() arguments a silent correctness requirement that
only a comment protected.

A 'needed' link feature (CMake 3.24) now says it outright, wrapping just
libOpenMS in --push-state,--no-as-needed,...,--pop-state. Verified by
reversing the arguments so libOpenMS comes first: it still links and
still records libOpenMS.so as DT_NEEDED, while the same reversed order
without the feature fails on exactly those undefined references. On Apple
and Windows, which have no --as-needed, the feature passes the library
through unchanged.

The second requirement -- libOpenMS ahead of the static Arrow/Parquet
archives, so their objects and Thrift's statics are not pulled into each
test -- is unaffected and still documented. Checked in the clang Release
build with static Arrow that reproduces it: ConsensusMapArrowExport_test
is 890872 bytes with 0 Thrift symbols, matching the healthy baseline.

The openms_gui tests keep the ordering for now: converting them means
resolving how OpenMS is spelt inside OpenMS_GUI_LIBRARIES, which needs a
Qt build to verify.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
Completes the previous commit: the openms_gui tests were left on the
argument ordering because verifying a change there needs a Qt build.

OpenMS_GUI_LIBRARIES is 'OpenMS_GUI;OpenMS;Qt6::Gui;Qt6::Widgets;
Qt6::Svg;Qt6::OpenGLWidgets', so dropping OpenMS from that list and
linking it through the feature is not sufficient on its own: OpenMS_GUI
links OpenMS publicly, so OpenMS also reaches these targets as a
transitive dependency with no feature, and CMake rejects that as

  'OpenMS', specified without any feature or 'DEFAULT' feature, has
  already occurred with the feature 'needed', which is not allowed.

LINK_LIBRARY_OVERRIDE_OpenMS settles the feature for every path by which
OpenMS reaches the target, which is what that property exists for.

Verified with Qt 6.4.2: configuration succeeds and the generated link
line wraps libOpenMS in --push-state,--no-as-needed,...,--pop-state even
though it now follows libOpenMS_GUI.so.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
Restores state that was carried by the merge commit which the split of
the tooling-removal PR rebased away.

UniqueIdGenerator stopped using boost::random in #9921, so the framework
no longer needs Boost's include directories: the header it seeds from
pulls in no boost headers at all any more.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR
@timosachsenberg
timosachsenberg force-pushed the claude/openms-test-framework-refactor-ssutqy branch from e833176 to d21ef5c Compare August 17, 2026 08:05

Copy link
Copy Markdown
Contributor Author

Follow-up: what it would take for the framework to stop depending on libOpenMS

This PR gets OpenMSTestFramework down to a small, well-defined dependency on libOpenMS. It does not remove it — the OpenSwathAlgo tests still name OpenMS explicitly, purely because the framework needs it. Recording the measurements here so the follow-up doesn't have to rediscover them.

The concrete goal is a single pass/fail test:

Datastructures_test (an OpenSwathAlgo test) links and passes with no libOpenMS on its link line.

How Catch2 solves this, and what carries over

Catch2, GoogleTest and doctest depend on the standard library and nothing else. They sit at the bottom of the dependency graph, so there is no "library under test" to be coupled to. Where they do need to know something about a user's types, they never name them — the user registers the knowledge:

CATCH_TRANSLATE_EXCEPTION(MyType const& ex) { return ex.message(); }

Catch2 stores that in a static registry (added in 2.8.0, precisely because exceptions not deriving from std::exception printed only "Unknown exception type"). Catch::StringMaker and GoogleTest's PrintTo are the same idea for value formatting.

We can't be std-only — TEST_EQUAL and TEST_REAL_SIMILAR legitimately format OpenMS types. But both halves of the Catch2 design do carry over:

  1. Sit at the bottom. Not "depend on nothing", but "depend on a bottom layer" rather than on all of libOpenMS.
  2. One customization point for the types the framework should not know about.

Measurement 1: nothing can be moved, and nothing is left to move

The framework needs 7 utilities from libOpenMS. Every one is a core library facility, so relocating them into the framework is not available:

symbol files in src/openms
StringUtils::toStr 285
StringUtils::trim 66
StringUtils::prefix 39
StringUtils::suffix 26
writtenDigits 15
precisionWrapper 9
StringUtils::extractDouble 5
ListUtilsIO (vector operator<<) 6

The reverse direction is also exhausted: scanning every OpenMS/CONCEPT header for ones referenced only from tests returns nothing. This PR already took the only test-only code libOpenMS had.

That leaves duplicating those utilities as the only way to cut the dependency — which is the wrong trade for code the library uses in 285 places. So the mechanism has to be something else.

Measurement 2: the closure is small and closed

The include closure of what the framework actually needs does not reach outside itself, apart from the generated config headers:

header includes implementation
CONCEPT/Types.h config.h —
CONCEPT/Exception.h Types.h 322 lines
DATASTRUCTURES/StringUtils.h Types.h, Exception.h 682 lines
CONCEPT/PrecisionWrapper.h Types.h, StringUtils.h 11 lines
DATASTRUCTURES/ListUtils.h StringUtils.h, TypeAliases.h, Exception.h 13 lines
DATASTRUCTURES/ListUtilsIO.h StringUtils.h header-only
DATASTRUCTURES/TypeAliases.h Types.h header-only
CONCEPT/UniqueIdGenerator.h Types.h only 126 lines

8 headers, 5 sources, ~1,150 lines — extractable as a core library that both libOpenMS and OpenMSTestFramework depend on. No code is duplicated and nothing is moved out of use.

Consumers are unaffected: include paths stay as they are and libOpenMS PUBLIC-links the core, so the 317 files including StringUtils.h, 243 including Exception.h and 196 including Types.h need no edits. Only the build system changes.

What that removes from the problem

Three things I had assumed were needed turn out not to be:

  • No seeding hook. UniqueIdGenerator.h includes only Types.h, so it fits the core and the framework keeps calling setSeed() directly. This PR's removal of the init callback stands; it does not need reintroducing.
  • No exception translator. With Exception in the core, the TEST_EXCEPTION macros keep catching BaseException directly. This is where we diverge from Catch2 deliberately — a translator would only be needed if the framework could not see the exception type at all, and it is the one change that would alter what a failing test prints.
  • No work at all on StringUtils, PrecisionWrapper, Types or ListUtilsIO.

What remains

One customization point, for the only dependency that should not go in the core. DataValue is a variant type used tree-wide, and ClassTest.h includes it solely for two overloads:

inline bool isRealType(const ParamValue&) { return true; }
inline bool isRealType(const DataValue&)  { return true; }

Replacing them with a trait the OpenMS side specializes is the direct analogue of Catch::StringMaker — it moves knowledge, not code:

template <class T> struct IsRealType : std::is_floating_point<T> {};

Cost, measured: 26 test files need an explicit include they currently get transitively through ClassTest.h (23 for DataValue, 3 for ParamValue).

Suggested order

  1. Extract the core library — build-system only, no source edits. Verifiable with nm: the framework's undefined symbols should resolve against the core, not libOpenMS.
  2. Add the IsRealType trait and the 26 explicit includes.
  3. Run the acid test, then drop the explicit OpenMS from src/tests/class_tests/openswathalgo/CMakeLists.txt.

Step 1 is not a precursor to splitting libOpenMS — it is the first slice of it. The framework's dependency list turns out to be a fairly precise specification of what the core library has to contain, which seems like the more useful outcome of this exercise.

Happy to move this to an issue if that is a better home than a PR comment.


Generated by Claude Code

@cbielow

cbielow commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

what are the compile time implications here?

And how much does runtime increase with VALIDATE_TMP_FILES? (which seems to be not required for this PR, but should be separate?)

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

The validation already happened automatically. this just makes it explicit (removes the validation from the framework and moves it to the library to be tested). It is so small that compile times and linking is about the same as before. Rebuild will be smaller if we do a library split into core, up etc. The ultimate goal should be to get a proper inversion of the dependency (e.g. the testing framework should not know much about what it tests and thus works with split libraries). That’s how other testing frameworks do it.

timosachsenberg added a commit that referenced this pull request Aug 18, 2026
…raction

Six pre-work changes, each measured on the #9919 branch, that remove the
plan's hard parts at the root instead of working around them:
configuration-free bottom layer with checked-in platform/export headers
(deletes the config.h wiring section), pull-model terminate handler so
Exception.cpp drops GlobalExceptionHandler (also fixes a data race),
local PID fetch so SysInfo stays in libOpenMS, moving DataValue
knowledge out of Types.h/StringUtils (incl. the test-only
writtenDigits<DataValue> specialization and the dead OpenMS_locale
global), finishing target-based CMake, and deriving the shipped-library
roster. With S1-S4 landed, the extraction becomes 9 headers + 4
dependency-free sources - the "build-system only" move the original
sketch assumed.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

Copy link
Copy Markdown
Contributor Author

The follow-up sketch, verified and turned into a plan

The sketch above has now been checked against this branch and expanded into a full implementation plan: doc/plans/OpenMSCore-extraction.md. This comment supersedes the sketch — what held, what didn't, and the shorter path that fell out of it. Everything below is measured, not estimated.

Confirmed

  • Trait cost: exactly 26 test files (23 for DataValue, 3 for ParamValue), plus 1 in openms_gui.
  • Nothing in the closure needs Boost or Qt; no seeding hook and no exception translator are required.
  • The framework's true link-level surface (compiling its two TUs standalone, nm -uC): ~11 symbols — BaseException dtor/getters and two subclass ctors, StringUtils::appendToStr(int,…), StringUtilsHelper::extractDouble, UniqueIdGenerator::setSeed — plus typeinfo for Exception::BaseException. TEST_EXCEPTION catches across the library boundary, so that RTTI must be a single shared definition; this detail ends up deciding the architecture.

Corrected: the closure is bigger than the header walk showed

The sketch measured header includes; the implementations add more:

sketch file its .cpp additionally needs
Exception.cpp GlobalExceptionHandler (every ctor pushes into it)
UniqueIdGenerator.cpp SysInfo::getProcessId() (seed mixing)
StringUtils.cpp DataValue.h/ParamValue.h (three toStr/appendToStr definitions) and SIMDe (the SIMD trim)

So "8 headers, 5 sources, build-system only" is false as measured: 11 headers + 7 sources (~4,400 lines) and a handful of real source edits.

The decision the sketch didn't make: the core must be a shared library

A static core embedded in both libOpenMS and each test executable duplicates four load-bearing globals: the UniqueIdGenerator singleton (START_TEST would seed a different instance than the library draws IDs from — always on Windows, and on Linux openms_hide_static_archive_symbols() from this very PR would defeat the interposition that hides it), GlobalExceptionHandler's state, the locale global in Types.cpp, and BaseException's vtable/typeinfo (cross-library catch breaks on macOS under hidden visibility). That is the Thrift lesson from this PR, generalized. Shared it is; openms_add_library() plus the OpenSwathAlgo precedent turn the new-artifact cost into a packaging checklist (wheels workflow components, pyOpenMS copy list and Linux preload order, KNIME lists — all enumerated in the plan).

The better outcome: change the code so the sketch becomes true

Each hard part of the extraction exists because something in OpenMS sits one layer below where it belongs — and each is fixable by deleting code, as small independently green PRs before the extraction:

  1. Configuration-free bottom. The 18 files consume no configure-time fact that isn't compiler-derivable (_WIN32, __has_include, !defined(NDEBUG) — which, unlike today's CMAKE_BUILD_TYPE check, also works for multi-config Debug — and std::endian; OPENMS_HAS_PROCESS_H has zero users). Checked-in static platform and export headers (all *_DLLAPI macros in one file keyed on CMake's <Target>_EXPORTS) delete the entire generated-header wiring problem, and make every future library a three-line diff.
  2. Pull-model terminate handler. Exception ctors stop pushing file/line/what into GlobalExceptionHandler's static strings (a data race under OpenMP, and it reports the last-constructed exception rather than the terminating one); the handler reads the in-flight BaseException via std::current_exception() + rethrow. Exception.cpp becomes dependency-free; the four outside setMessage() call sites are mechanical deletions.
  3. Local PID fetch in UniqueIdGenerator.cpp (three-line #ifdef) — SysInfo (335 lines of psapi/mach code, 8 real users) stays in libOpenMS.
  4. Type knowledge out of the bottom headers. Types.h itself specializes writtenDigits<DataValue> (used only by TEST_REAL_SIMILAR — no library caller exists), and StringUtils declares/defines toStr(DataValue/ParamValue); both move next to the types. Since DataValue/ParamValue have implicit operator double(), std::is_floating_point_v<T> || (std::is_class_v<T> && std::is_convertible_v<T, double>) can replace the isRealType registration entirely — future variant types then work with zero registration. Bonus find: Internal::OpenMS_locale is a no-op relic (its initializer restores what it sets; one reader that can use the literal "C") — deleting it empties Types.cpp.

After 1–4, the extraction is 9 headers + 4 dependency-free sources — effectively the "git mv + build system" move the sketch assumed — followed by the trait step (26+1 includes) and the cord-cut: the framework links OpenMSCore PUBLIC, the OpenSwathAlgo tests drop "$<LINK_LIBRARY:needed,OpenMS>", and the acid test stands: Datastructures_test with no libOpenMS anywhere in its link closure.

@cbielow re compile time: net −1 TU (−2 after the cleanups: PrecisionWrapper.cpp and Types.cpp are deleted), same code compiled once, better relink granularity, no runtime or behavior change; test binaries are unchanged and the new library is a few hundred KB.


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Revision: the framework can be freed without creating a library (the Catch2 answer)

The plan comment above was still complex because it answered two questions at once: free the test framework and start splitting libOpenMS. Everything heavy in it — the shared OpenMSCore, the export macros, the config.h wiring, the packaging checklist, the ABI note — is a cost of the second goal. Catch2 pays none of it because it refuses that goal's premise: it depends on nothing, so there is no library to create, version, export, or ship.

Catch2's cleanliness is one structural rule, not general tidiness:

The framework's compiled code touches only std types. Everything type-specific happens at the macro-expansion site, inside the test's TU, where the test's headers are visible. Knowledge flows into the framework via operator<<, ADL, trait defaults, and registration — the framework never names a type it tests.

The earlier sketch's objection ("we can't be std-only — TEST_EQUAL legitimately formats OpenMS types") conflated tests formatting OpenMS types (true — at the expansion site) with the framework linking OpenMS formatting (not needed). And this framework is already halfway there: testEqual's failure output streams both values with bare operator<< today — the Catch2 mechanism, in place and working.

Mapping the five measured couplings onto Catch2's mechanisms:

coupling (measured) Catch2 mechanism change
StringUtils::toStr in TEST_EQUAL's std::string == numeric quirk (old String(114) == "114") StringMaker — the framework owns its stringification ~20-line framework-local formatter; the one care point: doubles must format like toStr, and the 720-test suite is the oracle
ListUtilsIO.h include (vector printing) users provide operator<<, framework prints {?} otherwise framework-local streamable-if-possible printer; the include leaves ClassTest.h
BaseException caught/printed in ClassTest.cpp (+ ConversionError/IndexOverflow ctors via inline StringUtils.h code) catch std::exception + registered translators BaseException already is a std::runtime_error — fold file/line/name into what() (a strict improvement: even the default terminate handler prints what()), framework catches std::exception only. TEST_EXCEPTION(Exception::Precondition, …) is untouched — its typed catch expands in the test TU
StringUtilsHelper::extractDouble (49 lines) + trim in the fuzzy comparator the framework owns its parsing framework-local copies; parsing arbitrary file text is semantically independent of the library by nature
UniqueIdGenerator::setSeed at START_TEST event listeners — registration by the side that knows a support TU in the openms class-test project whose static initializer calls setSeed(2453440375) (one target_sources line; runs even earlier than today). The OpenSwathAlgo tests simply don't compile it. This re-adds what this PR's hook-removal took out — but as test-project code, not framework API
isRealType/writtenDigits<DataValue> trait with a sensible default `std::is_floating_point_v

Result: OpenMSTestFramework becomes a std-only static library — zero OpenMS includes, zero link dependencies, ~200–250 owned lines — in three small PRs: (1) complete what(); (2) std-only framework + CMake decoupling + seeding TU + the OpenSwathAlgo tests drop "$<LINK_LIBRARY:needed,OpenMS>"; (3) the predicate with the 26+1 test includes. No OPENMSCORE_DLLAPI, no config wiring, no packaging, no ABI change — and the acid test (Datastructures_test with no libOpenMS in its link closure) holds trivially.

Honest costs: ~250 lines duplicated in spirit (trim, number extraction, numeric formatting), with a loud failure mode (test failures, not silent drift) confined to fuzzy parsing and the string-vs-numeric quirk; and what() gaining context visibly changes uncaught-exception text tool-wide — for the better.

OpenMSCore stays on the table as exactly what it is: the first slice of splitting libOpenMS, on the split's own timeline and justification — no longer coupled to the framework. And if the question becomes "why not adopt Catch2 outright": wrapping TEST_* over Catch2 is feasible but is a 720-file migration project; this gets Catch2's architecture — which is what makes the framework split-proof — without touching a single test.

Full write-up (measurements, trade-offs, sequencing) is Part 3 of doc/plans/OpenMSCore-extraction.md.


Generated by Claude Code

timosachsenberg added a commit that referenced this pull request Aug 18, 2026
…a donor

The spec no longer requires #9919 to merge. Sequencing std-only BEFORE
extraction restructures the program into three green PRs from develop:
PR0 explicit tmp-file validation (26 measured tests, hunks donated by
the #9919 branch), PR1 std-only in place (framework files still inside
libOpenMS, so tests keep linking as today), PR2 a purely mechanical move
to src/testframework. Because the framework archive then references no
libOpenMS symbols and every openms test binary references libOpenMS
through the seeding/translator support TU, four pieces of #9919's
machinery are never needed: the 'needed' link feature,
LINK_LIBRARY_OVERRIDE, the CMake 3.21->3.24 bump, and the
OpenMS->framework usage-requirement propagation; the Arrow/Thrift link
order from develop is undisturbed. All file:line references re-verified
against develop (c77f588), including develop-only deps the previous
revision could not see (automatic FORMAT validation, TextFile/File use
in FuzzyStringComparator, vestigial boost fpclassify include).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

Copy link
Copy Markdown
Contributor Author

Note: this PR will be superseded

The plan has moved to a program based directly on develop that reaches the std-only end state without this PR merging first: doc/plans/testframework-std-only-implementation.md. Three PRs, each green: (0) explicit tmp-file validation, (1) the framework goes std-only in place inside libOpenMS, (2) a purely mechanical move to src/testframework/.

Nothing here is wasted — this branch becomes the donor for its verified pieces: the TestFileValidation.h + 26-test validation hunks (the measurement lives in this diff), the FORMAT/SYSTEM-free FuzzyStringComparator.cpp, and the src/testframework/CMakeLists.txt skeleton. The measurements in this thread (link surface, the 26+1 DataValue includes, the Thrift/Arrow analysis) all carry over.

What the new sequencing avoids needing at all: the needed link feature and LINK_LIBRARY_OVERRIDE, the CMake 3.21→3.24 bump (which existed only for that feature), and the OpenMS→framework usage-requirement propagation — because after step (1) the framework archive references no libOpenMS symbols, and every openms test binary references libOpenMS through the seeding/translator support TU, so link order is unconstrained and the Arrow ordering from develop is never disturbed.

Keeping this PR open until the replacement PRs are up, then it will be closed in favor of them.


Generated by Claude Code

timosachsenberg added a commit that referenced this pull request Aug 18, 2026
END_TEST no longer schema-validates NEW_TMP_FILE outputs automatically;
the 26 tests that actually validated files (determined by measurement in
#9919: all 57 NEW_TMP_FILE+XML tests were run against the automatic-
validation build and 26 validated something) now call VALIDATE_TMP_FILES
explicitly via the new header-only TestFileValidation.h in the class-test
project. Each validates exactly the same files as before; types without
a schema validator were skipped before and still are.

This removes the framework's only dependency on the FORMAT layer (a
CONCEPT component calling upward), as prework for making the class-test
framework standard-library-only. Validation becomes opt-in for new
tests; the VALIDATE_TMP_FILES docs say when to add it.

Validation hunks taken from #9919 (measurement and 26-test list).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D
timosachsenberg added a commit that referenced this pull request Aug 18, 2026
…on.h)

The donor hunk from #9919 that puts ${PROJECT_SOURCE_DIR}/include/ on
the class-test include path was missed when porting the explicit-
validation commit; without it the 26 validating tests cannot find
<OpenMS/TestFileValidation.h>.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D
@jpfeuffer

Copy link
Copy Markdown
Contributor

Quick question, what do we do that catch cannot do?
And how big would a move to catch be?

@timosachsenberg

timosachsenberg commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor Author

I think we could move to catch2 but: we would not win much as you also need to register exception translators and catch is a bit more expensive regarding compile times. See the new PR with the improved design.

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

#9929 With improved / low dependency design

@timosachsenberg

Copy link
Copy Markdown
Contributor Author

@jpfeuffer v3 seems to have faster build times so catch2 could be a follow up at some point

timosachsenberg added a commit that referenced this pull request Aug 26, 2026
…to its own library (OpenMSTestFramework) (#9929)

* [DOC] Plan: OpenMSCore extraction so the test framework stops depending on libOpenMS

Follow-up plan for #9919, verified against that branch by measurement:
the framework's link surface (nm on its two objects), the implementation
closure the PR-comment sketch missed (GlobalExceptionHandler, SysInfo,
SIMDe, the DataValue/ParamValue toStr definitions), why the core must be
a shared library (four duplicated-state hazards incl. UniqueIdGenerator
seeding and BaseException RTTI), the OPENMSCORE_DLLAPI/config.h wiring,
the test-side isRealType customization point (26+1 files, measured), the
two-PR step sequence with an acid test, and the packaging checklist for
a new shipped library (wheels, KNIME, pyOpenMS preload).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [DOC] Part 2: upstream simplifications that shrink the OpenMSCore extraction

Six pre-work changes, each measured on the #9919 branch, that remove the
plan's hard parts at the root instead of working around them:
configuration-free bottom layer with checked-in platform/export headers
(deletes the config.h wiring section), pull-model terminate handler so
Exception.cpp drops GlobalExceptionHandler (also fixes a data race),
local PID fetch so SysInfo stays in libOpenMS, moving DataValue
knowledge out of Types.h/StringUtils (incl. the test-only
writtenDigits<DataValue> specialization and the dead OpenMS_locale
global), finishing target-based CMake, and deriving the shipped-library
roster. With S1-S4 landed, the extraction becomes 9 headers + 4
dependency-free sources - the "build-system only" move the original
sketch assumed.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [DOC] Part 3: the Catch2 answer - free the framework without creating a library

Parts 1-2 answered two questions at once; all residual complexity
(shared library, export macros, config wiring, packaging, ABI) belongs
to starting the libOpenMS split, not to freeing the framework. Catch2's
structural rule - the framework's compiled code touches only std types,
everything type-specific happens at the macro-expansion site - maps onto
the five measured couplings: expansion-site printing already works
today, BaseException already derives std::runtime_error (complete
what(), catch std::exception), framework-owned trim/extractDouble/
formatter (~250 lines, loud failure mode), seeding via a test-project
support TU, and the S4 predicate. Result: a std-only static framework,
no new shipped artifact, acid test met in three small PRs; OpenMSCore
decouples onto the split's own timeline.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [DOC] Implementer spec for the std-only test framework (Part 3 handoff)

File-by-file specification with copy sources (appendNumeric,
extractDouble+parseFloat/tryParseNaN, to_path), the exception-translator
registry replacing the BaseException clauses in printLastException and
the TEST_EXCEPTION* macros, the seeding+translator support TU wired into
the three add_executable sites, the printValue layer (named function,
not operator<<, to avoid ADL ambiguity with ListUtilsIO), framework-owned
writtenDigits (OpenSwathAlgo tests use TEST_REAL_SIMILAR), the
NDEBUG switch for the precondition macros (14 files), the include-fallout
protocol, acceptance criteria, and a risk register.

Two revisions to Part 3 discovered while specifying: the isRealType
predicate must ride in the main PR (ClassTest.h cannot go std-only while
including DataValue.h), and the what()-completion PR is dropped -- 29
files compare what() verbatim in TEST_EXCEPTION_WITH_MESSAGE, so
exception naming is injected via a registered translator instead.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [DOC] Rebase the std-only framework spec onto develop; #9919 becomes a donor

The spec no longer requires #9919 to merge. Sequencing std-only BEFORE
extraction restructures the program into three green PRs from develop:
PR0 explicit tmp-file validation (26 measured tests, hunks donated by
the #9919 branch), PR1 std-only in place (framework files still inside
libOpenMS, so tests keep linking as today), PR2 a purely mechanical move
to src/testframework. Because the framework archive then references no
libOpenMS symbols and every openms test binary references libOpenMS
through the seeding/translator support TU, four pieces of #9919's
machinery are never needed: the 'needed' link feature,
LINK_LIBRARY_OVERRIDE, the CMake 3.21->3.24 bump, and the
OpenMS->framework usage-requirement propagation; the Arrow/Thrift link
order from develop is undisturbed. All file:line references re-verified
against develop (c77f588), including develop-only deps the previous
revision could not see (automatic FORMAT validation, TextFile/File use
in FuzzyStringComparator, vestigial boost fpclassify include).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [TEST] Make tmp-file schema validation explicit (VALIDATE_TMP_FILES)

END_TEST no longer schema-validates NEW_TMP_FILE outputs automatically;
the 26 tests that actually validated files (determined by measurement in
#9919: all 57 NEW_TMP_FILE+XML tests were run against the automatic-
validation build and 26 validated something) now call VALIDATE_TMP_FILES
explicitly via the new header-only TestFileValidation.h in the class-test
project. Each validates exactly the same files as before; types without
a schema validator were skipped before and still are.

This removes the framework's only dependency on the FORMAT layer (a
CONCEPT component calling upward), as prework for making the class-test
framework standard-library-only. Validation becomes opt-in for new
tests; the VALIDATE_TMP_FILES docs say when to add it.

Validation hunks taken from #9919 (measurement and 26-test list).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [INTERNAL] Class-test framework: standard library only

The framework (ClassTest, FuzzyStringComparator) no longer uses anything
from libOpenMS -- verified by compiling both TUs against an include tree
containing only the framework's own headers, and by linking and running
a test executable against nothing but the two framework objects.

Following the structure of Catch2: the framework's compiled code touches
only std types; everything type-specific happens at the macro-expansion
site or is registered by the side that knows.

* New ClassTestUtils.h owns the utilities the framework needs:
  writtenDigits, an isRealType predicate (floating point, or class
  implicitly convertible to double -- covers DataValue/ParamValue and
  any future variant type with zero registration), the numeric
  formatter (verbatim copy of StringUtils' appendNumeric; TEST_EQUAL's
  string-vs-number quirk must format exactly like toStr), a printValue
  layer for failure reports (streamable via expansion-site operator<<,
  ranges as "[a, b, c]" like ListUtilsIO, placeholder otherwise), trim/
  split/join, and a precisionWrapper equivalent.
* Exception handling: the framework catches std::exception only.
  TEST_EXCEPTION's typed catch always bound in the test TU; the
  hard-coded BaseException clauses are replaced by registered exception
  translators (Catch2's translator design). printLastException and the
  macros describe foreign exceptions via describeCaughtException().
* FuzzyStringComparator carries local copies of extractDouble/
  tryParseNaN/parseFloat, to_path, prefix/suffix and TextFile::getLine
  (each with a pointer to its source of truth); StringList/Int/UInt are
  respelled as their underlying std types, so the API is unchanged and
  FuzzyDiff compiles as before.
* New OpenMSTestSupport.cpp, compiled into every openms/openms_gui test
  executable, seeds UniqueIdGenerator at static init (earlier than the
  removed START_TEST-time call) and registers the OpenMS exception
  translator. OpenSwathAlgo tests do not include it -- their tests need
  nothing from libOpenMS anymore.
* TEST_PRECONDITION/POSTCONDITION_VIOLATED now key on NDEBUG (also
  correct for multi-config generators, unlike CMAKE_BUILD_TYPE).
* 25 tests add the DataValue/ParamValue includes they previously got
  transitively through ClassTest.h (23 + 3, measured; one file needs
  both).

The framework files still live in src/openms and still compile into
libOpenMS; the move into their own static library is the next commit.
Test link lines are unchanged in this commit.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [BUILD,INTERNAL] Move the class-test framework into its own library (OpenMSTestFramework)

Pure mechanics on top of the previous commit: git mv of the six framework
files (history follows) out of libOpenMS into src/testframework/, built
as the static library OpenMSTestFramework. Include paths are unchanged
(<OpenMS/CONCEPT/ClassTest.h>), install locations are unchanged, so no
test file needs editing for the move.

Because the framework is standard-library-only, none of the link-order
machinery a dependent framework would need exists here: no link
features, no --as-needed precautions, no usage-requirement propagation
from OpenMS, and the CMake minimum stays at 3.21. Every openms /
openms_gui test binary references libOpenMS genuinely (through its own
test code and OpenMSTestSupport.cpp), and libOpenMS.so keeps preceding
the static Arrow archives on the test link lines exactly as on develop.

* class tests link "OpenMSTestFramework ${OpenMS_LIBRARIES}" (gui
  analogous); the OpenSwathAlgo tests link "OpenSwathAlgo
  OpenMSTestFramework" -- no libOpenMS anywhere in their link closure,
  which was the goal of this series.
* FuzzyDiff links the framework for FuzzyStringComparator.
* The ~50 OPENMS_DLLAPI decorations are stripped (a static archive
  exports nothing) and the framework's symbols leave the libOpenMS ABI.
* The archive installs under its own component and is deliberately not
  part of the exported OpenMS package, so minimal component-wise
  install flows (pyOpenMS wheels) are unaffected.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [INTERNAL] Remove test-only DataValue knowledge from Types.h and the OpenMS_locale relic

The writtenDigits<DataValue> specialization (and its DataValue forward
declaration) existed only for TEST_REAL_SIMILAR, which now uses the test
framework's own writtenDigits; no library code calls it (measured).

Internal::OpenMS_locale was a no-op: its initializer saved the locale,
set "C" and restored the saved locale again, so the global only ever
held the literal "C". Its one reader (OpenSwathFeatureXMLToTSV) now uses
the literal; the test that existed solely to verify the relic is
removed, and with it Types.cpp is empty and deleted. This also removes a
static-initialization side effect from the bottom-most library layer.

Plus the CHANGELOG entry for the whole test-framework series.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [TEST] Add includes tests previously received transitively via ClassTest.h

First batch of the include fallout from the framework going
standard-library-only: tests using Exception types, StringUtils'
string operators, or the StringList alias now include those headers
themselves. Found by the full local build; more batches follow as the
-k 0 pass surfaces them.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [TEST] Second batch of include fallout; make MultiplexSatelliteProfile.h self-contained

Complete inventory from the full -k 0 build: tests add the Types.h /
Exception.h / StringUtils.h / TypeAliases.h includes they previously
received transitively through ClassTest.h. Two notable finds beyond
plain includes: MultiplexSatelliteProfile.h used OPENMS_DLLAPI without
including OpenMSConfig.h (never self-contained; papered over by the old
ClassTest.h transitives) and gets the include; and the one
TEST_EQUAL(std::string, DataValue) call site in the tree
(TargetedSpectraExtractor_test) now stringifies explicitly with
DataValue::toString() -- the same function the removed implicit
toStr(DataValue) path called.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [TEST] Add the class-test project's own include dir (TestFileValidation.h)

The donor hunk from #9919 that puts ${PROJECT_SOURCE_DIR}/include/ on
the class-test include path was missed when porting the explicit-
validation commit; without it the 26 validating tests cannot find
<OpenMS/TestFileValidation.h>.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [TEST] TOPPBase_test: compare string options against string literals

The five TEST_EQUAL(getStringOption(...), DataValue("...")) sites
compared a std::string against a DataValue, which relied on the
framework stringifying the DataValue; comparing against the string
literal directly is equivalent and simpler. (The framework's
stringification guard rejects non-arithmetic types by design.)

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [TEST] Key TEST_PRECONDITION_VIOLATED on the library's OPENMS_ASSERTIONS via registration

The NDEBUG guard was wrong in exactly the configuration the class tests
build in: the test projects replace CMAKE_CXX_FLAGS_RELEASE with plain
-O0, wiping -DNDEBUG, so the macros expected Precondition throws from a
Release library whose OPENMS_PRECONDITION checks are compiled out --
nine "no exception thrown" failures and one segfault (the unguarded
command running into the very condition the precondition guards) in the
local Release run.

Fixed with the same pattern as seeding and exception naming: the side
that knows registers. TEST_PRECONDITION/POSTCONDITION_VIOLATED now
check a runtime flag (default off) that OpenMSTestSupport.cpp enables
under #ifdef OPENMS_ASSERTIONS -- the identical switch Macros.h keys
the library's checks on, read from the same config.h, so the
expectation can never diverge from the library's behavior in any build
type, flag override, or multi-config generator.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [INTERNAL] Address review: iterator-overload UB, libc++ includes, report wording, doc alignment

Review findings from #9929, each verified against the code before fixing:

* extractDouble/extractInt iterator overloads (StringUtils.h and the
  framework's copy, kept in sync) no longer dereference the past-the-end
  iterator -- the end pointer is computed from the range length -- and
  guard empty ranges before dereferencing begin. Identical behavior for
  non-empty ranges; debug-iterator builds stop asserting.
* FuzzyStringComparator: explicit <fstream>/<istream>/<ostream> in the
  header and <type_traits> in the .cpp (std::is_same_v sits in the
  libc++-only from_chars fallback, exactly the platform that would have
  missed it transitively).
* TEST_NOT_EQUAL's generic failure branch says "forbidden is" like its
  enum branch (the "expected" wording predates this series).
* describeCaughtException() documents that it requires an active
  exception (bare rethrow otherwise terminates).
* TestFileValidation.h includes Types.h/TypeAliases.h directly and
  VALIDATE_TMP_FILES prints the failing-line marker like VALIDATE_FILE.
* OpenSwathFeatureXMLToTSV: setlocale(LC_ALL, "C") directly instead of
  a variable that only ever held "C".
* doc/plans: Part 3 aligned with the implemented translator design (no
  what() changes), PR count wording, acceptance criterion checks the
  transitive closure via ldd, include check scans all framework files
  against an allowlist.

Declined, with reasons in the PR thread: the to_path POSIX fallback
(verbatim copy of PathUtils.h; POSIX path construction is a byte copy
and cannot throw) and registering compressed tmp-file names (behavior
is identical to develop's automatic validation; changing it would newly
validate files with unverified .gz validator support -- follow-up
material).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [DOC] ClassTest doxygen page: document the std-only framework architecture

Rewrite the @defgroup ClassTest page (stale since the framework moved out of
OpenMS/source/TEST): what the OpenMSTestFramework library is, why it is
std-only, test anatomy, the registration points wired up by
OpenMSTestSupport.cpp (exception translators, precondition-test enablement,
unique-id seeding), expansion-site printing, the TEST_REAL_SIMILAR
convertibility rule, and where VALIDATE_TMP_FILES lives.

Tag VALIDATE_TMP_FILES / VALIDATE_FILE / validateTmpFiles with
@InGroup ClassTest and add the openms class-test include dir to the
documentation search path so they render on the same page.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [DOC] ClassTest: use doxygen comments for the group markers

The member block of the ClassTest topic was delimited with plain '//@{' /
'//@}' C++ comments, which doxygen (1.9.x) ignores entirely -- the generated
'Class test macros' page carried the group description but listed no macros.
Replace them with real doxygen comments ('/** @{ */' ... '/** @} */') so all
test macros appear as members of the page, and drop the equally invisible
'//@name test and subtest' stub. Verified with doxygen 1.9.8: the group page
now lists all 26 framework macros plus the validation helpers.

Also escape the whitespace escapes in the trim() doc comment, which doxygen
parsed as (unknown) commands.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [DOC] Drop the design/plan documents from the branch

The two planning documents under doc/plans/ drove the design phase of this
series; the durable outcome lives in the PR description, the code comments,
and the ClassTest doxygen page. Remove them so the tree gains no
implementation-time planning artifacts.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [FIX] to_path: key the Windows fallback on _WIN32; review-round polish

PathUtils.h guarded the Windows ANSI-code-page fallback of the inline
to_path() with OPENMS_WINDOWSPLATFORM but includes nothing that defines it,
so the branch selected depended on whether the including TU happened to see
<OpenMS/config.h> first -- an ODR hazard, and the cause of the windows-2025
CI failure: the std-only ClassTest.h no longer hands test TUs config.h
transitively, so PathUtils_test compiled to_path without the fallback and
the CP-1252 test cases threw. Key the guard on the compiler-provided _WIN32
(self-contained by construction; matches the framework's copies byte for
byte). Verified as the only header using a config.h macro without including
config.h; all test TUs using such macros reach config.h via Types.h.

Review-round follow-ups: printLastException reproduces develop's exact
two-line report format for non-OpenMS exceptions (translator output stays
on one line); drop TOPPBase_test's now-unused DataValue.h include; document
writtenDigits' deliberate report-precision divergence (ParamValue 6->15,
long 9->18; print-only, never the comparison).

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [BUILD] Do not ship the test-framework archive

The class-test framework is an in-repo development tool, not product
payload. Mark the archive's install rule EXCLUDE_FROM_ALL so default
installs and the monolithic installers (NSIS/zip) skip it, and drop the
component from the macOS productbuild package list (which enumerates
components explicitly). `cmake --install . --component
OpenMSTestFramework` still installs it for whoever wants it.

The headers keep installing to their historic location: they always
shipped as part of the OpenMS header set, and existing includes of
<OpenMS/CONCEPT/ClassTest.h> keep resolving against an installed tree.
All linking consumers (class tests, FuzzyDiff, tests of future
split-off libraries) are in-tree and use the CMake target directly.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

* [TEST] Guard the framework's copies of the libOpenMS numeric code

OpenMSTestFramework is standard-library-only, so the numeric formatting and
number parsing it needs are copies of libOpenMS code: detail::appendNumeric in
ClassTestUtils.h from StringUtils.cpp, and tryParseNaN/fromCharsFloat/
parseFloat/extractDouble in FuzzyStringComparator.cpp from StringUtils.

The copies exist to produce identical results, and nothing enforced that. The
two sides compile independently, so a change to one was silently accepted, and
the consequence would not be a build error but a behavioural one: TEST_EQUAL
(std::string, <number>) would stop agreeing with StringUtils::toStr(), and
FuzzyStringComparator would stop reading back the numbers the library writes
into the TOPP reference files. The suite was only an indirect oracle for this
-- it notices drift when some unrelated test's expected string happens to
change.

The test compares against libOpenMS rather than against a table of expected
strings, so a legitimate change to the library's format does not have to be
transcribed here, and the assertion keeps meaning "the two agree". It sits in
the class-test project because only there are both implementations visible.

Covers double/float/long double/integral formatting, writtenDigits (pinning the
documented, deliberate long and unsigned long divergences so they stay
deliberate), and -- through compareStrings -- that the comparator still parses
what StringUtils writes.

Verified by mutation: dropping one digit of precision in the framework's
appendNumeric, making its extractDouble always fail, and making its parseFloat
reject exponents are each caught. Disabling tryParseNaN alone is not, since
std::from_chars accepts "nan" as well; the comment on that assertion says so
rather than claiming a guard it does not provide.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MbuL7ckNAxytCK486pxHGR

* [DOC] Trim verbose code comments in the test framework

Tighten the block/rationale comments added in this series (framework
CMakeLists, ClassTestUtils, OpenMSTestSupport, PathUtils, FuzzyStringComparator,
TestFileValidation, packaging) to the load-bearing facts; no code changes.

Co-Authored-By: Claude Fable 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_014EBe4MJ3TQJxm4GVm4N42D

---------

Co-authored-by: Claude Fable 5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants