# SPDX-License-Identifier: GPL-3.0-or-later
# SPDX-FileCopyrightText: 2025 ai-ad4 and the FreePDFEditor contributors
# test/CMakeLists.txt
#
# Unit and gate tests. The M0 scaffold ships a single smoke test that proves
# the build produces a runnable artefact and the spike runner emits the
# contract JSON the CI pipeline parses. As the layers land (L1–L6), each gets
# its own test executable under here, all registered with CTest.

# We do not pull GoogleTest yet — the first tests are plain freestanding mains
# returning non-zero on failure, which keeps the M0 scaffold dependency-free
# and lets CI on all three platforms run ctest without a vcpkg build of gtest.
# A later milestone swaps in GTest once there is real C++ logic to assert on.

add_executable(test_spike_runner_contract test_spike_runner_contract.cpp
    ../spike/common/SpikeRunner.cpp)
target_include_directories(test_spike_runner_contract PRIVATE
    ${CMAKE_SOURCE_DIR}/spike)
target_compile_features(test_spike_runner_contract PRIVATE cxx_std_20)
freepdfeditor_apply_warnings(test_spike_runner_contract)
freepdfeditor_apply_hardening(test_spike_runner_contract)
add_test(NAME spike_runner_contract COMMAND test_spike_runner_contract)

# Pixel-diff harness scaffolding (§8.2 gate: render vs Ghostscript+PDFium
# reference). The actual comparison runs against a corpus that lives in the
# separate freepdfeditor-corpus repo (§13.2 rule 5); this scaffold is a
# self-contained Python script that CI invokes with paths to the corpus and
# the reference binaries.
install(FILES  "${CMAKE_CURRENT_SOURCE_DIR}/../ci/pixel-diff/run_pixel_diff.py"
        DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/freepdfeditor/ci")