include(gtest)

add_executable(
  repo-lens-test
  test_main.cpp
  navigation_test.cpp
  ../src/navigation.cpp
  ../src/process.cpp
  ../src/repo_tool_around.cpp
  ../src/repo_tool_find.cpp
  ../src/repo_tool_map.cpp
)

target_link_libraries(
  repo-lens-test
  gtest
)

if(ENABLE_ALL_REASONABLE_WARNINGS)
  target_enable_warnings(repo-lens-test)
endif()
if(ENABLE_WARNINGS_AS_ERRORS)
  target_warnings_as_errors(repo-lens-test)
endif()
if(ENABLE_SANITIZERS)
  target_enable_sanitizers(repo-lens-test)
  if(MSVC)
    # @ai-bookmark MSVC_SANITIZER_ANNOTATION_ALIGNMENT
    # MSVC STL sanitizer annotations must agree across linked translation units.
    foreach(_test_dependency IN ITEMS gtest gtest_main gmock gmock_main)
      target_enable_sanitizers(${_test_dependency})
    endforeach()
  endif()
endif()

include(GoogleTest)
gtest_discover_tests(repo-lens-test)

target_include_directories(repo-lens-test PRIVATE "${PROJECT_SOURCE_DIR}/include")
target_compile_definitions(repo-lens-test PRIVATE REPO_TEST_EXECUTABLE="$<TARGET_FILE:repo-lens-test>")
