From 247d1034b0ecad5bb63381554e681e40566f8c8e Mon Sep 17 00:00:00 2001 From: daniel-c-harvey Date: Mon, 27 Jul 2026 22:59:08 -0400 Subject: [PATCH] fix(comments): correct canary justification and expand failure guidance in padding tests --- CMakeLists.txt | 18 +++++++++--------- tests/test_app_version_padding.cpp | 17 +++++++++-------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 163807f..b50cece 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -604,15 +604,15 @@ target_link_libraries(app_version_tests PRIVATE app_version) add_test(NAME app_version_tests COMMAND app_version_tests) # Anti-normalization padding canary (see tests/test_app_version_padding.cpp for the full -# rationale). The live-version assertions in app_version_tests can only DETECT a -# "reconstruct the string from numeric components" regression when the live version -# happens to be zero-padded — at an unpadded version (e.g. 0.9.8) the reconstruction -# coincides with the verbatim string and the check silently goes vacuous. So: run the -# SAME version_generated.h.in template through configure_file a second time with a -# SYNTHETIC padded version, and compile the SAME src/app_version.cpp against that header -# (include-dir substitution — the canary target never sees the live generated/ dir). -# The "0.9.01" here is a permanent test fixture, NOT the shipped version (see also the -# source-of-truth comment at the top of this file for the live-version invariant); it +# rationale). The live-version assertions in app_version_tests are version-shape-blind: +# relative checks (e.g. appVersion() == stampVersion()) hold whether the string was +# threaded verbatim or reconstructed from numeric components, at any version, padded or +# not — the live suite cannot detect a reconstruct-from-components regression at all. +# So: run the SAME version_generated.h.in template through configure_file a second time +# with a SYNTHETIC padded version, and compile the SAME src/app_version.cpp against that +# header (include-dir substitution — the canary target never sees the live generated/ +# dir). The "0.9.01" here is a permanent test fixture, NOT the shipped version (see also +# the source-of-truth comment at the top of this file for the live-version invariant); it # must match the literals in test_app_version_padding.cpp and must never be bumped on # release. # diff --git a/tests/test_app_version_padding.cpp b/tests/test_app_version_padding.cpp index 1b49066..4e89dfd 100644 --- a/tests/test_app_version_padding.cpp +++ b/tests/test_app_version_padding.cpp @@ -2,11 +2,10 @@ // string threading (Phase V, V1 leading-zero fidelity). No REAPER, no framework. // // WHY THIS EXECUTABLE EXISTS: test_app_version.cpp pins stampVersion() relative to the -// live configure_file'd version string — but a live-version assertion can only DETECT a -// "reconstruct the string from numeric components" regression when the live version -// happens to be zero-padded. "0.9.01" reconstructed via integers renders "0.9.1" and -// trips it; "0.9.8" reconstructs to itself, so at an unpadded version the check passes -// whether or not the code regressed — the guard silently goes vacuous while green. +// live configure_file'd version string — but a relative assertion (e.g. appVersion() == +// stampVersion()) is version-shape-blind: it holds whether the string was threaded +// verbatim or reconstructed from numeric components, at any version, padded or not. +// The live suite therefore cannot detect a reconstruct-from-components regression at all. // Padded and unpadded versions are both legitimate (Daniel's ruling), so the guard must // not depend on the shipped version's shape. // @@ -67,9 +66,11 @@ static void testCanaryFixtureIsNonVacuous() { std::to_string(wv.parsed.major) + "." + std::to_string(wv.parsed.minor) + "." + std::to_string(wv.parsed.patch); - // If this fails, the fixture is unpadded and the canary guards nothing. - // Restore a zero-padded fixture (e.g. "0.9.01") in CMakeLists.txt and - // update the matching literals in this file. + // If this fails, one of two causes: (1) the fixture was changed to an unpadded form + // (e.g. "0.9.1") — restore a zero-padded fixture (e.g. "0.9.01") in CMakeLists.txt + // and update the matching literals in this file; or (2) the fixture is still padded + // but app_version.cpp regressed to parse-and-reprint — in that case + // testPaddedVersionSurvivesThreadingVerbatim also fails, pointing at the real cause. CHECK(reprinted != stampVersion()); }