diff --git a/CMakeLists.txt b/CMakeLists.txt index ca498cfeab..a718ee80ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,16 @@ else() add_subdirectory( "${CORE_ROOT_DIR}/OfficeUtils/tests" officeutils_test ) add_subdirectory( "${CORE_ROOT_DIR}/OdfFile/Reader/Converter/SMCustomShape2OOXML/TestSMCustomShape" starmath_smcustomshape_test ) add_subdirectory( "${CORE_ROOT_DIR}/OdfFile/Test/test_odf" test_odf ) + + # doctrenderer (V8) gtest suites. The V8 monolith is built in CI by + # common.cmake (build_3rdparty.py) and is self-contained at run time: + # the x64-linux build sets v8_use_external_startup_data=false (snapshot + # embedded in the monolith) and v8_enable_i18n_support=false (no external + # icudtl.dat), so CJSContext initializes with no external runtime data + # files. These suites build all JS inline via runScript() — no fixtures. + add_subdirectory( "${CORE_ROOT_DIR}/DesktopEditor/doctrenderer/test/json" doctrenderer_json_test ) + add_subdirectory( "${CORE_ROOT_DIR}/DesktopEditor/doctrenderer/test/js_internal" doctrenderer_jsinternal_test ) + add_subdirectory( "${CORE_ROOT_DIR}/DesktopEditor/doctrenderer/test/embed/internal/hash" doctrenderer_hash_test ) endif() endif() diff --git a/DesktopEditor/doctrenderer/test/embed/internal/hash/CMakeLists.txt b/DesktopEditor/doctrenderer/test/embed/internal/hash/CMakeLists.txt new file mode 100644 index 0000000000..102254da97 --- /dev/null +++ b/DesktopEditor/doctrenderer/test/embed/internal/hash/CMakeLists.txt @@ -0,0 +1,36 @@ +cmake_minimum_required(VERSION 3.10) + +project(doctrenderer_hash_test) + +# test/embed/internal/hash is 6 levels under the core root. +set(CORE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../../../..") + +include(${CORE_ROOT_DIR}/common.cmake) + +# Dependencies (mirror ADD_DEPENDENCY(doctrenderer) in test.pro). +if(NOT TARGET doctrenderer) + add_subdirectory(${CORE_ROOT_DIR}/DesktopEditor/doctrenderer doctrenderer) +endif() + +# main.cpp has no int main() of its own (no *_GOOGLE_TEST guard) -> use GTEST_MAIN. +# No extra google-test define for this suite. +add_core_gtest( + NAME doctrenderer_hash_test + SOURCES main.cpp + LIBS doctrenderer + GTEST_MAIN +) + +# INCLUDEPATH += $$CORE_ROOT_DIR/DesktopEditor/doctrenderer +# (for embed/Default.h, hash.h, js_internal/js_base.h) +target_include_directories(doctrenderer_hash_test PRIVATE + ${CORE_ROOT_DIR}/DesktopEditor/doctrenderer +) + +# core_linux { LIBS += -Wl,-unresolved-symbols=ignore-in-shared-libs -ldl } +if(LINUX) + target_link_options(doctrenderer_hash_test PRIVATE + "-Wl,-unresolved-symbols=ignore-in-shared-libs" + ) + target_link_libraries(doctrenderer_hash_test PRIVATE dl) +endif() diff --git a/DesktopEditor/doctrenderer/test/embed/internal/hash/main.cpp b/DesktopEditor/doctrenderer/test/embed/internal/hash/main.cpp index 32e3b4883a..fb68d4bd48 100644 --- a/DesktopEditor/doctrenderer/test/embed/internal/hash/main.cpp +++ b/DesktopEditor/doctrenderer/test/embed/internal/hash/main.cpp @@ -1,6 +1,7 @@ #include "gtest/gtest.h" #include +#include #include #include "embed/Default.h" diff --git a/DesktopEditor/doctrenderer/test/js_internal/CMakeLists.txt b/DesktopEditor/doctrenderer/test/js_internal/CMakeLists.txt new file mode 100644 index 0000000000..c51a7506b4 --- /dev/null +++ b/DesktopEditor/doctrenderer/test/js_internal/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.10) + +project(doctrenderer_jsinternal_test) + +# test/js_internal is 4 levels under the core root. +set(CORE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../..") + +include(${CORE_ROOT_DIR}/common.cmake) + +# Dependencies (mirror ADD_DEPENDENCY(doctrenderer) in test.pro). +if(NOT TARGET doctrenderer) + add_subdirectory(${CORE_ROOT_DIR}/DesktopEditor/doctrenderer doctrenderer) +endif() + +# main.cpp guards its own int main() behind #ifndef JS_INTERNAL_GOOGLE_TEST, so +# with the define active the suite has no main() of its own -> use GTEST_MAIN. +add_core_gtest( + NAME doctrenderer_jsinternal_test + SOURCES main.cpp + LIBS doctrenderer + GTEST_MAIN +) + +# CONFIG += js_internal_google_test -> DEFINES += JS_INTERNAL_GOOGLE_TEST +target_compile_definitions(doctrenderer_jsinternal_test PRIVATE + JS_INTERNAL_GOOGLE_TEST +) + +# INCLUDEPATH += ../.. (the doctrenderer source root, for js_internal/js_base.h etc.) +target_include_directories(doctrenderer_jsinternal_test PRIVATE + ${CORE_ROOT_DIR}/DesktopEditor/doctrenderer +) + +# core_linux { LIBS += -Wl,-unresolved-symbols=ignore-in-shared-libs -ldl } +if(LINUX) + target_link_options(doctrenderer_jsinternal_test PRIVATE + "-Wl,-unresolved-symbols=ignore-in-shared-libs" + ) + target_link_libraries(doctrenderer_jsinternal_test PRIVATE dl) +endif() diff --git a/DesktopEditor/doctrenderer/test/json/CMakeLists.txt b/DesktopEditor/doctrenderer/test/json/CMakeLists.txt new file mode 100644 index 0000000000..e52b450207 --- /dev/null +++ b/DesktopEditor/doctrenderer/test/json/CMakeLists.txt @@ -0,0 +1,40 @@ +cmake_minimum_required(VERSION 3.10) + +project(doctrenderer_json_test) + +# test/json is 4 levels under the core root. +set(CORE_ROOT_DIR "${CMAKE_CURRENT_LIST_DIR}/../../../..") + +include(${CORE_ROOT_DIR}/common.cmake) + +# Dependencies (mirror ADD_DEPENDENCY(doctrenderer) in test.pro). +if(NOT TARGET doctrenderer) + add_subdirectory(${CORE_ROOT_DIR}/DesktopEditor/doctrenderer doctrenderer) +endif() + +# main.cpp guards its own int main() behind #ifndef JSON_GOOGLE_TEST, so with +# the define active the suite has no main() of its own -> use GTEST_MAIN. +add_core_gtest( + NAME doctrenderer_json_test + SOURCES main.cpp + LIBS doctrenderer + GTEST_MAIN +) + +# CONFIG += json_google_test -> DEFINES += JSON_GOOGLE_TEST +target_compile_definitions(doctrenderer_json_test PRIVATE + JSON_GOOGLE_TEST +) + +# INCLUDEPATH += ../.. (the doctrenderer source root, for json/serialization.h etc.) +target_include_directories(doctrenderer_json_test PRIVATE + ${CORE_ROOT_DIR}/DesktopEditor/doctrenderer +) + +# core_linux { LIBS += -Wl,-unresolved-symbols=ignore-in-shared-libs -ldl } +if(LINUX) + target_link_options(doctrenderer_json_test PRIVATE + "-Wl,-unresolved-symbols=ignore-in-shared-libs" + ) + target_link_libraries(doctrenderer_json_test PRIVATE dl) +endif() diff --git a/DesktopEditor/doctrenderer/test/json/main.cpp b/DesktopEditor/doctrenderer/test/json/main.cpp index e5c6a0e52d..cfe3eed369 100644 --- a/DesktopEditor/doctrenderer/test/json/main.cpp +++ b/DesktopEditor/doctrenderer/test/json/main.cpp @@ -13,6 +13,14 @@ using namespace NSJSON; #ifdef JSON_GOOGLE_TEST +// NSJSON::ImageFormat is an `enum class`, so its enumerators are not visible +// unqualified. These tests reference them bare (e.g. `ifBGRA`); bring them into +// scope so the suite compiles. +static constexpr ImageFormat ifRGBA = ImageFormat::ifRGBA; +static constexpr ImageFormat ifBGRA = ImageFormat::ifBGRA; +static constexpr ImageFormat ifARGB = ImageFormat::ifARGB; +static constexpr ImageFormat ifInvalid = ImageFormat::ifInvalid; + class CJSONTest : public testing::Test { public: diff --git a/TESTING.md b/TESTING.md index 4835b8aff1..35ca8376d6 100644 --- a/TESTING.md +++ b/TESTING.md @@ -98,6 +98,23 @@ Done: `ExampleFiles/motion.odp` is working-dir-relative). The committed `common.cpp` had absolute Windows include paths and a `#pragma comment(lib, ...)` block; these were replaced with repo-relative includes (CMake links the libraries). +- [x] `DesktopEditor/doctrenderer/test/json` — dep: doctrenderer (V8). Define + `JSON_GOOGLE_TEST`; own `main()` is compiled out under that define, so `GTEST_MAIN`. + No fixtures (JS built inline via `runScript`). +- [x] `DesktopEditor/doctrenderer/test/js_internal` — dep: doctrenderer (V8). Define + `JS_INTERNAL_GOOGLE_TEST`; own `main()` is compiled out under that define, so + `GTEST_MAIN`. No fixtures. +- [x] `DesktopEditor/doctrenderer/test/embed/internal/hash` — dep: doctrenderer (V8). No + google-test define; no own `main()`, so `GTEST_MAIN`. No fixtures. + + **V8 runtime requirement (satisfied in CI):** these three suites instantiate + `CJSContext`, which initializes a V8 isolate. The V8 monolith is built in CI by + `common.cmake` (`build_3rdparty.py`, populating `V8_INSTALL_DIR`) and is self-contained + at run time: the x64-linux V8 build sets `v8_use_external_startup_data=false` (startup + snapshot is linked into the monolith) and `v8_enable_i18n_support=false` (no external + `icudtl.dat`), so no external V8 runtime data files need to be staged next to the test + binaries. The `doctrenderer` shared library these suites link is already built in CI + (the `docbuilder` app links it), so the suites run headless without extra provisioning. ### gtest suites to migrate @@ -110,10 +127,6 @@ Blocked / need extra work (build targets intentionally not created yet): - [ ] `PdfFile/test` — **fixtures not in repo** (`test.pdf`, `pdf.bin`, `base64.txt`, `pfx.pfx`, `test.djvu`, `changes.bin`, fonts). Needs fixtures committed before it can pass headless. -- [ ] `DesktopEditor/doctrenderer/test/json` -- [ ] `DesktopEditor/doctrenderer/test/js_internal` -- [ ] `DesktopEditor/doctrenderer/test/embed/internal/hash` — the three doctrenderer suites - need a **V8 JS runtime** (and embedded scripts) at run time. - [ ] `DesktopEditor/xmlsec/src/osign/test` — **no `osign` CMake target exists**; the library must be ported to CMake first.