From 1b4d3ebece50d4fd84cf8a7e1d319b6333d0d54b Mon Sep 17 00:00:00 2001 From: sean-parent Date: Fri, 20 Nov 2026 22:10:31 -0800 Subject: [PATCH] Add configurable timeouts for generated tests Default generated CTest tests to 120 seconds, validate TEST_TIMEOUT overrides, and preserve native per-test exceptions. Cover effective metadata and real runtime/build termination in regressions. Fixes #56 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci.yml | 6 + .scout/memory/index.md | 3 +- ...stration-to-preserve-per-test-overrides.md | 25 +++ .../generated-ci-package-artifact-check.md | 23 ++- README.md | 27 +++ cmake/cpp-library-testing.cmake | 10 + cpp-library.cmake | 16 +- tests/setup/test_timeouts.cmake | 193 ++++++++++++++++++ 8 files changed, 295 insertions(+), 8 deletions(-) create mode 100644 .scout/memory/knowledge/assign-generated-test-timeouts-at-registration-to-preserve-per-test-overrides.md create mode 100644 tests/setup/test_timeouts.cmake diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 64d714b..d842da0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -38,6 +38,9 @@ jobs: - name: Run static and in-source unit testing checks run: cmake -P tests/setup/test_source_testing.cmake + - name: Run generated-test timeout checks + run: cmake -P tests/setup/test_timeouts.cmake + - name: Run project version override tests run: cmake -P tests/setup/test_version_override.cmake @@ -88,6 +91,9 @@ jobs: - name: Run static and in-source unit testing checks run: cmake -P tests/setup/test_source_testing.cmake + - name: Run generated-test timeout checks + run: cmake -P tests/setup/test_timeouts.cmake + - name: Run project version override tests run: cmake -P tests/setup/test_version_override.cmake diff --git a/.scout/memory/index.md b/.scout/memory/index.md index c1931e6..344fc1f 100644 --- a/.scout/memory/index.md +++ b/.scout/memory/index.md @@ -3,12 +3,13 @@ ## Knowledge - [[knowledge/architecture-overview.md|Architecture Overview]] (concept, 0.80) `architecture-overview` `cpp-library-architecture` `cpp-library-overview` `toolkit-architecture` `cmake-infrastructure-overview` +- [[knowledge/assign-generated-test-timeouts-at-registration-to-preserve-per-test-overrides.md|Assign generated-test timeouts at registration to preserve per-test overrides]] (pattern, 1.00) `ctest` `timeouts` `test-support` `deferred-configuration` - [[knowledge/consumer-lifecycle-and-template-overwrite-controls.md|Consumer Lifecycle and Template Overwrite Controls]] (decision, 0.75) `template-initialization` `cpp-library-force-init` `project-is-top-level` `lightweight-consumer-mode` `template-copying` - [[knowledge/deferred-install-dependency-validation-and-config-generation.md|Deferred Install Dependency Validation and Config Generation]] (pattern, 0.75) `deferred-install` `install-validation` `untracked-dependencies` `cmake-language-defer` `find-dependency` - [[knowledge/dependency-mappings-follow-the-exported-target-s-owning-project.md|Dependency mappings follow the exported target's owning project]] (discovery, 0.99) `cmake` `dependency-mappings` `project-scope` `deferred-install` - [[knowledge/dependency-tracking-lifecycle-and-provider-ordering.md|Dependency Tracking Lifecycle and Provider Ordering]] (observation, 0.75) `dependency-tracking` `dependency-provider` `cpp-library-enable-dependency-tracking` `cmake-project-top-level-includes` `set-dependency-provider` - [[knowledge/documentation-setup-and-theme-integration-with-build-docs.md|Documentation Setup and Theme Integration with BUILD_DOCS]] (pattern, 0.75) `build-docs` `doxygen` `doxygen-awesome-css` `documentation-generation` `docs-target` -- [[knowledge/generated-ci-package-artifact-check.md|Generated CI package artifact check]] (decision, 0.95) `ci` `packaging` `cmake` +- [[knowledge/generated-ci-package-artifact-check.md|Generated CI package artifact check]] (decision, 0.98) `ci` `packaging` `cmake` `source-builds` - [[knowledge/installation-supports-separately-installed-dependencies-not-mixed-source-export-workarounds.md|Installation supports separately installed dependencies, not mixed source export workarounds]] (decision, 0.99) `cmake` `installation` `cpm` `supported-boundary` - [[knowledge/public-header-verification-must-participate-in-the-default-build.md|Public-header verification must participate in the default build]] (pattern, 0.99) `cmake` `header-verification` `testing` `file-sets` - [[knowledge/static-and-in-source-tests-require-separate-implementation-compilations.md|Static and in-source tests require separate implementation compilations]] (decision, 0.99) `cmake` `testing` `doctest` `static-linkage` `private-components` `generated-headers` diff --git a/.scout/memory/knowledge/assign-generated-test-timeouts-at-registration-to-preserve-per-test-overrides.md b/.scout/memory/knowledge/assign-generated-test-timeouts-at-registration-to-preserve-per-test-overrides.md new file mode 100644 index 0000000..652f25a --- /dev/null +++ b/.scout/memory/knowledge/assign-generated-test-timeouts-at-registration-to-preserve-per-test-overrides.md @@ -0,0 +1,25 @@ +--- +title: "Assign generated-test timeouts at registration to preserve per-test overrides" +entity_type: pattern +confidence: 1.00 +created: 2026-11-21T06:03:02Z +last_accessed: 2026-11-21T06:03:09Z +last_reinforced: 2026-11-21T06:03:09Z +access_count: 2 +sources: + - "cpp-library.cmake:135-150" + - "cpp-library.cmake:338-340" + - "cmake/cpp-library-testing.cmake:8-15" + - "cmake/cpp-library-testing.cmake:117-129" + - "tests/setup/test_timeouts.cmake:31-39" +tags: ["ctest", "timeouts", "test-support", "deferred-configuration"] +tier: knowledge +--- + +# Assign generated-test timeouts at registration to preserve per-test overrides + +Generated CTest timeout policy is project-local: cpp_library_setup stores an explicit TEST_TIMEOUT in the production library target's _CPP_LIBRARY_TEST_TIMEOUT property (cpp-library.cmake:338-340). _cpp_library_set_test_timeout reads that property, defaults to 120 seconds, and sets the native test TIMEOUT property (cmake/cpp-library-testing.cmake:8-15). + +Keep timeout assignment immediate at each registration site, not in deferred test-support finalization. Ordinary tests/examples and compile-fail checks are registered in cpp-library.cmake:135-150; compiled libraries also register a separate in-source runner in cmake/cpp-library-testing.cmake:117-129. All three paths must apply the same policy using the production library target, not its static unit-test implementation target. Immediate assignment lets consumers use set_tests_properties after setup without deferred work resetting their intentional exceptions; the regression overrides both ordinary and in-source tests (tests/setup/test_timeouts.cmake:31-39). + +Verification: cmake -P tests/setup/test_timeouts.cmake inspects effective CTest JSON, checks generated preset metadata, and proves one-second timeout failure for runtime and WILL_FAIL compile-fail tests. diff --git a/.scout/memory/knowledge/generated-ci-package-artifact-check.md b/.scout/memory/knowledge/generated-ci-package-artifact-check.md index 0d7d9d8..22689aa 100644 --- a/.scout/memory/knowledge/generated-ci-package-artifact-check.md +++ b/.scout/memory/knowledge/generated-ci-package-artifact-check.md @@ -1,19 +1,30 @@ --- title: "Generated CI package artifact check" entity_type: decision -confidence: 0.95 +confidence: 0.98 created: 2026-11-15T04:12:07Z -last_accessed: 2026-11-15T04:27:16Z -last_reinforced: 2026-11-15T04:27:16Z -access_count: 2 +last_accessed: 2026-11-21T06:05:52Z +last_reinforced: 2026-11-21T06:05:52Z +access_count: 4 sources: - "templates/.github/workflows/ci.yml.in:76-79" - "templates/test-package.cmake.in:8-35" - "cmake/cpp-library-ci.cmake:41-54" -tags: ["ci", "packaging", "cmake"] + - "README.md:223-265" + - "docs/installation-testing.md:3-17" + - "cmake/cpp-library-setup.cmake:187-196" +tags: ["ci", "packaging", "cmake", "source-builds"] tier: knowledge --- # Generated CI package artifact check -Generated consumer CI deliberately verifies only the root package's installed Config, ConfigVersion and Targets artifacts; dependency installation and downstream find_package resolution remain the consumer's responsibility. The checker requires both file existence and membership in the current CMake install manifest, so stale absolute-destination artifacts cannot pass. Absolute library destinations do not require the otherwise unused install prefix to exist. The deferred generator captures CPP_LIBRARY_ROOT when scheduled because setup may run inside a function whose scope ends before deferred calls execute. Sources: templates/.github/workflows/ci.yml.in:76-79, templates/test-package.cmake.in:8-35, cmake/cpp-library-ci.cmake:41-54. +# Generated CI package artifact check + +Generated consumer CI is source-only; it no longer installs or runs package-artifact checks automatically. Source presets (default, test, docs, clang-tidy, init) disable the resolved namespace/custom installation option; install enables it. Merely removing cmake --install is insufficient: CMake validates exports at generation time, so source-built dependencies without export sets can break configuration unless installation is disabled. + +Clients wanting installation testing provide their own YAML workflow that installs required dependencies separately, configures the component against those installed packages, then installs and optionally runs the generated cpp-library-test-package.cmake script. No installation-specific dependency declarations or export workarounds belong in client CMakeLists.txt. CPM_USE_LOCAL_PACKAGES is a preference, not a source-fallback prohibition. + +The optional checker verifies root Config, ConfigVersion and Targets artifact existence AND membership in the install manifest, not downstream consumption or dependency closure. Keep stale-artifact and absolute-destination protections. Keep deferred generator root capture for function-scoped setup. + +Presets are configured from templates/CMakePresets.json.in with @ONLY to preserve literal ${sourceDir}; preserve existing consumer files unless force initialization is requested. This updates the earlier memory that incorrectly described automatic generated-CI installation checking after PR #61. diff --git a/README.md b/README.md index fbb09c1..0341b71 100644 --- a/README.md +++ b/README.md @@ -506,6 +506,7 @@ cpp_library_setup( [DOCS_OPTIONS setting_list] # Additive single-line Doxygen assignments [REQUIRES_CPP_VERSION 17|20|23] # C++ version (default: 20) [ENABLE_THREADS ON|OFF] # Transitive thread requirements (default: ON) + [TEST_TIMEOUT seconds] # Per-test timeout in seconds (default: 120) [INSTALL_OPTION option_name] # Independent installation control (default: uppercase NAMESPACE_INSTALL) [LICENSE_FILES file_list] # Additional project-relative or absolute license/notice files ) @@ -541,6 +542,32 @@ cpp_library_setup( Pass `ENABLE_THREADS OFF` to skip automatic thread discovery and linkage; this does not disable C++ thread APIs or remove thread requirements you add manually. +### Test timeouts + +Generated unit tests, examples, compile-fail checks, and in-source test runners +each have a 120-second CTest `TIMEOUT`. Set `TEST_TIMEOUT` to change this +project-wide limit. Values must be whole seconds from 1 through 2147483647; +zero (unlimited), missing, fractional, and nonnumeric values fail configuration. +Manually registered tests are unchanged. + +For an intentionally longer test, set a finite per-test exception after setup: + +```cmake +cpp_library_setup( + DESCRIPTION "My library" + NAMESPACE mylib + HEADERS api.hpp + TESTS fast_test.cpp slow_test.cpp + TEST_TIMEOUT 120 +) +set_tests_properties(slow_test PROPERTIES TIMEOUT 300) +``` + +These properties apply to ordinary CTest runs, generated test presets, and CI. +Inspect the effective limits with `ctest --show-only=json-v1` in your build +directory. A timeout fails the test, including compile-fail checks marked +`WILL_FAIL`. + ### Documentation configuration Keep the toolkit's Doxyfile template instead of copying it into your project. diff --git a/cmake/cpp-library-testing.cmake b/cmake/cpp-library-testing.cmake index d70c9db..9242705 100644 --- a/cmake/cpp-library-testing.cmake +++ b/cmake/cpp-library-testing.cmake @@ -5,6 +5,15 @@ # Provides cpp_library_copy_runtime_dlls for custom and toolkit-created executables. # _cpp_library_setup_testing delegates to _cpp_library_setup_executables for compatibility. +# Sets a generated test's project timeout, defaulting to 120 seconds. +function(_cpp_library_set_test_timeout library_target test_name) + get_target_property(timeout "${library_target}" _CPP_LIBRARY_TEST_TIMEOUT) + if(NOT timeout) + set(timeout 120) + endif() + set_tests_properties("${test_name}" PROPERTIES TIMEOUT "${timeout}") +endfunction() + # Adds a private, always-defined function-style testing configuration. function(_cpp_library_setup_testing_config) cmake_parse_arguments(ARG "" "TARGET;ENABLED" "" ${ARGN}) @@ -115,6 +124,7 @@ function(_cpp_library_setup_test_support) [[${ARG_TARGET}]] [[${runner}]])") cpp_library_copy_runtime_dlls("${runner}") add_test(NAME "${runner}" COMMAND "${runner}") + _cpp_library_set_test_timeout("${ARG_TARGET}" "${runner}") set_tests_properties("${runner}" PROPERTIES LABELS doctest WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") endif() diff --git a/cpp-library.cmake b/cpp-library.cmake index 01a4c1e..40c7cb8 100644 --- a/cpp-library.cmake +++ b/cpp-library.cmake @@ -137,6 +137,7 @@ function(_cpp_library_setup_executables) WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) set_tests_properties(compile_${executable_base} PROPERTIES WILL_FAIL TRUE) + _cpp_library_set_test_timeout("${ARG_NAME}" "compile_${executable_base}") else() # Regular executable - build and link normally add_executable(${executable_base} "${source_dir}/${executable}") @@ -146,6 +147,7 @@ function(_cpp_library_setup_executables) # Register as CTest test add_test(NAME ${executable_base} COMMAND ${executable_base}) + _cpp_library_set_test_timeout("${ARG_NAME}" "${executable_base}") # Set test properties for better IDE integration (only for tests) if(ARG_TYPE STREQUAL "tests") @@ -184,6 +186,7 @@ function(cpp_library_setup) NAMESPACE # Namespace (e.g., "stlab") REQUIRES_CPP_VERSION # C++ version (default: 20) ENABLE_THREADS # Portable thread requirements (default: ON) + TEST_TIMEOUT # Generated-test timeout in seconds (default: 120) INSTALL_OPTION # Custom installation option name ) set(multiValueArgs @@ -202,7 +205,7 @@ function(cpp_library_setup) if("INSTALL_OPTION" IN_LIST ARG_KEYWORDS_MISSING_VALUES) message(FATAL_ERROR "cpp_library_setup: INSTALL_OPTION requires a value") endif() - foreach(keyword DOCS_INPUTS DOCS_OPTIONS LICENSE_FILES ENABLE_THREADS) + foreach(keyword DOCS_INPUTS DOCS_OPTIONS LICENSE_FILES ENABLE_THREADS TEST_TIMEOUT) if(keyword IN_LIST ARG_KEYWORDS_MISSING_VALUES) message(FATAL_ERROR "cpp_library_setup: ${keyword} requires a value") endif() @@ -210,6 +213,13 @@ function(cpp_library_setup) if(NOT DEFINED ARG_ENABLE_THREADS) set(ARG_ENABLE_THREADS ON) endif() + if(DEFINED ARG_TEST_TIMEOUT) + if(NOT ARG_TEST_TIMEOUT MATCHES "^[0-9]+$" OR + ARG_TEST_TIMEOUT LESS 1 OR ARG_TEST_TIMEOUT GREATER 2147483647) + message(FATAL_ERROR + "cpp_library_setup: TEST_TIMEOUT must be a positive integer in seconds (1 through 2147483647)") + endif() + endif() set(install_args) if(DEFINED ARG_INSTALL_OPTION) list(APPEND install_args INSTALL_OPTION "${ARG_INSTALL_OPTION}") @@ -325,6 +335,10 @@ function(cpp_library_setup) ${install_args} ) + if(DEFINED ARG_TEST_TIMEOUT) + set_property(TARGET "${ARG_NAME}" PROPERTY _CPP_LIBRARY_TEST_TIMEOUT "${ARG_TEST_TIMEOUT}") + endif() + if(ARG_ENABLE_THREADS) set(THREADS_PREFER_PTHREAD_FLAG TRUE) find_package(Threads REQUIRED) diff --git a/tests/setup/test_timeouts.cmake b/tests/setup/test_timeouts.cmake new file mode 100644 index 0000000..bcf23a1 --- /dev/null +++ b/tests/setup/test_timeouts.cmake @@ -0,0 +1,193 @@ +# SPDX-License-Identifier: BSL-1.0 +# +# Run as: cmake -P tests/setup/test_timeouts.cmake + +cmake_minimum_required(VERSION 3.24) + +get_filename_component(toolkit_source "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) +string(RANDOM LENGTH 16 ALPHABET 0123456789abcdef test_id) +set(test_root "${toolkit_source}/build/test-timeouts-${test_id}") +set(source "${test_root}/source") +get_filename_component(cmake_directory "${CMAKE_COMMAND}" DIRECTORY) +find_program(ctest NAMES ctest HINTS "${cmake_directory}" REQUIRED) +file(MAKE_DIRECTORY "${source}/include/fixture" "${source}/src" + "${source}/tests" "${source}/examples") +file(WRITE "${source}/CMakeLists.txt" [=[ +cmake_minimum_required(VERSION 3.24) +include("${TOOLKIT_SOURCE}/cpp-library.cmake") +project(timed LANGUAGES CXX) +include(CTest) +include("${TOOLKIT_SOURCE}/tests/setup/fixtures/mock_doctest.cmake") +set(source_args) +if(COMPILED) + set(source_args SOURCES library.cpp) +endif() +set(timeout_args) +if(DEFINED PROJECT_TIMEOUT) + set(timeout_args TEST_TIMEOUT "${PROJECT_TIMEOUT}") +elseif(MISSING_TIMEOUT) + set(timeout_args TEST_TIMEOUT) +endif() +cpp_library_setup(DESCRIPTION "Generated test timeouts" NAMESPACE fixture + HEADERS api.hpp ${source_args} + TESTS unit.cpp negative_fail.cpp + EXAMPLES example.cpp example_fail.cpp ${timeout_args}) +if(OVERRIDE_TEST) + set_tests_properties(unit PROPERTIES TIMEOUT 300) + if(COMPILED) + set_tests_properties(timed_in_source_tests PROPERTIES TIMEOUT 300) + endif() +endif() +add_test(NAME manual COMMAND "${CMAKE_COMMAND}" -E true) +set_tests_properties(manual PROPERTIES TIMEOUT 900) +if(SLOW_TESTS) + target_compile_definitions(unit PRIVATE SLOW_TEST) + set_property(TARGET negative_fail PROPERTY CXX_COMPILER_LAUNCHER + "${CMAKE_COMMAND};-P;${CMAKE_CURRENT_SOURCE_DIR}/stall.cmake") +endif() +]=]) +file(WRITE "${source}/include/fixture/api.hpp" "#pragma once\n") +file(WRITE "${source}/src/library.cpp" "int fixture_value() { return 42; }\n") +file(WRITE "${source}/tests/unit.cpp" [=[ +#ifdef SLOW_TEST +#include +#include +#endif +int main() { +#ifdef SLOW_TEST + std::this_thread::sleep_for(std::chrono::seconds(30)); +#endif + return 0; +} +]=]) +file(WRITE "${source}/tests/negative_fail.cpp" "#error Expected compile failure\n") +file(WRITE "${source}/examples/example.cpp" "int main() { return 0; }\n") +file(WRITE "${source}/examples/example_fail.cpp" "#error Expected compile failure\n") +file(WRITE "${source}/stall.cmake" + "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E sleep 30)\n") + +# Runs a command successfully and returns its standard output. +function(run) + execute_process(COMMAND ${ARGV} RESULT_VARIABLE result + OUTPUT_VARIABLE output ERROR_VARIABLE error TIMEOUT 120) + if(NOT result STREQUAL "0") + message(FATAL_ERROR "${ARGV}\n${output}\n${error}\nResult: ${result}") + endif() + set(command_output "${output}" PARENT_SCOPE) +endfunction() + +# Checks the effective timeout of every generated and manually registered test. +function(check_timeouts json timeout compiled overridden) + set(expected unit compile_negative_fail example compile_example_fail manual) + if(compiled) + list(APPEND expected timed_in_source_tests) + endif() + string(JSON count LENGTH "${json}" tests) + list(LENGTH expected expected_count) + if(NOT count EQUAL expected_count) + message(FATAL_ERROR "Expected ${expected_count} tests, got ${count}: ${json}") + endif() + math(EXPR last "${count} - 1") + foreach(index RANGE ${last}) + string(JSON name GET "${json}" tests ${index} name) + if(NOT name IN_LIST expected) + message(FATAL_ERROR "Unexpected or duplicate test: ${name}") + endif() + list(REMOVE_ITEM expected "${name}") + set(wanted "${timeout}") + if(name STREQUAL "manual") + set(wanted 900) + elseif(overridden AND (name STREQUAL "unit" OR name STREQUAL "timed_in_source_tests")) + set(wanted 300) + endif() + string(JSON properties GET "${json}" tests ${index} properties) + string(JSON property_count LENGTH "${properties}") + math(EXPR property_last "${property_count} - 1") + set(found FALSE) + if(property_count GREATER 0) + foreach(property_index RANGE ${property_last}) + string(JSON property GET "${properties}" ${property_index} name) + if(property STREQUAL "TIMEOUT") + string(JSON actual GET "${properties}" ${property_index} value) + if(NOT actual EQUAL wanted) + message(FATAL_ERROR "${name}: expected TIMEOUT ${wanted}, got ${actual}") + endif() + set(found TRUE) + endif() + endforeach() + endif() + if(NOT found) + message(FATAL_ERROR "${name}: missing TIMEOUT (expected ${wanted})") + endif() + endforeach() +endfunction() + +foreach(case default override header_only upper_bound slow) + set(binary "${test_root}/${case}") + set(options -DCOMPILED=ON) + set(timeout 120) + set(compiled TRUE) + set(overridden FALSE) + if(case STREQUAL "override") + list(APPEND options -DPROJECT_TIMEOUT=7 -DOVERRIDE_TEST=ON) + set(timeout 7) + set(overridden TRUE) + elseif(case STREQUAL "header_only") + set(options -DCOMPILED=OFF -DPROJECT_TIMEOUT=7) + set(timeout 7) + set(compiled FALSE) + elseif(case STREQUAL "upper_bound") + list(APPEND options -DPROJECT_TIMEOUT=2147483647) + set(timeout 2147483647) + elseif(case STREQUAL "slow") + list(APPEND options -DPROJECT_TIMEOUT=1 -DSLOW_TESTS=ON) + set(timeout 1) + endif() + run("${CMAKE_COMMAND}" -S "${source}" -B "${binary}" -G Ninja + "-DTOOLKIT_SOURCE=${toolkit_source}" -DCPP_LIBRARY_VERSION=1.0.0 + -DFIXTURE_INSTALL=OFF -DBUILD_DOCS=OFF -DCMAKE_BUILD_TYPE=Debug ${options}) + run("${CMAKE_COMMAND}" --build "${binary}") + run("${ctest}" --test-dir "${binary}" --show-only=json-v1) + check_timeouts("${command_output}" "${timeout}" "${compiled}" "${overridden}") + if(case STREQUAL "default") + run("${CMAKE_COMMAND}" -E chdir "${source}" + "${ctest}" --preset test --test-dir "${binary}" --show-only=json-v1) + check_timeouts("${command_output}" 120 TRUE FALSE) + endif() + if(NOT case STREQUAL "slow") + run("${ctest}" --test-dir "${binary}" --output-on-failure) + else() + foreach(test unit compile_negative_fail) + execute_process( + COMMAND "${ctest}" --test-dir "${binary}" -R "^${test}$" --output-on-failure + RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error TIMEOUT 15) + if(NOT result STREQUAL "8" OR NOT "${output}\n${error}" MATCHES "Timeout") + message(FATAL_ERROR "${test}: expected CTest timeout failure\n${output}\n${error}\n${result}") + endif() + message(STATUS "PASS ${test}: CTest terminates overlong test with TIMEOUT 1") + endforeach() + endif() + message(STATUS "PASS ${case}: effective generated-test timeouts") +endforeach() + +foreach(value 0 -1 0.5 invalid nan inf 2147483648 overflow missing) + if(value STREQUAL "missing") + set(option -DMISSING_TIMEOUT=ON) + elseif(value STREQUAL "overflow") + string(REPEAT "9" 400 oversized) + set(option "-DPROJECT_TIMEOUT=${oversized}") + else() + set(option "-DPROJECT_TIMEOUT=${value}") + endif() + execute_process( + COMMAND "${CMAKE_COMMAND}" -S "${source}" -B "${test_root}/invalid-${value}" -G Ninja + "-DTOOLKIT_SOURCE=${toolkit_source}" -DCPP_LIBRARY_VERSION=1.0.0 + -DFIXTURE_INSTALL=OFF -DBUILD_DOCS=OFF ${option} + RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error TIMEOUT 120) + if(result STREQUAL "0" OR NOT "${output}\n${error}" MATCHES "TEST_TIMEOUT") + message(FATAL_ERROR "Expected TEST_TIMEOUT diagnostic for '${value}'\n${output}\n${error}") + endif() + message(STATUS "PASS invalid TEST_TIMEOUT: ${value}") +endforeach() + +message(STATUS "All generated-test timeout checks passed")