cmake_minimum_required(VERSION 3.20)
# Fixture project for the framework-regression classifier in scripts/verify_linux.py.
#
# It reproduces the recorded framework CTest baseline shape -- two inherited
# failures plus three upstream-DISABLED tests -- and, per -DVARIANT, injects one
# additional category. The classifier must PASS only the baseline variant.
#
# The old classifier matched the literal "(Failed)" summary line, so SEGFAULT,
# Timeout and a missing executable all yielded "no unexpected failures" and were
# reported as a PASS. These variants exist so that cannot regress silently.
project(ctest_regression_fixture NONE)
include(CTest)
enable_testing()
set(VARIANT "baseline" CACHE STRING "baseline|newfail|crash|timeout|missingexe|zerotests")

if(NOT VARIANT STREQUAL "zerotests")
  add_test(NAME pass_test COMMAND ${CMAKE_COMMAND} -E true)
  # Names must match INHERITED_CTEST_FAILURES in scripts/verify_linux.py.
  add_test(NAME dirty_text_continuation_guards COMMAND ${CMAKE_COMMAND} -E false)
  add_test(NAME aot_overlay_discovery COMMAND ${CMAKE_COMMAND} -E false)
  # Must match INHERITED_CTEST_DISABLED.
  foreach(disabled_test interpreter_perf_guards runtime_perf_diag_guards
                        overlay_pair_dedup_runtime)
    add_test(NAME ${disabled_test} COMMAND ${CMAKE_COMMAND} -E true)
    set_tests_properties(${disabled_test} PROPERTIES DISABLED TRUE)
  endforeach()
endif()

if(VARIANT STREQUAL "newfail")
  add_test(NAME brand_new_failure COMMAND ${CMAKE_COMMAND} -E false)
elseif(VARIANT STREQUAL "crash")
  add_test(NAME crashing_test COMMAND sh -c "kill -SEGV $$")
elseif(VARIANT STREQUAL "timeout")
  add_test(NAME hanging_test COMMAND ${CMAKE_COMMAND} -E sleep 60)
  set_tests_properties(hanging_test PROPERTIES TIMEOUT 3)
elseif(VARIANT STREQUAL "missingexe")
  add_test(NAME missing_binary_test COMMAND /nonexistent/binary)
endif()
