Skip to content

Enable test_odf gtest suite under CTest#106

Open
juliusknorr wants to merge 3 commits into
mainfrom
claude/enable-testodf-tests
Open

Enable test_odf gtest suite under CTest#106
juliusknorr wants to merge 3 commits into
mainfrom
claude/enable-testodf-tests

Conversation

@juliusknorr

Copy link
Copy Markdown
Member

Summary

Migrates the OdfFile/Test/test_odf GoogleTest suite from its legacy qmake .pro to a CMake target registered with CTest, following the existing migration patterns (add_core_gtest() helper, guard-added dependencies, fixture staging).

The .pro builds only test.cpp + common.cpp (the entrance/motion/audio/interactions modules are commented out), so the CMake target matches that exactly.

Changes

  • OdfFile/Test/test_odf/CMakeLists.txt (new): builds test_odf via add_core_gtest(). The suite owns its own main() (InitGoogleTest + AddGlobalTestEnvironment(new TestEnv) + RUN_ALL_TESTS), so no GTEST_MAIN. Links OdfFormatLib (provides ConvertODF2OOXml) plus kernel / graphics / UnicodeConverter, and compiles OfficeFileFormatChecker2.cpp, pole.cpp and unicode_util.cpp directly into the target — mirroring Test/Applications/x2tTester, which uses the same format-checker sources. (COfficeFileFormatChecker's heavy PPTFormatLib dependency is gated behind FILE_FORMAT_CHECKER_WITH_MACRO, which is not defined, so no extra chain is pulled in.) Adds the core root and X2tConverter/src to the include path.
  • Fixture staging: TestEnv::SetUp() runs convert_single("ExampleFiles/motion.odp") — a working-dir-relative path. The committed ExampleFiles/ (.odp/.pptx pairs) is staged via a POST_BUILD copy_directory next to the binary, and the test runs from that directory (WORKING_DIRECTORY), so ExampleFiles/motion.odp resolves.
  • OdfFile/Test/test_odf/common.cpp: the committed file had absolute Windows include paths (D:\ONLYOFFICE\core\...), #include <tchar.h>, and a per-platform #pragma comment(lib, ...) block — none of which build on Linux. These were replaced with repo-relative includes; libraries are now linked by CMake. No functional logic changed.
  • CMakeLists.txt: registers the suite in the if(EO_BUILD_TESTS) block.
  • TESTING.md: moves the suite to the Done list with notes.

Note: with the animation modules commented out, the built sources register no TEST() cases yet; the global TestEnv still exercises an .odp -> .pptx conversion in SetUp() (this matches the .pro's intended build).

Build / verification

There is no vcpkg toolchain available locally (VCPKG_ROOT unset), so this could not be fully built here; correctness was mirrored against the existing references (cfcpp/test, TestSMConverter, x2tTester, OdfFormatLib). CI is the gate: it configures with -DVCPKG_MANIFEST_FEATURES=tests -DEO_BUILD_TESTS=ON, builds, and runs ctest --output-on-failure.

The top-level CMakeLists.txt line is appended after the existing 4 migrated entries; conflicts there with sibling migration PRs are expected and trivial to resolve.

https://claude.ai/code/session_01TJrhgZT4PwYaBKWiUCXmGg


Generated by Claude Code

@juliusknorr juliusknorr requested a review from a team as a code owner June 12, 2026 18:13
@juliusknorr juliusknorr requested review from rikled and removed request for a team June 12, 2026 18:13
@juliusknorr juliusknorr force-pushed the claude/enable-testodf-tests branch 3 times, most recently from 59fb780 to 0f30208 Compare June 12, 2026 19:12
Migrate the OdfFile/Test/test_odf GoogleTest suite from its qmake .pro to a
CMake target registered with CTest, matching the .pro which builds only
test.cpp + common.cpp (entrance/motion/audio/interactions modules stay
commented out).

- Add OdfFile/Test/test_odf/CMakeLists.txt using the add_core_gtest() helper.
  The suite owns its main(), so no GTEST_MAIN. Link OdfFormatLib (provides
  ConvertODF2OOXml) plus kernel/graphics/UnicodeConverter, and compile
  OfficeFileFormatChecker2.cpp, pole.cpp and unicode_util.cpp into the target
  (mirroring Test/Applications/x2tTester, which uses the same format-checker
  sources). Add the core root and X2tConverter/src to the include path.
- Stage ExampleFiles/ next to the binary via a POST_BUILD copy_directory and
  run the test from that directory, since TestEnv loads the fixture through the
  working-dir-relative path "ExampleFiles/motion.odp".
- Fix common.cpp: the committed file used absolute Windows include paths
  (D:\ONLYOFFICE\core\...), <tchar.h>, and a per-platform
  "#pragma comment(lib, ...)" block, none of which build on Linux. Replace them
  with repo-relative includes; libraries are linked by CMake.
- Register the suite in the top-level CMakeLists.txt EO_BUILD_TESTS block and
  move it to the Done list in TESTING.md.

https: //claude.ai/code/session_01TJrhgZT4PwYaBKWiUCXmGg
Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: Claude Code:Opus 4.8
The standalone test_odf link failed with hundreds of undefined references from
libOdfFormatLib.a (XmlUtils::EncodeXmlString, SimpleTypes::*, OOX::WritingElement
/CPath, OOX::Logic math classes, PPTX::Namespaces). OdfFormatLib's ODF->OOXML
writer depends on the OOXML format code, but its CMake target only linked
kernel/UnicodeConverter -- those OOXML symbols were previously satisfied only
when everything was linked together inside x2tlib.

Declare DocxFormatLib and PPTXFormatLib (the OOXML format library targets that
compile that code) as PUBLIC dependencies of OdfFormatLib so it links standalone
and any consumer (e.g. the test_odf suite) resolves the symbols transitively.

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: Claude Code:Opus 4.8
The standalone test_odf link cascaded: OdfFormatLib needs the OOXML format libs,
which in turn need the XLS/XLSB libs, etc. Those static archives reference each
other and are only ever linked together inside x2tlib (the core libraries are
built with -fvisibility=hidden, so linking x2tlib.so cannot resolve the test's
direct ConvertODF2OOXml call).

Instead of partially wiring shared-library dependencies (reverted from
OdfFormatLib), instantiate the same target set via the x2tlib "library"
subdirectory and link the OOXML/MS format static archives inside a
--start-group, plus the shared converter libs -- mirroring x2tlib's own link.
OfficeFileFormatChecker2.cpp is compiled into the test (no format lib provides
it); unicode_util.cpp/pole.cpp are dropped since DocxFormatLib supplies them.

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: Claude Code:Opus 4.8
@juliusknorr juliusknorr force-pushed the claude/enable-testodf-tests branch from 0f30208 to 2f854ff Compare June 13, 2026 06:41
@juliusknorr juliusknorr requested review from a team and DmySyz and removed request for a team June 16, 2026 19:43
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.

2 participants