d38e1466da
canon add module <path> creates <stem>/<path>.hpp, .cpp and .test.cpp (--no-test skips the test), records the module in .canon.toml, adds the source to the project's target and re-renders the managed block of CMakeLists.txt. canon add unit-test adds the test later. Both work from any directory inside the project. - toml: a reader for the TOML subset canon writes, with line numbers in errors, so canon stays dependency-free - manifest: strict parsing (unknown keys, wrong types, bad references) - project: finds .canon.toml by walking up from the current directory - plan/executor: update_file refuses to write if the file changed after it was read, and the report skips directories that already exist - tests: shared scenarios drive both the golden and end-to-end tests; goldens now live in tests/golden/<scenario>/ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
37 lines
1.2 KiB
CMake
37 lines
1.2 KiB
CMake
# Runs each scenario from ../scenarios.cmake, then configures, builds and tests
|
|
# the resulting project with the given compiler. Proves generated projects
|
|
# work, not just that they look right.
|
|
#
|
|
# cmake -DCANON=<canon executable> -DWORK_DIR=<scratch dir> -DCXX=<compiler> -P check.cmake
|
|
|
|
cmake_minimum_required(VERSION 3.20)
|
|
|
|
foreach(var CANON WORK_DIR CXX)
|
|
if(NOT DEFINED ${var})
|
|
message(FATAL_ERROR "${var} is not set")
|
|
endif()
|
|
endforeach()
|
|
|
|
get_filename_component(WORK_DIR "${WORK_DIR}" ABSOLUTE)
|
|
include(${CMAKE_CURRENT_LIST_DIR}/../scenarios.cmake)
|
|
|
|
function(run)
|
|
execute_process(COMMAND ${ARGN}
|
|
RESULT_VARIABLE status
|
|
OUTPUT_VARIABLE output
|
|
ERROR_VARIABLE errors)
|
|
if(NOT status EQUAL 0)
|
|
string(JOIN " " command ${ARGN})
|
|
message(FATAL_ERROR "Command failed (${status}): ${command}\n${output}${errors}")
|
|
endif()
|
|
endfunction()
|
|
|
|
foreach(scenario ${CANON_SCENARIOS})
|
|
message(STATUS "e2e: ${scenario}")
|
|
canon_scenario(${scenario} ${WORK_DIR} project)
|
|
run(${CMAKE_COMMAND} -S ${project} -B ${project}/build
|
|
-DCMAKE_CXX_COMPILER=${CXX} -DCMAKE_BUILD_TYPE=Debug)
|
|
run(${CMAKE_COMMAND} --build ${project}/build)
|
|
run(${CMAKE_CTEST_COMMAND} --test-dir ${project}/build --output-on-failure)
|
|
endforeach()
|