Files
aevolution/tests/cli_integration.cmake
T
dingoandClaude Opus 5 d5b4bd068e Initial commit: architecture docs and headless engineering proof
Aeternalis Evolution, a custom-engine persistent evolutionary MMO.

This first commit establishes the project skeleton:

- Architecture and design docs: project vision, system overview,
  engineering constitution, roadmap, 19 ADRs, and the simulation,
  world, network, persistence and infrastructure architectures.
- Headless engineering proof: deterministic synthetic particles,
  component lifecycle, explicit PRNG streams, canonical snapshots
  and restored execution.
- Build and tooling: CMake 3.28+ / Ninja presets, C++23 feature
  check, clang-format and clang-tidy config, format check script,
  Windows check script, and a Docker build context.
- Tests: unit tests, benchmarks, a snapshot fuzz target and CLI
  integration wiring.

No gameplay, renderer, network service or running deployment yet.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 15:44:41 -04:00

63 lines
2.8 KiB
CMake

if(NOT DEFINED EVO_SIM OR NOT DEFINED TEST_DIR)
message(FATAL_ERROR "EVO_SIM and TEST_DIR are required")
endif()
# Fresh build-local files each run; no recursive deletion or source-tree writes.
string(RANDOM LENGTH 16 ALPHABET 0123456789abcdef run_id)
set(run_dir "${TEST_DIR}/${run_id}")
file(MAKE_DIRECTORY "${run_dir}")
function(expect_success)
execute_process(COMMAND "${EVO_SIM}" ${ARGN}
RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error)
if(NOT result EQUAL 0)
message(FATAL_ERROR "CLI failed (${result}): ${error}")
endif()
endfunction()
function(expect_failure)
execute_process(COMMAND "${EVO_SIM}" ${ARGN}
RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error)
if(NOT result MATCHES "^[1-9][0-9]*$")
message(FATAL_ERROR "Expected normal nonzero CLI exit, got ${result}: ${output} ${error}")
endif()
endfunction()
expect_success(--seed 123456 --entities 8 --ticks 500 --save "${run_dir}/half.evo")
expect_success(--load "${run_dir}/half.evo" --ticks 500 --save "${run_dir}/resumed.evo"
--output "${run_dir}/report.json" --metrics "${run_dir}/metrics.prom")
expect_success(--seed 123456 --entities 8 --ticks 1000 --verify-replay
--save "${run_dir}/full.evo")
file(SHA256 "${run_dir}/resumed.evo" resumed_digest)
file(SHA256 "${run_dir}/full.evo" full_digest)
if(NOT resumed_digest STREQUAL full_digest)
message(FATAL_ERROR "CLI continuation differs from uninterrupted simulation")
endif()
file(READ "${run_dir}/report.json" report)
string(JSON state_hash GET "${report}" state_hash)
string(JSON tick GET "${report}" ticks)
if(NOT state_hash STREQUAL "d61ad5bf0c928c76" OR NOT tick EQUAL 1000)
message(FATAL_ERROR "CLI report does not match independent frozen fixture")
endif()
file(READ "${run_dir}/metrics.prom" metrics)
if(NOT metrics MATCHES "evo_active_entities 8" OR NOT metrics MATCHES "evo_simulation_tick 1000")
message(FATAL_ERROR "Missing or wrong metrics")
endif()
file(WRITE "${run_dir}/sentinel" "preserve this file")
execute_process(COMMAND "${CMAKE_COMMAND}" -E create_hardlink
"${run_dir}/sentinel" "${run_dir}/alias" RESULT_VARIABLE linked)
if(NOT linked EQUAL 0)
message(FATAL_ERROR "Hard-link regression fixture could not be created")
endif()
expect_failure(--ticks 0 --save "${run_dir}/sentinel" --output "${run_dir}/alias")
expect_failure(--load "${run_dir}/sentinel" --output "${run_dir}/alias")
file(READ "${run_dir}/sentinel" preserved)
if(NOT preserved STREQUAL "preserve this file")
message(FATAL_ERROR "CLI overwrote an aliased input/output")
endif()
expect_failure(--load "${run_dir}/half.evo" --seed 123)
expect_failure(--entities 100001)
expect_failure(--ticks 18446744073709551616)
expect_failure(--unknown value)
expect_failure(--load "${run_dir}/missing")
expect_success(--entities 0 --ticks 2 --verify-replay)