Skip to content

Enable doctrenderer (V8) gtest suites under CTest#104

Open
juliusknorr wants to merge 2 commits into
mainfrom
claude/enable-doctrenderer-tests
Open

Enable doctrenderer (V8) gtest suites under CTest#104
juliusknorr wants to merge 2 commits into
mainfrom
claude/enable-doctrenderer-tests

Conversation

@juliusknorr

Copy link
Copy Markdown
Member

Summary

Migrates the three doctrenderer GoogleTest suites from legacy qmake .pro files to CMake targets registered with CTest, in one PR. Each gets a CMakeLists.txt modeled on the existing TestSMConverter reference and the shared add_core_gtest() helper.

Suite Target Define Own main()? GTEST_MAIN
test/json doctrenderer_json_test JSON_GOOGLE_TEST compiled out under the define yes
test/js_internal doctrenderer_jsinternal_test JS_INTERNAL_GOOGLE_TEST compiled out under the define yes
test/embed/internal/hash doctrenderer_hash_test none none yes

For json and js_internal, main.cpp guards its int main() behind #ifndef <SUITE>_GOOGLE_TEST — so with the define active there is no own main(), hence GTEST_MAIN. The hash suite has no main() and no google-test define, so it also uses GTEST_MAIN.

Each suite:

  • guard-adds the existing doctrenderer shared library via if(NOT TARGET doctrenderer) add_subdirectory(...) endif();
  • mirrors the .pro INCLUDEPATH (DesktopEditor/doctrenderer) via target_include_directories;
  • mirrors DEFINES via target_compile_definitions;
  • on Linux reproduces -Wl,-unresolved-symbols=ignore-in-shared-libs and -ldl via target_link_options / target_link_libraries.

All three are registered in the top-level CMakeLists.txt if(EO_BUILD_TESTS) block, and TESTING.md is updated (the three entries moved to Done with a V8-runtime note).

V8 runtime decision: registered normally (CI-gated)

These suites instantiate CJSContext (a V8 isolate) at test time, so they need a working V8 runtime. I investigated whether that is reliably satisfiable in CI and concluded yes, so the add_subdirectory lines are registered normally (not commented out):

  • common.cmake builds the V8 monolith via build_3rdparty.py and populates V8_INSTALL_DIR; CI configures with -DVCPKG_MANIFEST_FEATURES=tests -DEO_BUILD_TESTS=ON and builds before ctest.
  • The x64-linux V8 build (Common/3dParty/v8/.../nc-build.sh) sets v8_use_external_startup_data=false (startup snapshot is linked into the monolith, no external snapshot_blob.bin) and v8_enable_i18n_support=false (no external icudtl.dat). So CJSContext initializes with no external V8 runtime data files staged next to the binary.
  • The doctrenderer shared library is already built in CI (the docbuilder app links it), so no new library provisioning is required.
  • The suites build all their JS inline via runScript(...) and load no embedded-script or fixture files.

Build / verify note

cmake + ninja are present locally but there is no vcpkg toolchain (VCPKG_ROOT unset), so a full local build is not possible and I did not bootstrap vcpkg. The CMake wiring mirrors the proven TestSMConverter / TestEQNtoOOXML references; the PR's CI (configure with the tests feature + EO_BUILD_TESTS=ON, build, ctest --output-on-failure) is the gate.

Residual uncertainty

The V8 self-containment conclusion is read from the build flags rather than observed at runtime locally. If CI surfaces an unexpected external-data dependency, the fix would be to stage that data next to the test binaries (or point WORKING_DIRECTORY), not to change the test wiring.

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:12
@juliusknorr juliusknorr requested review from Aiiaiiio and removed request for a team June 12, 2026 18:12
@juliusknorr juliusknorr force-pushed the claude/enable-doctrenderer-tests branch 2 times, most recently from c2d9edf to 2828d5d Compare June 12, 2026 19:06
@juliusknorr juliusknorr requested review from a team and rikled and removed request for a team June 16, 2026 19:43
Migrate the three doctrenderer GoogleTest suites from qmake .pro files to
CMake targets registered with CTest:

- DesktopEditor/doctrenderer/test/json (JSON_GOOGLE_TEST)
- DesktopEditor/doctrenderer/test/js_internal (JS_INTERNAL_GOOGLE_TEST)
- DesktopEditor/doctrenderer/test/embed/internal/hash

Each suite links the existing doctrenderer shared library (guard-added via
add_subdirectory) and builds through the add_core_gtest() helper. json and
js_internal compile out their own main() under their *_GOOGLE_TEST define, and
hash has none, so all three use GTEST_MAIN. Per-suite compile definitions and
include dirs mirror the .pro DEFINES/INCLUDEPATH; on Linux the unresolved-
symbols link flag and -ldl are reproduced.

The suites instantiate CJSContext (V8). The V8 monolith built in CI is self-
contained at run time (v8_use_external_startup_data=false, embedded snapshot;
v8_enable_i18n_support=false, no external icudtl.dat), and all test JS is built
inline via runScript with no fixtures, so the suites run headless in CI without
extra provisioning. Registered in the top-level CMakeLists EO_BUILD_TESTS block
and documented in TESTING.md.

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: Claude Code:Opus 4.8
Two test sources failed to compile in the Linux CI build:

- json/main.cpp referenced the NSJSON::ImageFormat enumerators (ifBGRA, ifRGBA,
  ifARGB, ifInvalid) unqualified, but ImageFormat is an `enum class`. Add
  in-scope constexpr aliases so the image tests compile.
- embed/internal/hash/main.cpp used std::setw/std::setfill without including
  <iomanip>. Add the include.

Signed-off-by: Julius Knorr <jus@bitgrid.net>
Assisted-by: Claude Code:Opus 4.8
@juliusknorr juliusknorr force-pushed the claude/enable-doctrenderer-tests branch from 2828d5d to 78771ee Compare June 30, 2026 20:35
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