# The CLI parser joins the core here: it is GUI-free too, and the canvas size
# it produces has to obey the same bounds a project file does.
add_executable(effector_tests core_tests.cpp ../src/cli/options.cpp)
target_link_libraries(effector_tests PRIVATE effector_core)
target_compile_options(effector_tests PRIVATE -Wall -Wextra -Wpedantic)

add_test(NAME core COMMAND effector_tests)

# The interface drives the real window, so it needs a display. Under ctest it
# gets a private Xvfb one when xvfb-run is installed; without it, or without a
# display of its own, the test reports itself skipped rather than failed.
add_executable(effector_gui_tests gui_tests.cpp)
target_link_libraries(effector_gui_tests PRIVATE effector_gui)
target_compile_options(effector_gui_tests PRIVATE -Wall -Wextra -Wpedantic)

find_program(XVFB_RUN xvfb-run)
if(XVFB_RUN)
    add_test(NAME gui COMMAND ${XVFB_RUN} -a -s "-screen 0 1400x900x24"
             env -u WAYLAND_DISPLAY GDK_BACKEND=x11 $<TARGET_FILE:effector_gui_tests>)
else()
    add_test(NAME gui COMMAND effector_gui_tests)
endif()
set_tests_properties(gui PROPERTIES SKIP_RETURN_CODE 77)
