PdfFile/test: CMake wiring + fixture investigation - #105
Conversation
9f3a01c to
6acced3
Compare
|
🏓 for review. Will rebase and resolve conflicts before merging as every of the test prs conflicts |
6acced3 to
b994641
Compare
chrip
left a comment
There was a problem hiding this comment.
Summary
Migrates the qmake PdfFile/test/test.pro GoogleTest suite to a CMake/CTest target
(pdffile_test), registers it in the top-level EO_BUILD_TESTS block, adds a portable
non-Windows definition of the *_HRESULT_* assertion macros so it compiles on Linux/macOS,
and documents the missing-fixture situation in TESTING.md. Every factual claim in the PR
body (dependency→target mapping, the single non-skipped case, the fixture catalogue, the
gating strategy) was verified against the code at the head SHA and holds up. This is a
well-scoped, honestly-labelled "wiring + investigation" change: it gates the build/link/load
path for the suite but, by design, exercises no PdfFile production logic yet. CI is fully
green and a maintainer (@DmySyz) has already approved at the current head.
Verification
| Claim / Item | Reality (verified at head b994641) | Status |
|---|---|---|
add_core_gtest supports NAME/SOURCES/LIBS/GTEST_MAIN/GTEST_FILTER |
Defined common.cmake:380-436; exactly those options/args exist |
✓ |
GTEST_MAIN needed because test.cpp has no main() |
No int main in test.cpp; macro writes a bundled entry point |
✓ |
GTEST_FILTER "-CPdfFileTest.EditPdfFromBase64" |
Valid GoogleTest negative filter; passed as --gtest_filter= (common.cmake:422-423) |
✓ |
| All 6 deps map to existing CMake targets | UnicodeConverter→UnicodeConverter, Common→project(kernel), DesktopEditor/graphics/cmake→project(graphics), PdfFile→PdfFile, DjVuFile→DjVuFile, DesktopEditor/xmlsec/src→project(ooxmlsignature); all add_library(... SHARED) present |
✓ |
Every case self-skips except EditPdfFromBase64 |
25 TEST_F cases; 24 call GTEST_SKIP() first; EditPdfFromBase64 (test.cpp:531-533) has //GTEST_SKIP(); commented out |
✓ |
| That case would hard-fail headless | It runs LoadFromFile() (ASSERT_TRUE) + opens base64.txt; excluding it via filter is the reason |
✓ |
| HRESULT macros were the Linux compile blocker | EXPECT_HRESULT_SUCCEEDED used at test.cpp:285,293,331,739,747…; guarded by #ifndef so Windows (where gtest defines them) is unaffected |
✓ |
Registered after the existing four suites in EO_BUILD_TESTS |
Added at CMakeLists.txt:47, inside if(EO_BUILD_TESTS) after test_odf |
✓ |
New CMakeLists.txt follows repo convention |
Matches sibling test dirs (OOXML/test, OdfFile/Test/test_odf): cmake_minimum_required(3.10) → project() → CORE_ROOT_DIR → include(common.cmake) → if(NOT TARGET) guards → add_core_gtest() |
✓ |
| CI status | build (Windows x64), build (Linux), Build WASM, build-wasm, DCO — all SUCCESS | ✓ |
Issues & Suggestions
⚠️ Major
(none)
ℹ️ Minor / 💡 Suggestions
- Zero production-code coverage (by design, disclosed). After the filter, the suite is
24 self-skips + 1 excluded case, so it exercises no PdfFile logic — it is purely a
build/link/loader gate until fixtures land. The PR body andTESTING.mdstate this plainly,
so it is not a defect, but the coverage ceiling is worth keeping in mind: this PR's value is
"the suite compiles, links and runs green in CI", not "PdfFile is tested". EditPdfFromBase64self-consistency (test.cpp:531-533). The one hard-failing case is
suppressed only at the CTest layer viaGTEST_FILTER, while its in-sourceGTEST_SKIP()
stays commented out. Running the binary directly (outside ctest, or ctest with an overridden
filter) would still hit theASSERT_TRUEon the missingtest.pdf. Cleaner would be to
restoreGTEST_SKIP()in source like the other 24 cases (making the filter belt-and-braces),
though the commented marker doubles as a useful "enable this one first" pointer — discussable.- Commit 1 message not Conventional Commits.
PdfFile/test: CMake wiring + fixture investigationuses a path prefix, not a type; the repo convention isfix:/feat:/chore:/test:
(e.g. recentchore: cleanup code). Commit 2 (test: define HRESULT assertion macros…) is
fine. Considertest(PdfFile): …on a rebase. Non-blocking. - Rebase pending. The author already noted (2026-06-26) they will rebase to resolve
conflicts with the other test PRs before merge; PR currently reports MERGEABLE. No action now.
Verdict
Approve — every claim in the PR verifies against the code at head, the CMake/CTest wiring
and dependency mapping are correct and idiomatic for this repo, CI is green, and a maintainer
has already approved; the only open points are minor/discussable (net-zero coverage is
intentional and disclosed, the EditPdfFromBase64 filter-vs-source nit, and commit-1 message
style). Merge after the planned rebase.
Assisted-by: ClaudeCode:claude-opus-4-8
Add a CMakeLists.txt for PdfFile/test that mirrors the qmake test.pro ADD_DEPENDENCY line (UnicodeConverter, kernel, graphics, PdfFile, DjVuFile, ooxmlsignature) and builds the suite via add_core_gtest with GTEST_MAIN (test.cpp has no own main()). All six dependencies map to existing CMake library targets, so no dependency porting is required. The suite's runtime fixtures (test.pdf, base64.txt, pdf.bin, pfx.pfx, test.djvu, changes.bin, test.jpeg, resI/) are not committed to the repo. Every test case self-skips except CPdfFileTest.EditPdfFromBase64, which would hard-fail without test.pdf/base64.txt. That single case is excluded with GTEST_FILTER so the suite builds, links and runs green; the remaining cases report as skipped. Registered in the top-level EO_BUILD_TESTS block. Update TESTING.md: move PdfFile/test to Done with the full fixture catalogue (inputs vs intermediates vs outputs) and the exact steps to fully enable it. Signed-off-by: Julius Knorr <jus@bitgrid.net> Assisted-by: Claude Code:Opus 4.8
GoogleTest only defines EXPECT_HRESULT_SUCCEEDED/ASSERT_HRESULT_SUCCEEDED on Windows. The PdfFile suite uses them, so it failed to compile on the Linux CI build with "use of undeclared identifier 'EXPECT_HRESULT_SUCCEEDED'". Add portable definitions (HRESULT success is >= 0 on all platforms) so the suite compiles. The affected cases still GTEST_SKIP() at runtime pending fixtures. Signed-off-by: Julius Knorr <jus@bitgrid.net> Assisted-by: Claude Code:Opus 4.8
b994641 to
30bca00
Compare
Summary
Migrates the qmake
PdfFile/test/test.proGoogleTest suite to a CMake/CTest target and documents the fixture situation.PdfFile/test/CMakeLists.txt:project(pdffile_test),CORE_ROOT_DIR = ../..,include(common.cmake), guard-added deps,add_core_gtest(NAME pdffile_test SOURCES test.cpp LIBS ... GTEST_MAIN GTEST_FILTER ...).test.cpphas no ownmain(), soGTEST_MAINis used.CMakeLists.txtif(EO_BUILD_TESTS)block, after the existing four suites.TESTING.mdupdated with the full fixture catalogue and exact steps to fully enable.Dependencies
test.pro'sADD_DEPENDENCY(UnicodeConverter, kernel, graphics, PdfFile, DjVuFile, ooxmlsignature)maps cleanly to existing CMake targets — no dependency lacks a CMake target, so no library porting is needed:UnicodeConverterCommonDesktopEditor/graphics/cmakePdfFileDjVuFileDesktopEditor/xmlsec/srcGating decision
Registered live, but with one case excluded via
GTEST_FILTERto keep CI green.Every test case in
test.cppcallsGTEST_SKIP()at the top exceptCPdfFileTest.EditPdfFromBase64, whoseGTEST_SKIP()is commented out. That case callsLoadFromFile()(anASSERT_TRUEon loading the missingtest.pdf) and opensbase64.txt, so it would hard-fail headless. It is excluded withGTEST_FILTER "-CPdfFileTest.EditPdfFromBase64". The suite then builds, links and runs cleanly (remaining cases report as skipped), so it gates the build/link without turning CI red.Missing fixtures (none present anywhere in the repo)
Inputs:
test.pdf,base64.txt,pdf.bin,pfx.pfx(PKCS#12, password123456),test.djvu,changes.bin,test.jpeg(used byEditPdfSign; not in the original blocker list), and anresI/directory of reference PNGs forImgDiff.Intermediate:
ONLYOFFICEFORM.docxf(produced byGetMetaData, consumed bySetMetaData).Outputs (generated at runtime, not required inputs):
test2.pdf,test3.pdf,test_split.pdf,pdftemp/,resO/,resD/,fonts_cache/,resPdfBinToPng.png.To fully enable
Commit the input fixtures above, stage them next to the test binary (the suite reads from
NSFile::GetProcessDirectory(), so useWORKING_DIRECTORYplus aPOST_BUILD copy_directory), drop theGTEST_FILTER, and un-GTEST_SKIP()the desired cases.Build/CI note
There is no vcpkg toolchain locally (
VCPKG_ROOTunset), so this could not be fully configured/built here. The PR's CI is the gate: configure with-DVCPKG_MANIFEST_FEATURES=tests -DEO_BUILD_TESTS=ON, build, thenctest --output-on-failure.https://claude.ai/code/session_01TJrhgZT4PwYaBKWiUCXmGg
Generated by Claude Code