From 11a48da5f8003fa2e25d6953eae5a19d4dd5216a Mon Sep 17 00:00:00 2001 From: sean-parent Date: Wed, 18 Nov 2026 19:30:37 -0800 Subject: [PATCH 1/2] style: format record adapter declarations and tests Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- include/cel/runtime/value.hpp | 9 +++++---- tests/segment_test.cpp | 36 ++++++++++++++++++----------------- tests/value_test.cpp | 24 +++++++++++++---------- 3 files changed, 38 insertions(+), 31 deletions(-) diff --git a/include/cel/runtime/value.hpp b/include/cel/runtime/value.hpp index bd73ceb..69d8e8e 100644 --- a/include/cel/runtime/value.hpp +++ b/include/cel/runtime/value.hpp @@ -40,9 +40,9 @@ template struct concrete_adapter; template concept nominal_record_adapter = requires(const T& input, const value& encoded) { - { record_adapter::type() } -> std::same_as; - { record_adapter::to_value(input) } -> std::same_as; - { record_adapter::from_value(encoded) } -> std::same_as; + {record_adapter::type()}->std::same_as; + {record_adapter::to_value(input)}->std::same_as; + {record_adapter::from_value(encoded)}->std::same_as; }; template struct boundary_adapter; @@ -573,7 +573,8 @@ struct boundary_adapter { const auto& expected = adapter_record_type(); auto encoded = record_adapter::to_value(source); if (!encoded.type().compatible_with(expected)) - throw std::invalid_argument("record adapter returned the wrong nominal record type"); + throw std::invalid_argument( + "record adapter returned the wrong nominal record type"); return encoded; } else { return concrete_adapter::from(source); diff --git a/tests/segment_test.cpp b/tests/segment_test.cpp index b8140d5..87bfdfb 100644 --- a/tests/segment_test.cpp +++ b/tests/segment_test.cpp @@ -93,16 +93,14 @@ const cel::value_type& foreign_callable_type() { /// Returns the declared nominal record descriptor with the primary callable ownership pair. const cel::value_type& declared_ownership_gap_type() { static const auto descriptor = cel::value_type::record( - "tests.ownership_gap", - std::array{cel::record_field{"code", primary_callable_type()}}); + "tests.ownership_gap", std::array{cel::record_field{"code", primary_callable_type()}}); return descriptor; } /// Returns a same-shape nominal record descriptor with incompatible callable ownership. const cel::value_type& foreign_ownership_gap_type() { static const auto descriptor = cel::value_type::record( - "tests.ownership_gap", - std::array{cel::record_field{"code", foreign_callable_type()}}); + "tests.ownership_gap", std::array{cel::record_field{"code", foreign_callable_type()}}); return descriptor; } @@ -129,20 +127,22 @@ template <> struct record_adapter { /// Returns the complete nested descriptor. static value_type type() { - static const auto descriptor = - value_type::record("tests.segment_bounds", - std::array{record_field{"width", value_type::leaf()}, - record_field{"height", value_type::leaf()}}); + static const auto descriptor = value_type::record( + "tests.segment_bounds", std::array{record_field{"width", value_type::leaf()}, + record_field{"height", value_type::leaf()}}); return descriptor; } /// Encodes one nested record value. static value to_value(const segment_bounds& source) { - return value::record(type(), std::array{value::from(source.width), value::from(source.height)}); + return value::record(type(), + std::array{value::from(source.width), value::from(source.height)}); } /// Decodes one nested record value. static segment_bounds from_value(const value& source) { - if (!source.type().same_shape(type())) throw std::invalid_argument("wrong segment bounds type"); - return {.width = source.field("width").as(), .height = source.field("height").as()}; + if (!source.type().same_shape(type())) + throw std::invalid_argument("wrong segment bounds type"); + return {.width = source.field("width").as(), + .height = source.field("height").as()}; } }; @@ -150,10 +150,10 @@ template <> struct record_adapter { /// Returns the complete nominal descriptor. static value_type type() { - static const auto descriptor = - value_type::record("tests.segment_widget", - std::array{record_field{"enabled", value_type::leaf()}, - record_field{"bounds", record_adapter::type()}}); + static const auto descriptor = value_type::record( + "tests.segment_widget", + std::array{record_field{"enabled", value_type::leaf()}, + record_field{"bounds", record_adapter::type()}}); return descriptor; } /// Encodes one nominal record value. @@ -163,7 +163,8 @@ struct record_adapter { } /// Decodes one nominal record value. static segment_widget from_value(const value& source) { - if (!source.type().same_shape(type())) throw std::invalid_argument("wrong segment widget type"); + if (!source.type().same_shape(type())) + throw std::invalid_argument("wrong segment widget type"); return {.enabled = source.field("enabled").as(), .bounds = source.field("bounds").as()}; } @@ -223,7 +224,8 @@ struct record_adapter { } /// Decodes this payload from a validated record value. static ownership_gap_payload from_value(const value& source) { - if (!source.type().same_shape(type())) throw std::invalid_argument("wrong ownership-gap type"); + if (!source.type().same_shape(type())) + throw std::invalid_argument("wrong ownership-gap type"); return {.seed = 0}; } }; diff --git a/tests/value_test.cpp b/tests/value_test.cpp index 3fc5ef7..c896ec9 100644 --- a/tests/value_test.cpp +++ b/tests/value_test.cpp @@ -58,19 +58,21 @@ struct record_adapter { /// Returns this adapter's complete nested nominal descriptor. static value_type type() { static const auto descriptor = value_type::record( - "tests.nominal_bounds", - std::array{record_field{"width", value_type::leaf()}, - record_field{"height", value_type::leaf()}}); + "tests.nominal_bounds", std::array{record_field{"width", value_type::leaf()}, + record_field{"height", value_type::leaf()}}); return descriptor; } /// Encodes one nested nominal value with source-order field ownership. static value to_value(const nominal_bounds& source) { - return value::record(type(), std::array{value::from(source.width), value::from(source.height)}); + return value::record(type(), + std::array{value::from(source.width), value::from(source.height)}); } /// Decodes one nested nominal value after complete descriptor validation. static nominal_bounds from_value(const value& source) { - if (!source.type().same_shape(type())) throw std::invalid_argument("wrong nominal bounds type"); - return {.width = source.field("width").as(), .height = source.field("height").as()}; + if (!source.type().same_shape(type())) + throw std::invalid_argument("wrong nominal bounds type"); + return {.width = source.field("width").as(), + .height = source.field("height").as()}; } }; @@ -91,7 +93,8 @@ struct record_adapter { } /// Decodes one nominal value after complete descriptor validation. static nominal_widget from_value(const value& source) { - if (!source.type().same_shape(type())) throw std::invalid_argument("wrong nominal widget type"); + if (!source.type().same_shape(type())) + throw std::invalid_argument("wrong nominal widget type"); return {.enabled = source.field("enabled").as(), .bounds = source.field("bounds").as()}; } @@ -408,9 +411,10 @@ TEST_CASE("nominal record adapter round-trips values and enforces complete schem CHECK(decoded.bounds.width == doctest::Approx(2.5)); CHECK(decoded.bounds.height == doctest::Approx(4.0)); const auto wrong = cel::value::record( - cel::value_type::record("tests.other_widget", - std::array{cel::record_field{"enabled", cel::value_type::leaf()}, - cel::record_field{"bounds", cel::record_adapter::type()}}), + cel::value_type::record( + "tests.other_widget", + std::array{cel::record_field{"enabled", cel::value_type::leaf()}, + cel::record_field{"bounds", cel::record_adapter::type()}}), std::array{cel::value::from(true), cel::value::from(nominal_bounds{.width = 1.0, .height = 1.0})}); CHECK_THROWS_AS(cel::record_adapter::from_value(wrong), std::invalid_argument); From 1c297ea456f24bc9640650bed4dc2a4b677de3b3 Mon Sep 17 00:00:00 2001 From: sean-parent Date: Wed, 18 Nov 2026 19:30:38 -0800 Subject: [PATCH 2/2] build: upgrade cpp-library and simplify test setup Upgrade cpp-library to 6.1.0 and regenerate its templates. Remove redundant documentation copying and settings, project-specific consumer tests and fixtures, and local test timeout policy. Retain private test-header access and portable thread linkage pending stlab/cpp-library#57; centralized time limits are tracked in stlab/cpp-library#56. Fixes #9. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .vscode/tasks.json | 2 +- CMakeLists.txt | 72 +++----------------- CMakePresets.json | 2 +- docs/execution.md | 3 +- docs/parity.md | 6 +- docs/runtime-milestone.md | 12 ++-- tests/installed_consumer.cmake.in | 46 ------------- tests/installed_consumer/CMakeLists.txt | 26 ------- tests/installed_consumer/main.cpp | 90 ------------------------- tests/source_consumer.cmake.in | 33 --------- 10 files changed, 20 insertions(+), 272 deletions(-) delete mode 100644 tests/installed_consumer.cmake.in delete mode 100644 tests/installed_consumer/CMakeLists.txt delete mode 100644 tests/installed_consumer/main.cpp delete mode 100644 tests/source_consumer.cmake.in diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 297e047..df55722 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -240,7 +240,7 @@ "$gcc", "$msCompile" ], - "detail": "Release build for installation with CPM_USE_LOCAL_PACKAGES enabled for testing installed packages Requires the CMake Tools extension (ms-vscode.cmake-tools) — without it, this task fails to start.", + "detail": "Release build for installation, preferring locally installed dependencies before fetching. Requires the CMake Tools extension (ms-vscode.cmake-tools) — without it, this task fails to start.", "windows": { "options": { "shell": { diff --git a/CMakeLists.txt b/CMakeLists.txt index c2456e6..586a6dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,8 @@ cmake_minimum_required(VERSION 3.24) include(cmake/CPM.cmake) -set(CPP_LIBRARY_VERSION "" CACHE STRING "CEL runtime package version override") - # Fetch cpp-library before project() -CPMAddPackage("gh:stlab/cpp-library@6.0.2") +CPMAddPackage("gh:stlab/cpp-library@6.1.0") include(${cpp-library_SOURCE_DIR}/cpp-library.cmake) # Enable dependency tracking before project() @@ -13,81 +11,29 @@ cpp_library_enable_dependency_tracking() # Now declare project project(runtime LANGUAGES CXX) -set(CMAKE_CXX_EXTENSIONS OFF) -if(PROJECT_IS_TOP_LEVEL) - include(CTest) -endif() +include(CTest) # Setup library cpp_library_setup( DESCRIPTION "Checked CEL programs, owned values, and reusable execution stacks" NAMESPACE cel - REQUIRES_CPP_VERSION 20 HEADERS runtime.hpp runtime/layout.hpp runtime/value_type.hpp runtime/value.hpp runtime/record_adapter.hpp runtime/raw_stack.hpp runtime/dyn_segment.hpp runtime/callable.hpp runtime/detail/retirement.hpp runtime/detail/frame.hpp runtime/detail/raw_segment.hpp SOURCES storage.cpp value_type.cpp value.cpp raw_stack.cpp raw_segment.cpp dyn_segment.cpp callable.cpp TESTS storage_test.cpp value_test.cpp resource_test.cpp raw_execution_test.cpp segment_test.cpp composite_execution_test.cpp callable_test.cpp executable_retirement_test.cpp native_contract_test.cpp nontrivial_leaf_fail.cpp typed_operand_fail.cpp overloaded_operand_fail.cpp generic_conversion_fail.cpp nondeduced_generic_fail.cpp raw_interface_fail.cpp alignment_interface_fail.cpp program_metadata_fail.cpp EXAMPLES getting_started.cpp DOCS_INPUTS README.md docs/build.md docs/get-started.md docs/libraries.md docs/execution.md docs/reference.dox + DOCS_EXCLUDE_SYMBOLS cel::detail cel::detail::* DOCS_OPTIONS "USE_MDFILE_AS_MAINPAGE = ${CMAKE_CURRENT_SOURCE_DIR}/README.md" - "EXCLUDE_SYMBOLS = cel::detail cel::detail::*" - "FULL_PATH_NAMES = NO" - "STRIP_FROM_PATH = ${CMAKE_CURRENT_SOURCE_DIR}" - "STRIP_FROM_INC_PATH = ${CMAKE_CURRENT_SOURCE_DIR}/include" ) -if(TARGET docs) - # Keeps checkout-relative contract-test links usable in generated documentation. - add_custom_command(TARGET docs POST_BUILD - COMMAND "${CMAKE_COMMAND}" -E copy_directory - "${CMAKE_CURRENT_SOURCE_DIR}/tests" "${CMAKE_CURRENT_BINARY_DIR}/tests" - COMMAND "${CMAKE_COMMAND}" -E copy_directory - "${CMAKE_CURRENT_SOURCE_DIR}/examples" "${CMAKE_CURRENT_BINARY_DIR}/examples" - COMMAND "${CMAKE_COMMAND}" -E copy - "${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt" "${CMAKE_CURRENT_BINARY_DIR}/CMakeLists.txt") -endif() + if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING) - configure_file(tests/installed_consumer.cmake.in installed_consumer.cmake @ONLY) - configure_file(tests/source_consumer.cmake.in source_consumer.cmake @ONLY) - add_test(NAME installed_consumer - COMMAND "${CMAKE_COMMAND}" "-DCONFIG=$" - -P "${CMAKE_CURRENT_BINARY_DIR}/installed_consumer.cmake") - add_test(NAME source_consumer - COMMAND "${CMAKE_COMMAND}" "-DCONFIG=$" - -P "${CMAKE_CURRENT_BINARY_DIR}/source_consumer.cmake") - set_tests_properties(installed_consumer source_consumer PROPERTIES TIMEOUT 180) - set_tests_properties(executable_retirement_test PROPERTIES TIMEOUT 180) -endif() -if(TARGET storage_test) - target_include_directories(storage_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") -endif() -if(TARGET raw_execution_test) - target_include_directories(raw_execution_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") - set_tests_properties(raw_execution_test PROPERTIES TIMEOUT 30) -endif() -if(TARGET value_test) - target_include_directories(value_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") -endif() -if(TARGET resource_test) + foreach(test storage_test raw_execution_test value_test resource_test segment_test + callable_test executable_retirement_test composite_execution_test) + target_include_directories(${test} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") + endforeach() + find_package(Threads REQUIRED) target_link_libraries(resource_test PRIVATE Threads::Threads) - target_include_directories(resource_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") - set_tests_properties(resource_test PROPERTIES TIMEOUT 30) -endif() -if(TARGET segment_test) - target_include_directories(segment_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") - set_tests_properties(segment_test PROPERTIES TIMEOUT 30) -endif() -foreach(test callable_test executable_retirement_test) - if(TARGET ${test}) - target_include_directories(${test} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") - endif() -endforeach() -if(TARGET composite_execution_test) - target_include_directories(composite_execution_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") - set_tests_properties(composite_execution_test PROPERTIES TIMEOUT 30) -endif() -if(TARGET callable_test) - target_include_directories(callable_test PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/src") - set_tests_properties(callable_test PROPERTIES TIMEOUT 30) endif() diff --git a/CMakePresets.json b/CMakePresets.json index 99ba84a..f6d7e7a 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -77,7 +77,7 @@ { "name": "install", "displayName": "Install Configuration", - "description": "Release build for installation with CPM_USE_LOCAL_PACKAGES enabled for testing installed packages", + "description": "Release build for installation, preferring locally installed dependencies before fetching", "binaryDir": "${sourceDir}/build/install", "generator": "Ninja", "cacheVariables": { diff --git a/docs/execution.md b/docs/execution.md index 4bcaa2c..aff3693 100644 --- a/docs/execution.md +++ b/docs/execution.md @@ -137,8 +137,7 @@ same-shape ownership ABIs. Complete compatibility also checks every callable result's ownership, including callables inside aggregate results, before checked execution or preparation admits the input. Prepared execution does not repeat these comparisons. Results may be client leaves, nested aggregates, or -another callable. The installed consumer exercises receipt after builders and -the temporary compiled factory disappear. +another callable. `value_type::callable(parameters, result)` describes a semantic signature without ownership operations. Use `bind_runtime_ownership(type)` when checked diff --git a/docs/parity.md b/docs/parity.md index a56aaba..7cbd4a5 100644 --- a/docs/parity.md +++ b/docs/parity.md @@ -23,7 +23,7 @@ The following entries cover the retained runtime surfaces: | Dynamic checked construction; preflight before effects; single-result freeze | [segment tests](../tests/segment_test.cpp), “checked signatures reject errors before callback effects” and “dynamic ordered mixed operations freeze reads and literals” | [dyn_segment.rs:757–789][rust-dyn], [prepared_segment.rs:16–75][rust-prepared] | Implemented | | Static stack effects and declared initial operands | Not part of the client interface | [segment.rs:57–73,90–122,188–239,350–415][rust-typed] | Not retained; clients compile source or use checked dynamic builders | | Complete identity, layout, and separately checked ownership capabilities | [value tests](../tests/value_test.cpp), including “private callable ownership installation preserves shape and validates operation pairs”; [resource tests](../tests/resource_test.cpp) for shared descriptor DAGs | [value_type.rs:1–9,47–74][rust-types], [prepared_segment.rs:16–75][rust-prepared] | Implemented | -| Code-independent canonical ownership binding for complete immutable type DAGs, including empty callable composites and higher-order result witnesses | [callable tests](../tests/callable_test.cpp): ownership binding, deep/shared DAGs, foreign-operation rejection; [installed consumer](../tests/installed_consumer/main.cpp) | C++ semantic-descriptor/canonical-carrier adaptation; no same-named Rust API claim | Implemented; semantic Fn declarations remain unbound | +| Code-independent canonical ownership binding for complete immutable type DAGs, including empty callable composites and higher-order result witnesses | [callable tests](../tests/callable_test.cpp): ownership binding, deep/shared DAGs, foreign-operation rejection | C++ semantic-descriptor/canonical-carrier adaptation; no same-named Rust API claim | Implemented; semantic Fn declarations remain unbound | | Recursive independent aggregate copies, native boundary adapters, over-aligned client roots | [segment tests](../tests/segment_test.cpp): “typed composite calls borrow inputs and return disjoint nested results”, “valid over-aligned client root arguments and results are admitted”; [value tests](../tests/value_test.cpp) | [prepared_segment.rs:96–225][rust-prepared] | Implemented; native C++ facades differ | | Tuple packing at exact origin; source-order ownership transfer | [structural tests](../tests/composite_execution_test.cpp): “nested packing consumes source order and preserves exact owners” | [dyn_segment.rs:792–825][rust-dyn] | Implemented; origin includes logical depth | | Typed arrays, empty arrays, zero-byte elements, nested owning payloads | [structural tests](../tests/composite_execution_test.cpp) packing and invalid-shape cases; [value tests](../tests/value_test.cpp) | [dyn_segment.rs:852–916][rust-dyn] | Implemented | @@ -38,10 +38,10 @@ The following entries cover the retained runtime surfaces: | Stable source-ordered guarded dynamic invocation across nested stack growth | [callable tests](../tests/callable_test.cpp), nested-growth reread and throwing dynamic-body tests | [dyn_segment.rs:1367–1457][rust-dyn] | Implemented; stable C++ canonical staging | | Nonallocating stack-independent callable/program retirement; deep literals, lazy bodies, and shared children | [executable retirement tests](../tests/executable_retirement_test.cpp), depth-12000 normal/unwinding and last-owner retirement | C++ ownership contract; no speculative Rust destruction claim | Deep retirement tested; allocation counts are not measured | | Complete higher-order result ownership before effects or raw binding | [callable tests](../tests/callable_test.cpp): “higher order results reject foreign ownership before checked execution and binding”, independently bound canonical higher-order witnesses | Complete checked ownership contract; foreign C++ ABI fixture has no Rust equivalent | Corrected; prepared execution remains comparison-free | -| Typed/raw preparation; no repeated descriptor comparison; caller-owned raw result retirement | [segment tests](../tests/segment_test.cpp), [installed consumer](../tests/installed_consumer/main.cpp) for public typed execution | [prepared_segment.rs:16–168,228–255][rust-prepared] | Implemented; raw result retirement tested in segment suite | +| Typed/raw preparation; no repeated descriptor comparison; caller-owned raw result retirement | [segment tests](../tests/segment_test.cpp) | [prepared_segment.rs:16–168,228–255][rust-prepared] | Implemented; raw result retirement tested in segment suite | | Intermediate alignment, prefix totals, zero-byte depth, selected/known-callee peaks | [segment tests](../tests/segment_test.cpp), [structural tests](../tests/composite_execution_test.cpp), [callable tests](../tests/callable_test.cpp) | [raw_segment.rs:117–130][rust-raw] gives alignment/frame metadata | Implemented/tested; published C++ reservation helper is an adaptation, not claimed Rust API parity | | Exception suffix cleanup, preserved prefixes, construction rollback, partial-owner retirement, reusable stack | [raw execution tests](../tests/raw_execution_test.cpp), [segment tests](../tests/segment_test.cpp), structural/callable callback exceptions and invalid-construction rollback cases | [raw_stack.rs:67–76][rust-stack], [raw_segment.rs:411–433][rust-raw], [dyn_segment.rs:1367–1457][rust-dyn] | Implemented; allocation-failure injection is not tested | -| Installed umbrella, standalone scalar/composite/callable clients, runnable cached example | [installed consumer](../tests/installed_consumer/main.cpp), [example](../examples/getting_started.cpp), `installed_consumer` CTest | C++ packaging adaptation; no Rust package-equivalence claim | Implemented | +| Runnable cached example | [example](../examples/getting_started.cpp) | C++ packaging adaptation; no Rust package-equivalence claim | Implemented | ## Deliberate scope and mechanism adaptations diff --git a/docs/runtime-milestone.md b/docs/runtime-milestone.md index d9667bd..4deac0e 100644 --- a/docs/runtime-milestone.md +++ b/docs/runtime-milestone.md @@ -75,12 +75,10 @@ Independent final port review and remote/platform validation remain pending. ## Reproduce local validation -The pinned cpp-library release is `v6.0.2` at revision -`df18f94c816df6dc4fbab8078e6b57a7d265a2c2`. Its presets, doctest/CTest, +The pinned cpp-library release is `v6.1.0` at revision +`13ff79ac9fbbf575bbab0ab3dee0c752b4501fcc`. Its presets, doctest/CTest, compile-fail gates, Doxygen, exports, installation, and generated CI remain in -use. The installed-consumer CTest installs the built configuration to an -isolated prefix, rejects leaked source/sibling paths, and compiles two real -clients using only the imported package. +use. Run Debug and lint checks from the checkout: @@ -116,8 +114,8 @@ ASAN_OPTIONS=detect_leaks=0 UBSAN_OPTIONS=halt_on_error=1 \ ctest --test-dir build/sanitized --output-on-failure ``` -The original milestone's 16 CTests, including six compile-fail gates, the runnable example, and -installed consumption, pass in Debug, Release, supported ASan+UBSan, and +The original milestone's runtime tests, compile-fail gates, and runnable example +pass in Debug, Release, supported ASan+UBSan, and clang-tidy configurations. Compiler output is warning-free, formatting passes, and strict Doxygen passes. Explicit owner counters supplement sanitizer cleanup checks. macOS LeakSanitizer is unsupported and disabled; it is not a diff --git a/tests/installed_consumer.cmake.in b/tests/installed_consumer.cmake.in deleted file mode 100644 index 6305629..0000000 --- a/tests/installed_consumer.cmake.in +++ /dev/null @@ -1,46 +0,0 @@ -# SPDX-License-Identifier: BSL-1.0 -# Installs this built configuration and tests standalone clients against that prefix. -# The consumer receives no runtime source include directory or build-tree library target. -set(prefix "@CMAKE_CURRENT_BINARY_DIR@/installed-check/prefix") -set(consumer_build "@CMAKE_CURRENT_BINARY_DIR@/installed-check/consumer") -file(REMOVE_RECURSE "${prefix}" "${consumer_build}") -execute_process(COMMAND "@CMAKE_COMMAND@" --install "@CMAKE_CURRENT_BINARY_DIR@" - --config "${CONFIG}" --prefix "${prefix}" COMMAND_ERROR_IS_FATAL ANY) - -# Rejects exported source/sibling paths before configuring an installed-only consumer. -file(GLOB_RECURSE package_configs "${prefix}/*.cmake") -get_filename_component(repository_parent "@CMAKE_CURRENT_SOURCE_DIR@" DIRECTORY) -foreach(config_file IN LISTS package_configs) - file(READ "${config_file}" contents) - string(FIND "${contents}" "${repository_parent}" leaked_path) - if(NOT leaked_path EQUAL -1) - message(FATAL_ERROR "Installed configuration leaks a repository path: ${config_file}") - endif() -endforeach() - -execute_process(COMMAND "@CMAKE_COMMAND@" - -S "@CMAKE_CURRENT_SOURCE_DIR@/tests/installed_consumer" -B "${consumer_build}" - -G "@CMAKE_GENERATOR@" "-DCMAKE_BUILD_TYPE=${CONFIG}" - "-DCMAKE_PREFIX_PATH=${prefix}" - "-DCMAKE_CXX_COMPILER=@CMAKE_CXX_COMPILER@" - "-DCMAKE_CXX_FLAGS=@CMAKE_CXX_FLAGS@" - "-DCMAKE_EXE_LINKER_FLAGS=@CMAKE_EXE_LINKER_FLAGS@" - "-DCMAKE_CXX_CLANG_TIDY=@CMAKE_CXX_CLANG_TIDY@" - -DCMAKE_EXPORT_COMPILE_COMMANDS=ON - -DCMAKE_FIND_USE_PACKAGE_REGISTRY=OFF - -DCMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY=OFF - COMMAND_ERROR_IS_FATAL ANY) - -# Verifies that both imported boundaries resolve inside this fresh installation. -file(READ "${consumer_build}/imported-runtime-${CONFIG}.txt" imported_paths) -foreach(boundary library headers) - string(FIND "${imported_paths}" "${boundary}=${prefix}/" installed_path) - if(installed_path EQUAL -1) - message(FATAL_ERROR "Consumer ${boundary} did not resolve to the installation") - endif() -endforeach() - -execute_process(COMMAND "@CMAKE_COMMAND@" --build "${consumer_build}" --config "${CONFIG}" - COMMAND_ERROR_IS_FATAL ANY) -execute_process(COMMAND "@CMAKE_CTEST_COMMAND@" --test-dir "${consumer_build}" - -C "${CONFIG}" --output-on-failure COMMAND_ERROR_IS_FATAL ANY) diff --git a/tests/installed_consumer/CMakeLists.txt b/tests/installed_consumer/CMakeLists.txt deleted file mode 100644 index e59fd5f..0000000 --- a/tests/installed_consumer/CMakeLists.txt +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-License-Identifier: BSL-1.0 -cmake_minimum_required(VERSION 3.24) -project(installed_runtime_consumer LANGUAGES CXX) - -find_package(cel-runtime CONFIG REQUIRED) -get_target_property(runtime_imported cel::runtime IMPORTED) -if(NOT runtime_imported) - message(FATAL_ERROR "The consumer requires an installed imported target") -endif() - -include(CTest) -add_executable(installed_runtime_consumer main.cpp) -target_link_libraries(installed_runtime_consumer PRIVATE cel::runtime) -add_executable(installed_getting_started ../../examples/getting_started.cpp) -target_link_libraries(installed_getting_started PRIVATE cel::runtime) -foreach(target installed_runtime_consumer installed_getting_started) - set_target_properties(${target} PROPERTIES CXX_EXTENSIONS OFF) - if(MSVC) - target_compile_options(${target} PRIVATE /W4 /WX) - else() - target_compile_options(${target} PRIVATE -Wall -Wextra -Wpedantic -Werror) - endif() - add_test(NAME ${target} COMMAND ${target}) -endforeach() -file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/imported-runtime-$.txt" - CONTENT "library=$\nheaders=$\n") diff --git a/tests/installed_consumer/main.cpp b/tests/installed_consumer/main.cpp deleted file mode 100644 index 4f30b35..0000000 --- a/tests/installed_consumer/main.cpp +++ /dev/null @@ -1,90 +0,0 @@ -// SPDX-License-Identifier: BSL-1.0 -#include - -#include -#include -#include - -/// Verifies installed scalar, independent nested-owner, and surviving callable results. -/// Returns zero when cached execution preserves the caller prefix and all results match. -int main() try { - if (!cel::value_type::leaf().compatible_with(cel::value_type::leaf()) || - cel::value_type::leaf().compatible_with(cel::value_type::leaf())) - return 9; - cel::raw_stack stack; - stack.push(true); - const auto cursor = stack.cursor(); - const auto depth = stack.depth(); - - cel::dyn_segment scalar; - scalar.push_argument(0, cel::native_type()); - if (scalar.origin_below(0) != cel::stack_origin{sizeof(double), 1} || - scalar.origin_below(1) != cel::stack_origin{}) - return 10; - const auto operands = scalar.operand_types(1); - if (operands.size() != 1 || !operands[0].compatible_with(cel::value_type::leaf()) || - operands[0].compatible_with(cel::value_type::leaf()) || - !scalar.operand_types(2).empty()) - return 8; - scalar.op1([](double n) { return n * 2.0; }); - auto cached = std::move(scalar).finish().prepare(); - const auto needed = cached.requirements().for_prefix(cursor, depth); - stack.reserve(needed.bytes.size, needed.bytes.alignment); - stack.reserve_depth(needed.slots); - if (cached.call(stack, 3.0) != 6.0 || cached.call(stack, 4.0) != 8.0) return 1; - - using nested = std::tuple>>>; - const nested input{true, {{2.0, {true, false}}}}; - cel::dyn_segment composite; - composite.push_argument(0, cel::native_type()); - auto copy = std::move(composite).finish().prepare(); - auto first = copy.call(stack, input); - auto second = copy.call(stack, input); - std::get<1>(std::get<1>(first)[0])[0] = false; - if (!std::get<1>(std::get<1>(second)[0])[0] || !std::get<1>(std::get<1>(input)[0])[0]) return 2; - - auto received = [&] { - cel::dyn_segment body; - body.push_argument(0, cel::value_type::leaf()); - body.op1([](double n) { return n + 1.0; }); - cel::dyn_segment factory; - factory.push_closure(std::move(body).finish(), std::array{cel::value_type::leaf()}); - return std::move(factory).finish().execute(stack, {}); - }(); - auto fn = cel::callable::from_value(received); - received = cel::value{}; - if (fn.call(stack, std::array{cel::value::from(4.0)}).as() != 5.0) return 3; - auto alias = cel::callable::from_value(fn.to_value()); - if (alias.call(stack, std::array{cel::value::from(8.0)}).as() != 9.0) return 4; - const auto declared = cel::value_type::callable(std::array{cel::value_type::leaf()}, - cel::value_type::leaf()); - const auto bound = cel::bind_runtime_ownership(declared); - if (declared.owns_values() || !bound.owns_values() || !bound.compatible_with(fn.type()) || - !cel::bind_runtime_ownership(bound).compatible_with(bound)) - return 10; - auto empty = [&] { - const auto higher = cel::value_type::callable({}, declared); - const auto record = cel::value_type::record( - "empty", std::array{cel::record_field{"factory", higher}, - cel::record_field{"functions", cel::value_type::array(declared)}}); - cel::dyn_segment builder; - builder.make_array(0, cel::bind_runtime_ownership(record), {}); - return std::move(builder).finish().execute(stack, {}); - }(); - auto empty_copy = empty; - if (empty.size() != 0 || empty_copy.size() != 0 || - !empty_copy.type().element().fields()[0].result().compatible_with(fn.type())) - return 11; - cel::dyn_segment populated; - populated.just(fn.to_value()); - populated.make_array(1, bound, {}); - auto functions = std::move(populated).finish().execute(stack, {}); - if (cel::callable::from_value(functions.at(0)) - .call(stack, std::array{cel::value::from(6.0)}) - .as() != 7.0) - return 12; - if (stack.cursor() != cursor || stack.depth() != depth || !stack.pop()) return 5; - return stack.depth() == 0 ? 0 : 6; -} catch (...) { - return 7; -} diff --git a/tests/source_consumer.cmake.in b/tests/source_consumer.cmake.in deleted file mode 100644 index 1c04a43..0000000 --- a/tests/source_consumer.cmake.in +++ /dev/null @@ -1,33 +0,0 @@ -# SPDX-License-Identifier: BSL-1.0 -# Builds a source consumer whose own tests are enabled, without dependency options. -set(consumer_source "@CMAKE_CURRENT_BINARY_DIR@/source-check/source") -set(consumer_build "@CMAKE_CURRENT_BINARY_DIR@/source-check/build") -file(REMOVE_RECURSE "${consumer_source}" "${consumer_build}") -file(MAKE_DIRECTORY "${consumer_source}") -file(WRITE "${consumer_source}/CMakeLists.txt" [=[ -cmake_minimum_required(VERSION 3.24) -project(source_consumer LANGUAGES CXX) -include(CTest) -add_subdirectory("@CMAKE_CURRENT_SOURCE_DIR@" cel-runtime) -get_target_property(kind cel::runtime TYPE) -get_target_property(imported cel::runtime IMPORTED) -get_property(dependency_tests DIRECTORY "@CMAKE_CURRENT_SOURCE_DIR@" PROPERTY TESTS) -if(NOT kind STREQUAL "STATIC_LIBRARY" OR imported OR dependency_tests OR CEL_INSTALL) - message(FATAL_ERROR "Expected a source-built static runtime without dependency tests or installation") -endif() -add_executable(client "@CMAKE_CURRENT_SOURCE_DIR@/examples/getting_started.cpp") -target_link_libraries(client PRIVATE cel::runtime) -add_test(NAME client COMMAND client) -]=]) -execute_process(COMMAND "@CMAKE_COMMAND@" - -S "${consumer_source}" -B "${consumer_build}" - -G "@CMAKE_GENERATOR@" "-DCMAKE_BUILD_TYPE=${CONFIG}" - "-DCMAKE_CXX_COMPILER=@CMAKE_CXX_COMPILER@" - "-DCMAKE_CXX_FLAGS=@CMAKE_CXX_FLAGS@" - "-DCMAKE_EXE_LINKER_FLAGS=@CMAKE_EXE_LINKER_FLAGS@" - "-DCPM_SOURCE_CACHE=@CPM_SOURCE_CACHE@" - COMMAND_ERROR_IS_FATAL ANY) -execute_process(COMMAND "@CMAKE_COMMAND@" --build "${consumer_build}" --config "${CONFIG}" - COMMAND_ERROR_IS_FATAL ANY) -execute_process(COMMAND "@CMAKE_CTEST_COMMAND@" --test-dir "${consumer_build}" - -C "${CONFIG}" --output-on-failure COMMAND_ERROR_IS_FATAL ANY)