From f9bb54602408b47609053301d1ca8cfa3e65fbe9 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 15:05:49 +0100 Subject: [PATCH 1/5] Prefix WebFront's test, coverage and sanitizer options [#412] ENABLE_TESTING, ENABLE_FUZZING, ENABLE_COVERAGE and ENABLE_SANITIZER_* were generic names shared with an embedding parent: a parent defining them for its own tests built, fuzzed or instrumented WebFront too. They become WEBFRONT_ENABLE_*, declared in cmake/WebFrontTestOptions.cmake; a consumer opts in only with the prefixed name. At the top level the former names still work until WebFront 0.7.0: a value given is moved to the new option with a deprecation warning and removed from the cache, and the OFF defaults left by older build trees are dropped silently. The native detection default no longer needs the top-level test. TestOptionsConfiguration covers the migration and the isolation of a subproject; the frontend-consumer fixture sets the parent's generic options and checks that WebFront adds no tests, fuzzers, coverage or sanitizers. CI, AGENTS.md, the README and the guides use the new names. --- .github/actions/wf-driver/action.yml | 2 +- .github/workflows/BuildAndTest.yml | 12 ++-- .github/workflows/MddlogIntegration.yml | 6 +- .github/workflows/ReleaseVersion.yml | 2 +- AGENTS.md | 12 ++-- CMakeLists.txt | 16 ++--- README.md | 6 +- cmake/Sanitizers.cmake | 19 ++---- cmake/WebFrontTestOptions.cmake | 35 ++++++++++ docs/AUTOMATION.md | 2 +- docs/CHANGELOG.md | 7 ++ docs/DEVELOPER_ENVIRONMENT.md | 4 +- docs/EMBEDDED_ASSETS.md | 2 +- docs/FRONTENDS.md | 6 +- docs/HTTP_ASSETS.md | 2 +- docs/WEBKITGTK.md | 2 +- docs/WKWEBVIEW.md | 2 +- docs/adr/ADR-001-coeur-cpp23-header-only.md | 2 +- docs/adr/ADR-012-preuves-et-tests.md | 2 +- .../adr/ADR-017-acces-direct-aux-frontends.md | 2 +- docs/adr/ADR-018-acces-au-dom.md | 2 +- docs/mddlog-integration.md | 2 +- js/core/WebFrontAssets.cmake | 4 +- js/developer/tools/PUBLISHING.md | 2 +- test/cmake/CheckFrontendConsumer.cmake | 10 +++ test/cmake/CheckNewcomerDocs.cmake | 6 +- test/cmake/CheckTestOptions.cmake | 64 +++++++++++++++++++ .../frontend-consumer/provider/CMakeLists.txt | 36 ++++++++++- test/cmake/test-options/CMakeLists.txt | 13 ++++ test/fuzz/CMakeLists.txt | 6 +- test/fuzz/README.md | 8 +-- test/unit/CMakeLists.txt | 12 +++- 32 files changed, 234 insertions(+), 74 deletions(-) create mode 100644 cmake/WebFrontTestOptions.cmake create mode 100644 test/cmake/CheckTestOptions.cmake create mode 100644 test/cmake/test-options/CMakeLists.txt diff --git a/.github/actions/wf-driver/action.yml b/.github/actions/wf-driver/action.yml index ad444f97..438cd55e 100644 --- a/.github/actions/wf-driver/action.yml +++ b/.github/actions/wf-driver/action.yml @@ -25,7 +25,7 @@ runs: - name: Build webfront-wf shell: bash run: | - cmake -S . -B build-driver -G Ninja -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON \ + cmake -S . -B build-driver -G Ninja -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON \ -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK \ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF cmake --build build-driver --target webfront-wf --parallel 2 diff --git a/.github/workflows/BuildAndTest.yml b/.github/workflows/BuildAndTest.yml index a951ee80..99875827 100644 --- a/.github/workflows/BuildAndTest.yml +++ b/.github/workflows/BuildAndTest.yml @@ -78,7 +78,7 @@ jobs: build_type: Debug test_env: {WEBKIT_DISABLE_SANDBOX_THIS_IS_DANGEROUS: '1'} # GCC 16 compiles the optional C++26 reflection layer of the forms (#383): its tests must not be skipped here. - options: -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DENABLE_COVERAGE=ON -DWEBFRONT_REQUIRE_REFLECTION_TESTS=ON + options: -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DWEBFRONT_ENABLE_COVERAGE=ON -DWEBFRONT_REQUIRE_REFLECTION_TESTS=ON runs-on: ${{ matrix.os }} # Only the Linux job runs in the prebuilt toolchain image; an empty value means no container. container: ${{ matrix.use_image && fromJSON(format('{{"image":"{0}","credentials":{{"username":"{1}","password":"{2}"}},"options":"--shm-size=1g"}}', needs.linux-image.outputs.image, github.actor, github.token)) || '' }} @@ -123,7 +123,7 @@ jobs: - name: Configure run: >- cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON + -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_SCAN_FOR_MODULES=OFF ${{ matrix.options }} @@ -323,7 +323,7 @@ jobs: # No compiler cache: a new user compiles everything. - name: Configure shell: bash - run: cmake -S . -B build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_SCAN_FOR_MODULES=OFF + run: cmake -S . -B build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_SCAN_FOR_MODULES=OFF - name: Portability tests shell: bash run: ctest --test-dir build -C Release -L portability --output-on-failure --no-tests=error @@ -375,9 +375,9 @@ jobs: - name: Configure hardened sanitizer tests run: >- cmake -S . -B build-sanitizers -DCMAKE_BUILD_TYPE=RelWithDebInfo - -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_BUILD_EXAMPLES=OFF -DENABLE_TESTING=ON -DENABLE_CACHE=OFF + -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_BUILD_EXAMPLES=OFF -DWEBFRONT_ENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_SCAN_FOR_MODULES=OFF - ${{ matrix.sanitizer == 'thread' && '-DCMAKE_CXX_FLAGS=-stdlib=libc++ -DENABLE_SANITIZER_THREAD=ON' || '-DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DENABLE_FUZZING=ON -DWEBFRONT_GZIP_DIFFERENTIAL=ON' }} + ${{ matrix.sanitizer == 'thread' && '-DCMAKE_CXX_FLAGS=-stdlib=libc++ -DWEBFRONT_ENABLE_SANITIZER_THREAD=ON' || '-DWEBFRONT_ENABLE_SANITIZER_ADDRESS=ON -DWEBFRONT_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DWEBFRONT_ENABLE_FUZZING=ON -DWEBFRONT_GZIP_DIFFERENTIAL=ON' }} - name: Build run: cmake --build build-sanitizers --parallel 2 - name: Run full CEF-off suite @@ -459,7 +459,7 @@ jobs: # The registry packages and the pinned bootstrap environment are downloaded and verified here; wf then builds the rest. - name: Configure CEF integration build - run: cmake . -B ${{github.workspace}}/build-cef -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_SCAN_FOR_MODULES=OFF + run: cmake . -B ${{github.workspace}}/build-cef -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_EMBED_CEF=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DWEBFRONT_ENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_SCAN_FOR_MODULES=OFF - name: Build browser test run: cmake --build ${{github.workspace}}/build-cef --target webtest developer_integration webfront-wf --parallel 2 diff --git a/.github/workflows/MddlogIntegration.yml b/.github/workflows/MddlogIntegration.yml index 4f9e261f..12f9f28f 100644 --- a/.github/workflows/MddlogIntegration.yml +++ b/.github/workflows/MddlogIntegration.yml @@ -47,7 +47,7 @@ jobs: - name: Configure source integration run: >- cmake -S . -B build-mddlog-source -G Ninja - -DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF + -DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/dependencies/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake -DWEBFRONT_USE_MDDLOG=ON -DWEBFRONT_MDDLOG_SOURCE_DIR=${{ github.workspace }}/dependencies/mddlog @@ -60,7 +60,7 @@ jobs: - name: Configure installed integration run: >- cmake -S . -B build-mddlog-install -G Ninja - -DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF + -DCMAKE_BUILD_TYPE=Release -DENABLE_CACHE=OFF -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/dependencies/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake -DWEBFRONT_USE_MDDLOG=ON -DCMAKE_PREFIX_PATH=${{ github.workspace }}/mddlog-install @@ -124,7 +124,7 @@ jobs: - name: Configure instrumented source integration run: >- cmake -S . -B build-sanitized -G Ninja - -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_CACHE=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF + -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_CACHE=OFF -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/dependencies/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake "-DCMAKE_CXX_FLAGS=-stdlib=libc++ ${{ matrix.flags }} -fno-omit-frame-pointer" "-DCMAKE_EXE_LINKER_FLAGS=${{ matrix.flags }}" diff --git a/.github/workflows/ReleaseVersion.yml b/.github/workflows/ReleaseVersion.yml index cb698686..380bdbcd 100644 --- a/.github/workflows/ReleaseVersion.yml +++ b/.github/workflows/ReleaseVersion.yml @@ -22,7 +22,7 @@ jobs: with: version: '4.4.4' - name: Detect project version with CMake - run: cmake -S . -B build -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF + run: cmake -S . -B build -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_BUILD_EXAMPLES=OFF - name: Compare release tag with header and CMake env: RELEASE_TAG: ${{ github.event.release.tag_name || github.ref_name }} diff --git a/AGENTS.md b/AGENTS.md index 544f6481..dd1114a4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -48,7 +48,7 @@ cmake --build . --parallel 2 # Fast, portable C++ baseline (no CEF download) cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \ - -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON + -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON cmake --build build --parallel ctest --test-dir build --output-on-failure --parallel 4 @@ -58,13 +58,13 @@ ctest --test-dir build --output-on-failure --parallel 4 # Linux real-browser integration test: configure downloads and verifies the pinned bootstrap environment and the packages # of the local npm registry; the tests build the rest with wf cmake -S . -B build-cef -DCMAKE_BUILD_TYPE=Release \ - -DWEBFRONT_EMBED_CEF=ON -DENABLE_TESTING=ON + -DWEBFRONT_EMBED_CEF=ON -DWEBFRONT_ENABLE_TESTING=ON cmake --build build-cef --target webtest webfront-wf --parallel ctest --test-dir build-cef -L web-integration --output-on-failure --parallel 4 ``` -Build the developer environment with wf (the driver comes from any build with `ENABLE_TESTING=ON`), as +Build the developer environment with wf (the driver comes from any build with `WEBFRONT_ENABLE_TESTING=ON`), as `js/developer/tools/PUBLISHING.md` describes: ```bash @@ -78,7 +78,7 @@ Important CMake options: The headers of the embedded assets are generated, and checked by CTest, in pure CMake (`js/core/EmbedAsset.cmake`; the `webfront-embedded-assets` target regenerates them). Normal C++ builds consume the versioned headers. Configuring with -`ENABLE_TESTING=ON` downloads the pinned bootstrap environment and the packages of the test registry, each verified +`WEBFRONT_ENABLE_TESTING=ON` downloads the pinned bootstrap environment and the packages of the test registry, each verified against its SHA-512; `-DWEBFRONT_BOOTSTRAP_DIR` and `-DWEBFRONT_REGISTRY_DIR` replace those downloads on a machine without network access. @@ -86,9 +86,9 @@ without network access. - `WEBFRONT_EMBED_WEBVIEW2=OFF` (default): Windows-only opt-in SDK and static loader for `WebView2Frontend`; requires the separately installed Evergreen runtime. Select it explicitly with `WebFrontWithFrontend`. With tests enabled, `WEBFRONT_WEBTEST_FRONTEND=WebView2` runs the shared Jasmine suite and lifecycle cases. - `WEBFRONT_EMBED_WKWEBVIEW=OFF` (default): macOS 13.3+ opt-in Cocoa/WebKit frontend, with no engine download. Select `WebFrontWithFrontend` on the main thread; `WEBFRONT_WEBTEST_FRONTEND=WKWebView` runs Jasmine and lifecycle coverage. -- `ENABLE_TESTING=ON` (default `OFF`): build Catch2 and Jasmine test targets. CI and contributor commands must pass it explicitly. +- `WEBFRONT_ENABLE_TESTING=ON` (default `OFF`): build Catch2 and Jasmine test targets. CI and contributor commands must pass it explicitly. The test, fuzzing, coverage and sanitizer options (`WEBFRONT_ENABLE_SANITIZER_*`) carry the `WEBFRONT_` prefix so that a parent's own `ENABLE_TESTING` or `ENABLE_SANITIZER_ADDRESS` never builds or instruments WebFront's tests; the former unprefixed names are accepted, with a deprecation warning, only at the top level and until 0.7.0 (`cmake/WebFrontTestOptions.cmake`). - `WEBFRONT_BUILD_EXAMPLES` (default `ON` only for the top-level project): build the examples. As a subproject (`add_subdirectory`), link `WebFront::WebFront`; no examples, tests or global compiler settings are added. -- `ENABLE_COVERAGE=ON`: add GCC/Clang coverage instrumentation to the C++ tests. +- `WEBFRONT_ENABLE_COVERAGE=ON`: add GCC/Clang coverage instrumentation to the C++ tests. If the environment provides a read-only default ccache directory, set `CCACHE_DIR` to a writable temporary directory for local builds. Do not encode machine-specific cache paths in project files. In CI, `ENABLE_CACHE=OFF` disables automatic cache discovery while `CMAKE_CXX_COMPILER_LAUNCHER=sccache` explicitly enables sccache; a PATH/version probe runs on all three platforms. The combined Linux job uses Debug with GCC coverage on every PR; Windows and macOS use Release. The WebKitGTK sandbox opt-out is confined to the Linux test step and trusted fixtures. diff --git a/CMakeLists.txt b/CMakeLists.txt index aa154da9..2e7f8f71 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,11 +11,10 @@ else() endif() option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF) -option(ENABLE_TESTING "Enable Test Builds" OFF) +include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/WebFrontTestOptions.cmake) +webfront_declare_test_options(${WEBFRONT_IS_TOP_LEVEL}) option(WEBFRONT_BUILD_AUTOMATION "Build the optional local developer CLI/MCP launcher" OFF) option(WEBFRONT_BUILD_EXAMPLES "Build the example applications" ${WEBFRONT_IS_TOP_LEVEL}) -option(ENABLE_COVERAGE "Enable test coverage instrumentation" OFF) -option(ENABLE_FUZZING "Enable Fuzzing Builds" OFF) option(WEBFRONT_GZIP_DIFFERENTIAL "Build test-only gzip/zlib differential checks" OFF) option(WEBFRONT_USE_MDDLOG "Use the compiled mddlog diagnostic adapter" OFF) # The experimental gate must be selected before project() probes the compiler. @@ -32,8 +31,7 @@ project(WebFront LANGUAGES CXX VERSION ${VERSION_STRING}) include(cmake/Frontends.cmake) # Applications need no -DWEBFRONT_EMBED_* option: unless the user decided, this platform's native window # engine is enabled when its dependencies are present. Test and fuzzing builds keep explicit selection. -# An embedding parent's variables of those names do not decide for its consumers. -if(NOT WEBFRONT_IS_TOP_LEVEL OR (NOT ENABLE_TESTING AND NOT ENABLE_FUZZING)) +if(NOT WEBFRONT_ENABLE_TESTING AND NOT WEBFRONT_ENABLE_FUZZING) set(WEBFRONT_AUTODETECT_NATIVE_DEFAULT ON) else() set(WEBFRONT_AUTODETECT_NATIVE_DEFAULT OFF) @@ -127,7 +125,7 @@ webfront_add_embedded_assets() # Opt-in consumer test registration; inclusion alone downloads nothing and registers no tests. include(WebFrontJasmine) -if(WEBFRONT_BUILD_AUTOMATION OR (ENABLE_TESTING AND +if(WEBFRONT_BUILD_AUTOMATION OR (WEBFRONT_ENABLE_TESTING AND (WEBFRONT_EMBED_CEF OR WEBFRONT_EMBED_WKWEBVIEW OR WEBFRONT_EMBED_WEBVIEW2 OR WEBFRONT_EMBED_WEBKITGTK))) webfront_default_embedded_frontend(_automation_default FALLBACK CEF) webfront_select_frontend(WEBFRONT_AUTOMATION_FRONTEND "${_automation_default}" @@ -144,15 +142,15 @@ if(WEBFRONT_BUILD_AUTOMATION OR (ENABLE_TESTING AND webfront_setup_frontends_for_target(webfront-agent) endif() -if(ENABLE_TESTING OR ENABLE_FUZZING) +if(WEBFRONT_ENABLE_TESTING OR WEBFRONT_ENABLE_FUZZING) include(TestHardening) endif() -if(ENABLE_FUZZING) +if(WEBFRONT_ENABLE_FUZZING) add_subdirectory(test/fuzz) endif() -if(ENABLE_TESTING) +if(WEBFRONT_ENABLE_TESTING) enable_testing() add_subdirectory(test/unit) add_subdirectory(test/web) diff --git a/README.md b/README.md index 9095980a..2c982a7b 100644 --- a/README.md +++ b/README.md @@ -122,7 +122,7 @@ When the engine is missing, configuration still succeeds. CMake prints a `Native **Advanced options.** -- Choose the engine yourself with `-DWEBFRONT_EMBED_WEBVIEW2=ON|OFF`, `-DWEBFRONT_EMBED_WKWEBVIEW=ON|OFF` or `-DWEBFRONT_EMBED_WEBKITGTK=ON|OFF`; an explicit value is never replaced by the detection. `-DWEBFRONT_AUTODETECT_NATIVE=OFF` disables it. Test builds (`-DENABLE_TESTING=ON`) keep the explicit selection. +- Choose the engine yourself with `-DWEBFRONT_EMBED_WEBVIEW2=ON|OFF`, `-DWEBFRONT_EMBED_WKWEBVIEW=ON|OFF` or `-DWEBFRONT_EMBED_WEBKITGTK=ON|OFF`; an explicit value is never replaced by the detection. `-DWEBFRONT_AUTODETECT_NATIVE=OFF` disables it. Test builds (`-DWEBFRONT_ENABLE_TESTING=ON`) keep the explicit selection. - Automatic engine choices are recalculated on each configuration and do not create an engine option in the cache. To return from an explicit macOS choice to automatic detection, run `cmake .. -UWEBFRONT_EMBED_WKWEBVIEW` (or remove the corresponding engine option on another platform). - Another project directory, and another environment archive, can be passed: `examples/WebFrontLifeDeveloper [ ]`, for instance an environment [built from the sources](docs/DEVELOPER_ENVIRONMENT.md#environment-distribution-and-offline-tests-maintainers). @@ -295,7 +295,7 @@ int main() { To get a native window when one can be opened and the system browser otherwise (for example over SSH, in a container or in CI, where no display exists), use `WebFrontWithFrontend`: no `#if` is needed, and the reason for a fallback is printed once. See [docs/FRONTENDS.md](docs/FRONTENDS.md). -Native engines are detected by default for consumer builds, whatever variables the parent project defines, and for standalone builds except with `ENABLE_TESTING=ON` or `ENABLE_FUZZING=ON`. The helper applies the native engine's target setup and defines `WEBFRONT_NATIVE_WINDOW` only when that engine is enabled; otherwise CMake prints installation advice and the application uses the default browser. On Windows, detection requires an MSVC-compatible compiler and downloads the pinned WebView2 SDK; the Evergreen runtime must be installed separately. Linux needs WebKitGTK 6.0 development files, and macOS needs Clang and macOS 13.3 or later. Explicit `WEBFRONT_EMBED_=ON|OFF` values take precedence; `WEBFRONT_AUTODETECT_NATIVE=OFF` disables detection. No option needs to be set before `add_subdirectory`/CPM for the default path. +Native engines are detected by default, except in WebFront's own test and fuzzing builds (`WEBFRONT_ENABLE_TESTING=ON` or `WEBFRONT_ENABLE_FUZZING=ON`); a parent project's own `ENABLE_TESTING` or `ENABLE_FUZZING` affects neither the detection nor WebFront's tests. The helper applies the native engine's target setup and defines `WEBFRONT_NATIVE_WINDOW` only when that engine is enabled; otherwise CMake prints installation advice and the application uses the default browser. On Windows, detection requires an MSVC-compatible compiler and downloads the pinned WebView2 SDK; the Evergreen runtime must be installed separately. Linux needs WebKitGTK 6.0 development files, and macOS needs Clang and macOS 13.3 or later. Explicit `WEBFRONT_EMBED_=ON|OFF` values take precedence; `WEBFRONT_AUTODETECT_NATIVE=OFF` disables detection. No option needs to be set before `add_subdirectory`/CPM for the default path. For explicit engine selection, `webfront_native_frontend_option(out)` and `webfront_setup_frontends_for_target(MyApp)` are also callable from the parent or other directories. The latter applies setup for all enabled engines; the native helper selects only the platform's native engine and never CEF. See [WKWebView](docs/WKWEBVIEW.md), [WebKitGTK](docs/WEBKITGTK.md) and the [frontend architecture](docs/adr/README.md). @@ -303,7 +303,7 @@ For explicit engine selection, `webfront_native_frontend_option(out)` and `webfr ```bash cmake -S . -B build -DCMAKE_BUILD_TYPE=Release \ - -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON + -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON cmake --build build --parallel 2 ctest --test-dir build --output-on-failure --parallel 4 ``` diff --git a/cmake/Sanitizers.cmake b/cmake/Sanitizers.cmake index bfac05c8..6882324c 100644 --- a/cmake/Sanitizers.cmake +++ b/cmake/Sanitizers.cmake @@ -1,9 +1,7 @@ function(enable_sanitizers target) cmake_parse_arguments(SANITIZER_OPTIONS "NO_COVERAGE" "" "" ${ARGN}) if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") - option(ENABLE_COVERAGE "Enable coverage reporting for gcc/clang" FALSE) - - if(ENABLE_COVERAGE AND NOT SANITIZER_OPTIONS_NO_COVERAGE) + if(WEBFRONT_ENABLE_COVERAGE AND NOT SANITIZER_OPTIONS_NO_COVERAGE) # The server tests run threads: non-atomic counters can race and give lcov negative counts. target_compile_options(${target} INTERFACE --coverage -fprofile-update=atomic -O0 -g) target_link_libraries(${target} INTERFACE --coverage) @@ -11,23 +9,19 @@ function(enable_sanitizers target) set(SANITIZERS "") - option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" OFF) - if(ENABLE_SANITIZER_ADDRESS) + if(WEBFRONT_ENABLE_SANITIZER_ADDRESS) list(APPEND SANITIZERS "address") endif() - option(ENABLE_SANITIZER_LEAK "Enable leak sanitizer" OFF) - if(ENABLE_SANITIZER_LEAK) + if(WEBFRONT_ENABLE_SANITIZER_LEAK) list(APPEND SANITIZERS "leak") endif() - option(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "Enable undefined behavior sanitizer" OFF) - if(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR) + if(WEBFRONT_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR) list(APPEND SANITIZERS "undefined") endif() - option(ENABLE_SANITIZER_THREAD "Enable thread sanitizer" OFF) - if(ENABLE_SANITIZER_THREAD) + if(WEBFRONT_ENABLE_SANITIZER_THREAD) if("address" IN_LIST SANITIZERS OR "leak" IN_LIST SANITIZERS) message(WARNING "Thread sanitizer does not work with Address and Leak sanitizer enabled") else() @@ -35,8 +29,7 @@ function(enable_sanitizers target) endif() endif() - option(ENABLE_SANITIZER_MEMORY "Enable memory sanitizer" OFF) - if(ENABLE_SANITIZER_MEMORY AND CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") + if(WEBFRONT_ENABLE_SANITIZER_MEMORY AND CMAKE_CXX_COMPILER_ID MATCHES ".*Clang") message(WARNING "Memory sanitizer requires all the code (including libc++) to be MSan-instrumented otherwise it reports false positives") if("address" IN_LIST SANITIZERS OR "thread" IN_LIST SANITIZERS diff --git a/cmake/WebFrontTestOptions.cmake b/cmake/WebFrontTestOptions.cmake new file mode 100644 index 00000000..48b07e2f --- /dev/null +++ b/cmake/WebFrontTestOptions.cmake @@ -0,0 +1,35 @@ +# WebFront's own test, fuzzing, coverage and sanitizer switches. They carry the project prefix so that an embedding +# parent's ENABLE_TESTING, ENABLE_FUZZING, ENABLE_COVERAGE or ENABLE_SANITIZER_* never build or instrument WebFront's +# tests; a consumer that wants them sets WEBFRONT_ENABLE_ explicitly. +# +# The former unprefixed names are still read when WebFront is the top-level project, until WebFront 0.7.0: a value +# given there is moved to the new option (with a deprecation warning) and removed from the cache, so that a later +# -DWEBFRONT_ENABLE_ is not overridden by a stale entry. A false former value that changes nothing is dropped +# silently. +macro(webfront_declare_test_options is_top_level) + option(WEBFRONT_ENABLE_TESTING "Build WebFront's tests" OFF) + option(WEBFRONT_ENABLE_FUZZING "Build WebFront's fuzzers" OFF) + option(WEBFRONT_ENABLE_COVERAGE "Instrument WebFront's tests for GCC/Clang coverage" OFF) + option(WEBFRONT_ENABLE_SANITIZER_ADDRESS "Build WebFront's tests with the address sanitizer" OFF) + option(WEBFRONT_ENABLE_SANITIZER_LEAK "Build WebFront's tests with the leak sanitizer" OFF) + option(WEBFRONT_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "Build WebFront's tests with the undefined behavior sanitizer" OFF) + option(WEBFRONT_ENABLE_SANITIZER_THREAD "Build WebFront's tests with the thread sanitizer" OFF) + option(WEBFRONT_ENABLE_SANITIZER_MEMORY "Build WebFront's tests with the memory sanitizer" OFF) + foreach(_webfront_name TESTING FUZZING COVERAGE SANITIZER_ADDRESS SANITIZER_LEAK SANITIZER_UNDEFINED_BEHAVIOR + SANITIZER_THREAD SANITIZER_MEMORY) + if(${is_top_level} AND DEFINED CACHE{ENABLE_${_webfront_name}}) + set(_webfront_value "$CACHE{ENABLE_${_webfront_name}}") + # Build trees configured before the rename hold the former OFF defaults: drop those without noise. + if(NOT _webfront_value AND NOT WEBFRONT_ENABLE_${_webfront_name}) + unset(ENABLE_${_webfront_name} CACHE) + continue() + endif() + message(DEPRECATION "ENABLE_${_webfront_name} is deprecated and will be removed in WebFront 0.7.0: " + "use WEBFRONT_ENABLE_${_webfront_name} (set to ${_webfront_value} for this build)") + unset(ENABLE_${_webfront_name} CACHE) + set_property(CACHE WEBFRONT_ENABLE_${_webfront_name} PROPERTY VALUE "${_webfront_value}") + endif() + endforeach() + unset(_webfront_name) + unset(_webfront_value) +endmacro() diff --git a/docs/AUTOMATION.md b/docs/AUTOMATION.md index 2002cb89..06ffcc90 100644 --- a/docs/AUTOMATION.md +++ b/docs/AUTOMATION.md @@ -20,7 +20,7 @@ Enable an embedded frontend and the launcher. For example, on macOS: ```sh cmake -S . -B build-agent -DCMAKE_BUILD_TYPE=Release \ - -DWEBFRONT_EMBED_WKWEBVIEW=ON -DWEBFRONT_BUILD_AUTOMATION=ON -DENABLE_TESTING=ON + -DWEBFRONT_EMBED_WKWEBVIEW=ON -DWEBFRONT_BUILD_AUTOMATION=ON -DWEBFRONT_ENABLE_TESTING=ON cmake --build build-agent --target webfront-agent webfront-wf --parallel 2 ``` diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 714fb022..76d74693 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +- Prefix WebFront's test options (#412): `WEBFRONT_ENABLE_TESTING`, `WEBFRONT_ENABLE_FUZZING`, + `WEBFRONT_ENABLE_COVERAGE` and `WEBFRONT_ENABLE_SANITIZER_{ADDRESS,LEAK,UNDEFINED_BEHAVIOR,THREAD,MEMORY}` replace + the unprefixed `ENABLE_*` names (still `OFF` by default). A parent project's own generic variables no longer build + WebFront's tests or fuzzers, instrument it for coverage or sanitizers, or disable its native detection; a consumer that wants WebFront's tests sets the prefixed option. At the top level the + former names still work until WebFront 0.7.0: a value given is moved to the new option, with a deprecation warning, + and removed from the cache. CI, the documentation and `TestOptionsConfiguration` use the new names. + - Stabilise the desktop-native tier (#416): before removing its temporary WebView2 profile, the automation owner waits up to 5 s for the browser processes it launched to exit and ends those still running (at once after a forced exit, which also keeps the status of an exit that completes meanwhile), then retries files pending deletion for 2 s. diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index 89718ee6..ed8c4357 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -542,7 +542,7 @@ webfront-wf --project [--environment --integrity /bootstrap/` and verifies the + by an explicit pull request). With `WEBFRONT_ENABLE_TESTING=ON`, configure downloads it to `/bootstrap/` and verifies the digest; a wrong digest or an unreachable URL stops the configure. On a machine without network access, pass `-DWEBFRONT_BOOTSTRAP_DIR=`: the archive is verified the same way. - `--environment` and `--integrity` run an archive built elsewhere, such as the one built from the current sources (the @@ -667,7 +667,7 @@ committed: the archives live in the build directory. ```sh cmake -S . -B build-native -DCMAKE_BUILD_TYPE=Release \ -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WKWEBVIEW=ON \ - -DWEBFRONT_WEBTEST_FRONTEND=WKWebView -DENABLE_TESTING=ON + -DWEBFRONT_WEBTEST_FRONTEND=WKWebView -DWEBFRONT_ENABLE_TESTING=ON cmake --build build-native --parallel ctest --test-dir build-native -R 'Developer|LifeEmbedded' --output-on-failure ``` diff --git a/docs/EMBEDDED_ASSETS.md b/docs/EMBEDDED_ASSETS.md index cd1f5fa3..6885d106 100644 --- a/docs/EMBEDDED_ASSETS.md +++ b/docs/EMBEDDED_ASSETS.md @@ -28,7 +28,7 @@ the guard reports current sizes. ## Maintenance -CMake 3.31 or newer is the only tool: regeneration and the asset checks of `ENABLE_TESTING=ON` are CMake scripts, and +CMake 3.31 or newer is the only tool: regeneration and the asset checks of `WEBFRONT_ENABLE_TESTING=ON` are CMake scripts, and normal library consumers need neither. From the repository root: ```sh diff --git a/docs/FRONTENDS.md b/docs/FRONTENDS.md index 5f0c2c71..c06e7b82 100644 --- a/docs/FRONTENDS.md +++ b/docs/FRONTENDS.md @@ -130,7 +130,7 @@ Build one explicitly, then launch its executable (the macOS executable is inside For comparable Linux timings, use Release without coverage: ```bash -cmake -S . -B build-performance -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=ON \ +cmake -S . -B build-performance -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_ENABLE_TESTING=ON \ -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK cmake --build build-performance --target webkitgtk_transport_benchmark --parallel 2 cd test/web @@ -168,8 +168,8 @@ An explicit normal or cached option is never replaced, even if it equals the las A missing engine only prints a status; the Life examples then use the default browser and CMake explains what to install. Platforms without a registered native engine use the default browser as well. `-DWEBFRONT_AUTODETECT_NATIVE=OFF` turns the detection off. CEF is never detected. -`ENABLE_TESTING` and `ENABLE_FUZZING` only disable the detection of a top-level WebFront build: a -parent project that defines them for its own purposes does not change the detection of its consumers. +`WEBFRONT_ENABLE_TESTING` and `WEBFRONT_ENABLE_FUZZING` disable the detection. A parent project's own `ENABLE_TESTING` or +`ENABLE_FUZZING` changes neither the detection nor WebFront's tests: only the prefixed options do. Consumers can call `webfront_use_native_window(target)` after linking `WebFront::WebFront`. It applies the native engine's setup and defines `WEBFRONT_NATIVE_WINDOW` on that target when diff --git a/docs/HTTP_ASSETS.md b/docs/HTTP_ASSETS.md index bcabf21e..f065affc 100644 --- a/docs/HTTP_ASSETS.md +++ b/docs/HTTP_ASSETS.md @@ -176,7 +176,7 @@ Filesystem reads remain synchronous on that context. ## Manual benchmarks and differential validation With a CEF-off Release test build configured, build the optional tools explicitly. -`gzip_decoder_benchmark` is unavailable when `ENABLE_SANITIZER_THREAD=ON`; use a build +`gzip_decoder_benchmark` is unavailable when `WEBFRONT_ENABLE_SANITIZER_THREAD=ON`; use a build with ThreadSanitizer disabled for the commands below: ```sh diff --git a/docs/WEBKITGTK.md b/docs/WEBKITGTK.md index 34ae02e1..30d56456 100644 --- a/docs/WEBKITGTK.md +++ b/docs/WEBKITGTK.md @@ -22,7 +22,7 @@ Install development packages before configuring: ```bash cmake -S . -B build-webkitgtk -DCMAKE_BUILD_TYPE=Release \ - -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WEBKITGTK=ON -DENABLE_TESTING=ON \ + -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_ENABLE_TESTING=ON \ -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK cmake --build build-webkitgtk --parallel 2 ctest --test-dir build-webkitgtk -L web-integration --output-on-failure --no-tests=error diff --git a/docs/WKWEBVIEW.md b/docs/WKWEBVIEW.md index 28cd63a8..8a4af013 100644 --- a/docs/WKWEBVIEW.md +++ b/docs/WKWEBVIEW.md @@ -149,7 +149,7 @@ for LAN hosts; the default address remains loopback. ```bash cmake -S . -B build-wkwebview -DCMAKE_BUILD_TYPE=Release \ -DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_EMBED_WKWEBVIEW=ON \ - -DENABLE_TESTING=ON -DWEBFRONT_WEBTEST_FRONTEND=WKWebView + -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_WEBTEST_FRONTEND=WKWebView cmake --build build-wkwebview --parallel ctest --test-dir build-wkwebview --output-on-failure ``` diff --git a/docs/adr/ADR-001-coeur-cpp23-header-only.md b/docs/adr/ADR-001-coeur-cpp23-header-only.md index 056182cb..2f8625a4 100644 --- a/docs/adr/ADR-001-coeur-cpp23-header-only.md +++ b/docs/adr/ADR-001-coeur-cpp23-header-only.md @@ -42,7 +42,7 @@ la spécialisation. WebFront demeure expérimental ; aucune API générale de co ou de DOM C++ n’est acquise. Le projet parent conserve ses réglages globaux. Les exemples ne sont activés par défaut -qu’au niveau principal, les tests demandent `ENABLE_TESTING=ON`. L’adaptateur mddlog compilé +qu’au niveau principal, les tests demandent `WEBFRONT_ENABLE_TESTING=ON`. L’adaptateur mddlog compilé est une exception optionnelle documentée par l’ADR-011. ## Options écartées et motifs diff --git a/docs/adr/ADR-012-preuves-et-tests.md b/docs/adr/ADR-012-preuves-et-tests.md index 4f2c894b..f180b300 100644 --- a/docs/adr/ADR-012-preuves-et-tests.md +++ b/docs/adr/ADR-012-preuves-et-tests.md @@ -32,7 +32,7 @@ C++, se ferme et fournit un statut de processus significatif. CTest borne les te timeouts. La CI Linux utilise CEF/Xvfb ; les moteurs natifs ont leurs suites de cycle de vie lorsque configurés. -Le socle de validation est une configuration Release sans CEF avec `ENABLE_TESTING=ON`, +Le socle de validation est une configuration Release sans CEF avec `WEBFRONT_ENABLE_TESTING=ON`, construction puis CTest. Les changements de bridge, cycle de vie navigateur, modules servis, assets Jasmine ou frontend CEF exigent aussi l’intégration CEF/Xvfb. Les voies natives complètent cette couverture selon la modification. diff --git a/docs/adr/ADR-017-acces-direct-aux-frontends.md b/docs/adr/ADR-017-acces-direct-aux-frontends.md index 74227d93..22b63683 100644 --- a/docs/adr/ADR-017-acces-direct-aux-frontends.md +++ b/docs/adr/ADR-017-acces-direct-aux-frontends.md @@ -417,7 +417,7 @@ Chacun fera l'objet d'une issue dédiée : - Benchmark WKWebView : [WKWebViewTransportBenchmark.cpp](../../test/web/WKWebViewTransportBenchmark.cpp), [sondes d'API](../../test/web/wkwebview-transport-contracts.html), enregistrement dans [WKWebViewSupport.cmake](../../cmake/WKWebViewSupport.cmake). Configuration macOS : - `-DWEBFRONT_EMBED_WKWEBVIEW=ON -DWEBFRONT_WEBTEST_FRONTEND=WKWebView -DENABLE_TESTING=ON` ; + `-DWEBFRONT_EMBED_WKWEBVIEW=ON -DWEBFRONT_WEBTEST_FRONTEND=WKWebView -DWEBFRONT_ENABLE_TESTING=ON` ; `ctest --test-dir -R '^WKWebViewTransport(Benchmark|Contracts)$' --output-on-failure`. - API publiques Apple (documentation et en-têtes du SDK macOS, vérifiés le 2026-10-25) : [corps des messages](https://developer.apple.com/documentation/webkit/wkscriptmessage/body), diff --git a/docs/adr/ADR-018-acces-au-dom.md b/docs/adr/ADR-018-acces-au-dom.md index 72da94c7..65561121 100644 --- a/docs/adr/ADR-018-acces-au-dom.md +++ b/docs/adr/ADR-018-acces-au-dom.md @@ -136,7 +136,7 @@ Les prototypes ne font pas partie du dépôt : ils sont consultables dans le com - `DomPrototype.cpp` et `dom-prototype.html` : les scénarios, les vérifications du DOM et le rapport. Le programme échoue sur un DOM faux ou un rapport absent, jamais sur une durée. -Exécution dans ce commit (build `-DWEBFRONT_EMBED_WEBKITGTK=ON -DENABLE_TESTING=ON`, Release) : construire la cible +Exécution dans ce commit (build `-DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_ENABLE_TESTING=ON`, Release) : construire la cible `webkitgtk_dom_prototype`, extraire les archives `react-19.3.1`, `react-dom-19.3.1` et `scheduler-0.28.0` de `build/registry-archives/` dans un répertoire de paquets, puis lancer le programme sous Xvfb depuis `test/web/dom` avec ce répertoire en argument. diff --git a/docs/mddlog-integration.md b/docs/mddlog-integration.md index 728379fc..089f9dbd 100644 --- a/docs/mddlog-integration.md +++ b/docs/mddlog-integration.md @@ -28,7 +28,7 @@ For example, with an upstream Clang/libc++ toolchain providing its std module ma ```bash cmake -S . -B build-mddlog -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_TOOLCHAIN_FILE=/path/to/mddlog/cmake/toolchains/linux-clang21-libcxx.cmake \ - -DENABLE_TESTING=ON -DWEBFRONT_USE_MDDLOG=ON -DWEBFRONT_MDDLOG_SOURCE_DIR=/path/to/mddlog + -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_USE_MDDLOG=ON -DWEBFRONT_MDDLOG_SOURCE_DIR=/path/to/mddlog cmake --build build-mddlog --parallel ctest --test-dir build-mddlog --output-on-failure --no-tests=error ``` diff --git a/js/core/WebFrontAssets.cmake b/js/core/WebFrontAssets.cmake index a7dc3477..14413024 100644 --- a/js/core/WebFrontAssets.cmake +++ b/js/core/WebFrontAssets.cmake @@ -12,7 +12,7 @@ function(_webfront_add_embedded_asset source header struct test_name) COMMENT "Regenerating ${header}" VERBATIM ) - if(ENABLE_TESTING) + if(WEBFRONT_ENABLE_TESTING) add_test(NAME ${test_name} COMMAND ${CMAKE_COMMAND} -DINPUT=${source} -DCHECK=${header} -DSTRUCT=${struct} -DGIT_EXECUTABLE=${GIT_EXECUTABLE} -P ${_WEBFRONT_ASSETS_DIR}/EmbedAsset.cmake @@ -47,7 +47,7 @@ function(webfront_add_embedded_assets) "${root}/js/core/bootstrap/bootstrap.bundle.mjs" "${root}/include/webfront/system/DeveloperBootstrapData.hpp" DeveloperBootstrapData DeveloperBootstrapAssetFresh) - if(ENABLE_TESTING) + if(WEBFRONT_ENABLE_TESTING) add_test(NAME MinimalCoreAssets COMMAND ${CMAKE_COMMAND} -DROOT=${root} -P ${root}/test/cmake/CheckMinimalCoreAssets.cmake) # The guard must fail on an asset header outside the normative list. diff --git a/js/developer/tools/PUBLISHING.md b/js/developer/tools/PUBLISHING.md index 6dc15cb2..8e7055b6 100644 --- a/js/developer/tools/PUBLISHING.md +++ b/js/developer/tools/PUBLISHING.md @@ -16,7 +16,7 @@ The driver `webfront-wf` runs one `wf` command without interaction on a project works; WebKitGTK on Linux is the one CI uses. ```sh -cmake -S . -B build-driver -DCMAKE_BUILD_TYPE=Release -DENABLE_TESTING=ON \ +cmake -S . -B build-driver -DCMAKE_BUILD_TYPE=Release -DWEBFRONT_ENABLE_TESTING=ON \ -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK cmake --build build-driver --target webfront-wf wf() { xvfb-run -a build-driver/test/web/webfront-wf --project "$PWD" --manifest-dir js/developer -- "$@"; } diff --git a/test/cmake/CheckFrontendConsumer.cmake b/test/cmake/CheckFrontendConsumer.cmake index 4f8c713d..4ba64241 100644 --- a/test/cmake/CheckFrontendConsumer.cmake +++ b/test/cmake/CheckFrontendConsumer.cmake @@ -44,3 +44,13 @@ execute_process(COMMAND "${CMAKE_COMMAND}" --fresh if(NOT result EQUAL 0) message(FATAL_ERROR "Support module option change: ${output}${error}") endif() + +# A consumer opts in to one of WebFront's test options only by its prefixed name (#412). +execute_process(COMMAND "${CMAKE_COMMAND}" --fresh + -S "${ROOT}/test/cmake/frontend-consumer" -B "${WORK_DIR}/consumer-coverage" + "-DROOT=${ROOT}" -DPROBE=ON -DFULL_PROJECT=ON "-DCPM_MODULE=${CPM_MODULE}" + -DWEBFRONT_ENABLE_COVERAGE=ON ${DEPENDENCY_ARGS} + RESULT_VARIABLE result OUTPUT_VARIABLE output ERROR_VARIABLE error) +if(NOT result EQUAL 0) + message(FATAL_ERROR "Consumer WEBFRONT_ENABLE_COVERAGE: ${output}${error}") +endif() diff --git a/test/cmake/CheckNewcomerDocs.cmake b/test/cmake/CheckNewcomerDocs.cmake index ea4c60ae..9ab1df07 100644 --- a/test/cmake/CheckNewcomerDocs.cmake +++ b/test/cmake/CheckNewcomerDocs.cmake @@ -22,6 +22,7 @@ _read(life examples/life/LifeDeveloper.cpp) _read(embedded examples/life/LifeEmbedded.cpp) _read(examples examples/CMakeLists.txt) _read(root CMakeLists.txt) +_read(test_options cmake/WebFrontTestOptions.cmake) _read(ci .github/workflows/BuildAndTest.yml) _read(frontends docs/FRONTENDS.md) _read(developer_guide docs/DEVELOPER_ENVIRONMENT.md) @@ -48,7 +49,8 @@ else() endif() _require("${root}" "add_subdirectory(examples)" "examples directory") -_require("${root}" "option(ENABLE_TESTING \"Enable Test Builds\" OFF)" "tests opt-in") +_require("${root}" "webfront_declare_test_options(\${WEBFRONT_IS_TOP_LEVEL})" "test options") +_require("${test_options}" "option(WEBFRONT_ENABLE_TESTING \"Build WebFront's tests\" OFF)" "tests opt-in") _require("${root}" "add_library(WebFront::WebFront ALIAS WebFront)" "consumer alias") _require("${readme}" "target_link_libraries(MyApp PRIVATE WebFront::WebFront)" "consumer instructions") _require("${readme}" "mkdir build\ncd build\ncmake ..\ncmake --build .\n" "Life standard build") @@ -107,7 +109,7 @@ foreach(name IN LISTS WEBFRONT_FRONTEND_REGISTRY) _require("${frontends}" "| ${option} | ${default} | ${description} |" "frontend option reference") endforeach() foreach(text readme agents ci) - _require("${${text}}" "-DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON" "${text} baseline configuration") + _require("${${text}}" "-DWEBFRONT_EMBED_CEF=OFF -DWEBFRONT_ENABLE_TESTING=ON" "${text} baseline configuration") endforeach() foreach(text readme agents) _require("${${text}}" "ctest --test-dir build --output-on-failure --parallel 4" "${text} test command") diff --git a/test/cmake/CheckTestOptions.cmake b/test/cmake/CheckTestOptions.cmake new file mode 100644 index 00000000..1003aa1a --- /dev/null +++ b/test/cmake/CheckTestOptions.cmake @@ -0,0 +1,64 @@ +# WebFront's test options (#412): the prefixed names decide, the former names are migrated only at the top level. +cmake_minimum_required(VERSION 3.31) +if(NOT ROOT OR NOT WORK_DIR) + message(FATAL_ERROR "ROOT and WORK_DIR are required") +endif() +file(REMOVE_RECURSE "${WORK_DIR}") +function(configure name directory) + cmake_parse_arguments(PARSE_ARGV 2 arg "DEPRECATED" "" "EXPECT;OPTIONS") + execute_process(COMMAND "${CMAKE_COMMAND}" -S "${ROOT}/test/cmake/test-options" -B "${WORK_DIR}/${directory}" + "-DROOT=${ROOT}" ${arg_OPTIONS} + RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE error) + set(log "${output}${error}") + if(NOT status EQUAL 0) + message(FATAL_ERROR "${name}: status ${status}\n${log}") + endif() + foreach(expected IN LISTS arg_EXPECT) + if(NOT log MATCHES "-- ${expected}\n") + message(FATAL_ERROR "${name}: expected '${expected}'\n${log}") + endif() + endforeach() + string(FIND "${log}" "is deprecated and will be removed in WebFront 0.7.0" deprecated) + if(arg_DEPRECATED AND deprecated EQUAL -1) + message(FATAL_ERROR "${name}: the former name must print a deprecation warning\n${log}") + elseif(NOT arg_DEPRECATED AND NOT deprecated EQUAL -1) + message(FATAL_ERROR "${name}: unexpected deprecation warning\n${log}") + endif() +endfunction() + +configure("defaults" defaults + EXPECT "TESTING=OFF LEGACY=" "FUZZING=OFF LEGACY=" "COVERAGE=OFF LEGACY=" + OPTIONS -DTOP_LEVEL=ON) +configure("prefixed names at the top level" prefixed + EXPECT "TESTING=ON LEGACY=" "FUZZING=ON LEGACY=" "COVERAGE=ON LEGACY=" + OPTIONS -DTOP_LEVEL=ON -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_ENABLE_FUZZING=ON -DWEBFRONT_ENABLE_COVERAGE=ON) +configure("former names at the top level are migrated" legacy DEPRECATED + EXPECT "TESTING=ON LEGACY=" "FUZZING=ON LEGACY=" "COVERAGE=ON LEGACY=" + OPTIONS -DTOP_LEVEL=ON -DENABLE_TESTING=ON -DENABLE_FUZZING=ON -DENABLE_COVERAGE=ON) +configure("a migrated value is kept without warning" legacy + EXPECT "TESTING=ON LEGACY=" "COVERAGE=ON LEGACY=") +configure("the prefixed name then decides alone" legacy + EXPECT "TESTING=OFF LEGACY=" "FUZZING=ON LEGACY=" + OPTIONS -DWEBFRONT_ENABLE_TESTING=OFF) +configure("a former name given again wins over the cache" legacy DEPRECATED + EXPECT "TESTING=ON LEGACY=" "FUZZING=OFF LEGACY=" + OPTIONS -DENABLE_TESTING=ON -DENABLE_FUZZING=OFF) +configure("the former OFF defaults of an old build tree are dropped silently" old-tree + EXPECT "TESTING=OFF LEGACY=" "SANITIZER_THREAD=OFF LEGACY=" + OPTIONS -DTOP_LEVEL=ON -DENABLE_TESTING=OFF -DENABLE_SANITIZER_THREAD=OFF) +configure("a parent's generic names are ignored" subproject + EXPECT "TESTING=OFF LEGACY=ON" "FUZZING=OFF LEGACY=ON" "COVERAGE=OFF LEGACY=ON" + OPTIONS -DTOP_LEVEL=OFF -DENABLE_TESTING=ON -DENABLE_FUZZING=ON -DENABLE_COVERAGE=ON) +configure("a consumer opts in with the prefixed name" consumer + EXPECT "TESTING=ON LEGACY=OFF" "FUZZING=OFF LEGACY=ON" + OPTIONS -DTOP_LEVEL=OFF -DENABLE_TESTING=OFF -DENABLE_FUZZING=ON -DWEBFRONT_ENABLE_TESTING=ON) +configure("former sanitizer names at the top level are migrated" sanitizers DEPRECATED + EXPECT "SANITIZER_ADDRESS=ON LEGACY=" "SANITIZER_LEAK=ON LEGACY=" + "SANITIZER_UNDEFINED_BEHAVIOR=ON LEGACY=" "SANITIZER_THREAD=ON LEGACY=" + "SANITIZER_MEMORY=ON LEGACY=" + OPTIONS -DTOP_LEVEL=ON -DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_LEAK=ON + -DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DENABLE_SANITIZER_THREAD=ON -DENABLE_SANITIZER_MEMORY=ON) +configure("a parent's generic sanitizer names are ignored" subproject-sanitizers + EXPECT "SANITIZER_ADDRESS=OFF LEGACY=ON" "SANITIZER_UNDEFINED_BEHAVIOR=OFF LEGACY=ON" + OPTIONS -DTOP_LEVEL=OFF -DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON) +message(STATUS "WebFront's test options ignore a parent's generic names and migrate the former ones") diff --git a/test/cmake/frontend-consumer/provider/CMakeLists.txt b/test/cmake/frontend-consumer/provider/CMakeLists.txt index 8e3fb07a..9cb86845 100644 --- a/test/cmake/frontend-consumer/provider/CMakeLists.txt +++ b/test/cmake/frontend-consumer/provider/CMakeLists.txt @@ -31,13 +31,45 @@ if(FULL_PROJECT) get_filename_component(cpm_filename "${CPM_MODULE}" NAME) file(COPY_FILE "${CPM_MODULE}" "${CPM_SOURCE_CACHE}/cpm/${cpm_filename}" ONLY_IF_DIFFERENT) endif() - set(ENABLE_TESTING OFF) - set(ENABLE_FUZZING OFF) + # The parent's own generic switches (#412): WebFront must add no tests, fuzzers, coverage or sanitizers for them. + set(ENABLE_TESTING ON CACHE BOOL "The parent's tests") + set(ENABLE_FUZZING ON CACHE BOOL "The parent's fuzzers") + set(ENABLE_COVERAGE ON CACHE BOOL "The parent's coverage") + set(ENABLE_SANITIZER_ADDRESS ON CACHE BOOL "The parent's sanitizer") + set(ENABLE_SANITIZER_UNDEFINED_BEHAVIOR ON CACHE BOOL "The parent's sanitizer") set(WEBFRONT_BUILD_EXAMPLES OFF) + # Only the prefixed option, given explicitly, opts in. + set(consumer_coverage OFF) + if(WEBFRONT_ENABLE_COVERAGE) + set(consumer_coverage ON) + endif() add_subdirectory("${ROOT}" webfront) if(NOT WEBFRONT_AUTODETECT_NATIVE) message(FATAL_ERROR "Native detection must default to ON for consumers without examples") endif() + foreach(name TESTING FUZZING COVERAGE SANITIZER_ADDRESS SANITIZER_UNDEFINED_BEHAVIOR) + if(WEBFRONT_ENABLE_${name} AND NOT (name STREQUAL "COVERAGE" AND consumer_coverage)) + message(FATAL_ERROR "The parent's ENABLE_${name} enabled WEBFRONT_ENABLE_${name}") + endif() + if(NOT ENABLE_${name}) + message(FATAL_ERROR "WebFront changed the parent's ENABLE_${name}") + endif() + endforeach() + foreach(target tests webtest webfront-wf fuzz_messages fuzz_http WebFront_test_hardening) + if(TARGET ${target}) + message(FATAL_ERROR "The parent's generic options added WebFront's ${target}") + endif() + endforeach() + get_target_property(options WebFront_options INTERFACE_COMPILE_OPTIONS) + if(options MATCHES "fsanitize") + message(FATAL_ERROR "The parent's ENABLE_SANITIZER_* instrumented WebFront: ${options}") + endif() + if(options MATCHES "coverage" AND NOT consumer_coverage) + message(FATAL_ERROR "The parent's ENABLE_COVERAGE instrumented WebFront: ${options}") + elseif(NOT options MATCHES "coverage" AND consumer_coverage + AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang") + message(FATAL_ERROR "WEBFRONT_ENABLE_COVERAGE=ON was ignored for a consumer: ${options}") + endif() else() webfront_autodetect_native_frontends() webfront_declare_frontend_options() diff --git a/test/cmake/test-options/CMakeLists.txt b/test/cmake/test-options/CMakeLists.txt new file mode 100644 index 00000000..86575e20 --- /dev/null +++ b/test/cmake/test-options/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.31) +include("${ROOT}/cmake/WebFrontTestOptions.cmake") +webfront_declare_test_options(${TOP_LEVEL}) +project(TestOptions LANGUAGES NONE) +foreach(name TESTING FUZZING COVERAGE SANITIZER_ADDRESS SANITIZER_LEAK SANITIZER_UNDEFINED_BEHAVIOR + SANITIZER_THREAD SANITIZER_MEMORY) + if(DEFINED CACHE{ENABLE_${name}}) + set(legacy "$CACHE{ENABLE_${name}}") + else() + set(legacy "") + endif() + message(STATUS "${name}=${WEBFRONT_ENABLE_${name}} LEGACY=${legacy}") +endforeach() diff --git a/test/fuzz/CMakeLists.txt b/test/fuzz/CMakeLists.txt index 0acafed7..c87793e5 100644 --- a/test/fuzz/CMakeLists.txt +++ b/test/fuzz/CMakeLists.txt @@ -1,7 +1,7 @@ if(NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR MSVC) - message(FATAL_ERROR "ENABLE_FUZZING requires Clang with libFuzzer (Linux or macOS)") + message(FATAL_ERROR "WEBFRONT_ENABLE_FUZZING requires Clang with libFuzzer (Linux or macOS)") endif() -if(ENABLE_SANITIZER_THREAD OR ENABLE_SANITIZER_MEMORY) +if(WEBFRONT_ENABLE_SANITIZER_THREAD OR WEBFRONT_ENABLE_SANITIZER_MEMORY) message(FATAL_ERROR "Fuzzing uses ASan+UBSan and cannot be combined with TSan or MSan") endif() @@ -15,7 +15,7 @@ extern \"C\" int LLVMFuzzerTestOneInput(const std::uint8_t*, std::size_t) { retu WEBFRONT_HAS_LIBFUZZER) cmake_pop_check_state() if(NOT WEBFRONT_HAS_LIBFUZZER) - message(FATAL_ERROR "ENABLE_FUZZING requires the compiler-rt libFuzzer, ASan and UBSan runtimes") + message(FATAL_ERROR "WEBFRONT_ENABLE_FUZZING requires the compiler-rt libFuzzer, ASan and UBSan runtimes") endif() foreach(_decoder IN ITEMS Messages HTTP WebSocket Gzip) diff --git a/test/fuzz/README.md b/test/fuzz/README.md index 272068e0..44411c1e 100644 --- a/test/fuzz/README.md +++ b/test/fuzz/README.md @@ -1,11 +1,11 @@ # Decoder fuzzing -`ENABLE_FUZZING=ON` builds `fuzz_messages`, `fuzz_http`, `fuzz_websocket`, and `fuzz_gzip` with +`WEBFRONT_ENABLE_FUZZING=ON` builds `fuzz_messages`, `fuzz_http`, `fuzz_websocket`, and `fuzz_gzip` with Clang/libFuzzer, ASan, UBSan, standard library hardening and pattern initialization. Linux with Clang/compiler-rt is validated in CI. Apple Clang does not include libFuzzer; on macOS install it externally (for example as part of LLVM/compiler-rt) and use compatible ASan/UBSan runtimes. CMake rejects missing runtimes during configuration. -It works independently of `ENABLE_TESTING`; no Catch2 or CEF is needed. +It works independently of `WEBFRONT_ENABLE_TESTING`; no Catch2 or CEF is needed. The binary corpus files use the existing wire formats. Seeds derive from `MessagesTests.cpp` (handshake, print call, scalar, tuple, typed arrays and return), @@ -35,8 +35,8 @@ file to the same executable, then add a unit regression before fixing it. ## Gzip/zlib differential checks Opt in with `-DWEBFRONT_GZIP_DIFFERENTIAL=ON`: tests link zlib, production headers do not. -With `ENABLE_TESTING=ON`, `gzip_differential` compares the neutral fixtures in CTest; -with `ENABLE_FUZZING=ON`, `fuzz_gzip_differential` additionally checks arbitrary accepted +With `WEBFRONT_ENABLE_TESTING=ON`, `gzip_differential` compares the neutral fixtures in CTest; +with `WEBFRONT_ENABLE_FUZZING=ON`, `fuzz_gzip_differential` additionally checks arbitrary accepted streams against zlib under ASan/UBSan: ```sh diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index d02fd04e..ad6bccdf 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -153,7 +153,7 @@ if(UNIX) endif() endif() -if(ENABLE_COVERAGE) +if(WEBFRONT_ENABLE_COVERAGE) target_compile_options(tests PUBLIC -O0 -g -fprofile-arcs -ftest-coverage) target_link_options(tests PUBLIC -fprofile-arcs -ftest-coverage) endif() @@ -161,7 +161,7 @@ endif() # Replaces the global operator new to count allocations: kept out of Catch2 and TSan builds. # Clang's TSan C++ runtime defines the same operators, so this executable cannot link with it. # Ordinary and ASan/UBSan builds retain this regression; the rest of the suite still runs under TSan. -if(NOT ENABLE_SANITIZER_THREAD) +if(NOT WEBFRONT_ENABLE_SANITIZER_THREAD) add_executable(frame_allocation FrameAllocationTest.cpp) target_link_libraries(frame_allocation PRIVATE WebFront_test_hardening WebFront_warnings WebFront_options WebFront) add_test(NAME FrameBufferNotFormattedWhenDebugDisabled COMMAND frame_allocation) @@ -205,6 +205,12 @@ add_test(NAME NativeAutodetectReconfiguration -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckNativeAutodetect.cmake) # The test takes about 5 s; the wide bound only absorbs a loaded runner (one unexplained stall at 60 s, #416). set_tests_properties(NativeAutodetectReconfiguration PROPERTIES TIMEOUT 180) +# WebFront's prefixed test options, the migration of the former names and their isolation from a parent (#412). +add_test(NAME TestOptionsConfiguration + COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} + -DWORK_DIR=${CMAKE_CURRENT_BINARY_DIR}/test-options + -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckTestOptions.cmake) +set_tests_properties(TestOptionsConfiguration PROPERTIES TIMEOUT 120 LABELS fast) # Exercise configuration-dependent CTest discovery and generator switches on single-config CI hosts. # The fixture configures no compiler and builds nothing; Ninja is optional for contributor builds. find_program(WEBFRONT_TEST_NINJA_EXECUTABLE ninja) @@ -302,7 +308,7 @@ target_link_libraries(gzip_cache_benchmark PRIVATE WebFront_test_hardening WebFr add_test(NAME TransportBenchmarksAreManual COMMAND ${CMAKE_COMMAND} -DROOT=${PROJECT_SOURCE_DIR} -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckManualTransportBenchmarks.cmake) -if(NOT ENABLE_SANITIZER_THREAD) +if(NOT WEBFRONT_ENABLE_SANITIZER_THREAD) add_executable(gzip_decoder_benchmark EXCLUDE_FROM_ALL GzipDecoderBenchmark.cpp) target_link_libraries(gzip_decoder_benchmark PRIVATE WebFront_test_hardening WebFront_warnings WebFront_options WebFront) endif() From 69e7d9618d931eceb65299bcc48662d38b1fb424 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 16:13:17 +0100 Subject: [PATCH 2/5] Let a cached prefixed test option win over a former name [#412] Build trees configured before the rename hold the FALSE/OFF defaults of the former option() calls. The migration applied them to the new names, so a -DWEBFRONT_ENABLE_COVERAGE=ON on such a tree stayed OFF, and a former name given with the prefixed one overrode it. A prefixed option already in the cache now decides: a true former value is ignored with a warning saying so. Otherwise a true former value is moved with a deprecation warning that names its origin. A false former value is always dropped silently. TestOptionsConfiguration reproduces an old tree with a new prefixed option and both names given together. --- AGENTS.md | 2 +- cmake/WebFrontTestOptions.cmake | 44 ++++++++++++++++++-------- docs/CHANGELOG.md | 9 ++++-- test/cmake/CheckTestOptions.cmake | 42 +++++++++++++++++------- test/cmake/test-options/CMakeLists.txt | 6 ++++ 5 files changed, 75 insertions(+), 28 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index dd1114a4..fe39714c 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,7 +86,7 @@ without network access. - `WEBFRONT_EMBED_WEBVIEW2=OFF` (default): Windows-only opt-in SDK and static loader for `WebView2Frontend`; requires the separately installed Evergreen runtime. Select it explicitly with `WebFrontWithFrontend`. With tests enabled, `WEBFRONT_WEBTEST_FRONTEND=WebView2` runs the shared Jasmine suite and lifecycle cases. - `WEBFRONT_EMBED_WKWEBVIEW=OFF` (default): macOS 13.3+ opt-in Cocoa/WebKit frontend, with no engine download. Select `WebFrontWithFrontend` on the main thread; `WEBFRONT_WEBTEST_FRONTEND=WKWebView` runs Jasmine and lifecycle coverage. -- `WEBFRONT_ENABLE_TESTING=ON` (default `OFF`): build Catch2 and Jasmine test targets. CI and contributor commands must pass it explicitly. The test, fuzzing, coverage and sanitizer options (`WEBFRONT_ENABLE_SANITIZER_*`) carry the `WEBFRONT_` prefix so that a parent's own `ENABLE_TESTING` or `ENABLE_SANITIZER_ADDRESS` never builds or instruments WebFront's tests; the former unprefixed names are accepted, with a deprecation warning, only at the top level and until 0.7.0 (`cmake/WebFrontTestOptions.cmake`). +- `WEBFRONT_ENABLE_TESTING=ON` (default `OFF`): build Catch2 and Jasmine test targets. CI and contributor commands must pass it explicitly. The test, fuzzing, coverage and sanitizer options (`WEBFRONT_ENABLE_SANITIZER_*`) carry the `WEBFRONT_` prefix so that a parent's own `ENABLE_TESTING` or `ENABLE_SANITIZER_ADDRESS` never builds or instruments WebFront's tests; the former unprefixed names are accepted, with a deprecation warning, only at the top level and until 0.7.0, and a prefixed option already in the cache always wins (`cmake/WebFrontTestOptions.cmake`). - `WEBFRONT_BUILD_EXAMPLES` (default `ON` only for the top-level project): build the examples. As a subproject (`add_subdirectory`), link `WebFront::WebFront`; no examples, tests or global compiler settings are added. - `WEBFRONT_ENABLE_COVERAGE=ON`: add GCC/Clang coverage instrumentation to the C++ tests. diff --git a/cmake/WebFrontTestOptions.cmake b/cmake/WebFrontTestOptions.cmake index 48b07e2f..80a32678 100644 --- a/cmake/WebFrontTestOptions.cmake +++ b/cmake/WebFrontTestOptions.cmake @@ -2,11 +2,23 @@ # parent's ENABLE_TESTING, ENABLE_FUZZING, ENABLE_COVERAGE or ENABLE_SANITIZER_* never build or instrument WebFront's # tests; a consumer that wants them sets WEBFRONT_ENABLE_ explicitly. # -# The former unprefixed names are still read when WebFront is the top-level project, until WebFront 0.7.0: a value -# given there is moved to the new option (with a deprecation warning) and removed from the cache, so that a later -# -DWEBFRONT_ENABLE_ is not overridden by a stale entry. A false former value that changes nothing is dropped -# silently. +# The former unprefixed names are still read when WebFront is the top-level project, until WebFront 0.7.0, and are +# always removed from the cache: +# - a prefixed option already in the cache (given with -D, or created by an earlier configure) decides; a true former +# value is then ignored with a warning; +# - otherwise, a true former value (from the command line or left in the cache of an older build tree) is moved to the +# prefixed option with a deprecation warning. +# A false former value is dropped silently: older build trees hold the OFF defaults of the former option() calls, +# which the user never chose. macro(webfront_declare_test_options is_top_level) + set(_webfront_names TESTING FUZZING COVERAGE SANITIZER_ADDRESS SANITIZER_LEAK SANITIZER_UNDEFINED_BEHAVIOR + SANITIZER_THREAD SANITIZER_MEMORY) + set(_webfront_chosen "") + foreach(_webfront_name IN LISTS _webfront_names) + if(DEFINED CACHE{WEBFRONT_ENABLE_${_webfront_name}}) + list(APPEND _webfront_chosen ${_webfront_name}) + endif() + endforeach() option(WEBFRONT_ENABLE_TESTING "Build WebFront's tests" OFF) option(WEBFRONT_ENABLE_FUZZING "Build WebFront's fuzzers" OFF) option(WEBFRONT_ENABLE_COVERAGE "Instrument WebFront's tests for GCC/Clang coverage" OFF) @@ -15,21 +27,27 @@ macro(webfront_declare_test_options is_top_level) option(WEBFRONT_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "Build WebFront's tests with the undefined behavior sanitizer" OFF) option(WEBFRONT_ENABLE_SANITIZER_THREAD "Build WebFront's tests with the thread sanitizer" OFF) option(WEBFRONT_ENABLE_SANITIZER_MEMORY "Build WebFront's tests with the memory sanitizer" OFF) - foreach(_webfront_name TESTING FUZZING COVERAGE SANITIZER_ADDRESS SANITIZER_LEAK SANITIZER_UNDEFINED_BEHAVIOR - SANITIZER_THREAD SANITIZER_MEMORY) + foreach(_webfront_name IN LISTS _webfront_names) if(${is_top_level} AND DEFINED CACHE{ENABLE_${_webfront_name}}) set(_webfront_value "$CACHE{ENABLE_${_webfront_name}}") - # Build trees configured before the rename hold the former OFF defaults: drop those without noise. - if(NOT _webfront_value AND NOT WEBFRONT_ENABLE_${_webfront_name}) - unset(ENABLE_${_webfront_name} CACHE) + unset(ENABLE_${_webfront_name} CACHE) + if(NOT _webfront_value) continue() endif() - message(DEPRECATION "ENABLE_${_webfront_name} is deprecated and will be removed in WebFront 0.7.0: " - "use WEBFRONT_ENABLE_${_webfront_name} (set to ${_webfront_value} for this build)") - unset(ENABLE_${_webfront_name} CACHE) - set_property(CACHE WEBFRONT_ENABLE_${_webfront_name} PROPERTY VALUE "${_webfront_value}") + if(_webfront_name IN_LIST _webfront_chosen) + message(DEPRECATION "ENABLE_${_webfront_name} is deprecated and ignored: " + "WEBFRONT_ENABLE_${_webfront_name} is set (${WEBFRONT_ENABLE_${_webfront_name}}) and decides. " + "ENABLE_${_webfront_name} will be removed in WebFront 0.7.0.") + else() + message(DEPRECATION "ENABLE_${_webfront_name} is deprecated and will be removed in WebFront 0.7.0: " + "its value ${_webfront_value}, from the command line or the cache, now sets " + "WEBFRONT_ENABLE_${_webfront_name}") + set_property(CACHE WEBFRONT_ENABLE_${_webfront_name} PROPERTY VALUE "${_webfront_value}") + endif() endif() endforeach() + unset(_webfront_names) + unset(_webfront_chosen) unset(_webfront_name) unset(_webfront_value) endmacro() diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 76d74693..33bee4ea 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -5,9 +5,12 @@ - Prefix WebFront's test options (#412): `WEBFRONT_ENABLE_TESTING`, `WEBFRONT_ENABLE_FUZZING`, `WEBFRONT_ENABLE_COVERAGE` and `WEBFRONT_ENABLE_SANITIZER_{ADDRESS,LEAK,UNDEFINED_BEHAVIOR,THREAD,MEMORY}` replace the unprefixed `ENABLE_*` names (still `OFF` by default). A parent project's own generic variables no longer build - WebFront's tests or fuzzers, instrument it for coverage or sanitizers, or disable its native detection; a consumer that wants WebFront's tests sets the prefixed option. At the top level the - former names still work until WebFront 0.7.0: a value given is moved to the new option, with a deprecation warning, - and removed from the cache. CI, the documentation and `TestOptionsConfiguration` use the new names. + WebFront's tests or fuzzers, instrument it for coverage or sanitizers, or disable its native detection; a consumer + that wants WebFront's tests sets the prefixed option. At the top level the former names still work until WebFront + 0.7.0 and are removed from the cache: a prefixed option already in the cache decides, and a true former value is + then ignored with a warning; otherwise a true former value is moved to the prefixed option with a deprecation + warning. The `OFF` defaults left in older build trees are dropped silently. CI, the documentation and + `TestOptionsConfiguration` use the new names. - Stabilise the desktop-native tier (#416): before removing its temporary WebView2 profile, the automation owner waits up to 5 s for the browser processes it launched to exit and ends those still running (at once after a forced diff --git a/test/cmake/CheckTestOptions.cmake b/test/cmake/CheckTestOptions.cmake index 1003aa1a..a3c15a60 100644 --- a/test/cmake/CheckTestOptions.cmake +++ b/test/cmake/CheckTestOptions.cmake @@ -4,8 +4,9 @@ if(NOT ROOT OR NOT WORK_DIR) message(FATAL_ERROR "ROOT and WORK_DIR are required") endif() file(REMOVE_RECURSE "${WORK_DIR}") +# MIGRATED and IGNORED count the deprecation warnings of former names moved to, or overridden by, the prefixed ones. function(configure name directory) - cmake_parse_arguments(PARSE_ARGV 2 arg "DEPRECATED" "" "EXPECT;OPTIONS") + cmake_parse_arguments(PARSE_ARGV 2 arg "" "MIGRATED;IGNORED" "EXPECT;OPTIONS") execute_process(COMMAND "${CMAKE_COMMAND}" -S "${ROOT}/test/cmake/test-options" -B "${WORK_DIR}/${directory}" "-DROOT=${ROOT}" ${arg_OPTIONS} RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE error) @@ -18,12 +19,23 @@ function(configure name directory) message(FATAL_ERROR "${name}: expected '${expected}'\n${log}") endif() endforeach() - string(FIND "${log}" "is deprecated and will be removed in WebFront 0.7.0" deprecated) - if(arg_DEPRECATED AND deprecated EQUAL -1) - message(FATAL_ERROR "${name}: the former name must print a deprecation warning\n${log}") - elseif(NOT arg_DEPRECATED AND NOT deprecated EQUAL -1) - message(FATAL_ERROR "${name}: unexpected deprecation warning\n${log}") - endif() + # CMake wraps warning text: compare it on one line. + string(REGEX REPLACE "\n +" " " flat "${log}") + foreach(kind MIGRATED IGNORED) + if(kind STREQUAL "MIGRATED") + set(pattern "ENABLE_[A-Z_]+ is deprecated and will be removed in WebFront 0\\.7\\.0: its value") + else() + set(pattern "ENABLE_[A-Z_]+ is deprecated and ignored") + endif() + string(REGEX MATCHALL "${pattern}" matches "${flat}") + list(LENGTH matches count) + if(NOT arg_${kind}) + set(arg_${kind} 0) + endif() + if(NOT count EQUAL arg_${kind}) + message(FATAL_ERROR "${name}: expected ${arg_${kind}} ${kind} warnings, got ${count}\n${log}") + endif() + endforeach() endfunction() configure("defaults" defaults @@ -32,7 +44,7 @@ configure("defaults" defaults configure("prefixed names at the top level" prefixed EXPECT "TESTING=ON LEGACY=" "FUZZING=ON LEGACY=" "COVERAGE=ON LEGACY=" OPTIONS -DTOP_LEVEL=ON -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_ENABLE_FUZZING=ON -DWEBFRONT_ENABLE_COVERAGE=ON) -configure("former names at the top level are migrated" legacy DEPRECATED +configure("former names at the top level are migrated" legacy MIGRATED 3 EXPECT "TESTING=ON LEGACY=" "FUZZING=ON LEGACY=" "COVERAGE=ON LEGACY=" OPTIONS -DTOP_LEVEL=ON -DENABLE_TESTING=ON -DENABLE_FUZZING=ON -DENABLE_COVERAGE=ON) configure("a migrated value is kept without warning" legacy @@ -40,9 +52,17 @@ configure("a migrated value is kept without warning" legacy configure("the prefixed name then decides alone" legacy EXPECT "TESTING=OFF LEGACY=" "FUZZING=ON LEGACY=" OPTIONS -DWEBFRONT_ENABLE_TESTING=OFF) -configure("a former name given again wins over the cache" legacy DEPRECATED - EXPECT "TESTING=ON LEGACY=" "FUZZING=OFF LEGACY=" +configure("a former name given again is ignored once the prefixed one exists" legacy IGNORED 1 + EXPECT "TESTING=OFF LEGACY=" "FUZZING=ON LEGACY=" OPTIONS -DENABLE_TESTING=ON -DENABLE_FUZZING=OFF) +configure("the prefixed name wins when both are given" both IGNORED 1 + EXPECT "TESTING=OFF LEGACY=" + OPTIONS -DTOP_LEVEL=ON -DENABLE_TESTING=ON -DWEBFRONT_ENABLE_TESTING=OFF) +# An old tree holds ENABLE_TESTING=ON and the FALSE/OFF defaults of the former sanitizer module. +configure("an old build tree" upgraded OPTIONS -DOLD_TREE=ON -DENABLE_TESTING=ON) +configure("an old tree's former defaults never override a new prefixed option" upgraded MIGRATED 1 + EXPECT "TESTING=ON LEGACY=" "COVERAGE=ON LEGACY=" "SANITIZER_ADDRESS=ON LEGACY=" + OPTIONS -DOLD_TREE=OFF -DTOP_LEVEL=ON -DWEBFRONT_ENABLE_COVERAGE=ON -DWEBFRONT_ENABLE_SANITIZER_ADDRESS=ON) configure("the former OFF defaults of an old build tree are dropped silently" old-tree EXPECT "TESTING=OFF LEGACY=" "SANITIZER_THREAD=OFF LEGACY=" OPTIONS -DTOP_LEVEL=ON -DENABLE_TESTING=OFF -DENABLE_SANITIZER_THREAD=OFF) @@ -52,7 +72,7 @@ configure("a parent's generic names are ignored" subproject configure("a consumer opts in with the prefixed name" consumer EXPECT "TESTING=ON LEGACY=OFF" "FUZZING=OFF LEGACY=ON" OPTIONS -DTOP_LEVEL=OFF -DENABLE_TESTING=OFF -DENABLE_FUZZING=ON -DWEBFRONT_ENABLE_TESTING=ON) -configure("former sanitizer names at the top level are migrated" sanitizers DEPRECATED +configure("former sanitizer names at the top level are migrated" sanitizers MIGRATED 5 EXPECT "SANITIZER_ADDRESS=ON LEGACY=" "SANITIZER_LEAK=ON LEGACY=" "SANITIZER_UNDEFINED_BEHAVIOR=ON LEGACY=" "SANITIZER_THREAD=ON LEGACY=" "SANITIZER_MEMORY=ON LEGACY=" diff --git a/test/cmake/test-options/CMakeLists.txt b/test/cmake/test-options/CMakeLists.txt index 86575e20..0d61e8d0 100644 --- a/test/cmake/test-options/CMakeLists.txt +++ b/test/cmake/test-options/CMakeLists.txt @@ -1,4 +1,10 @@ cmake_minimum_required(VERSION 3.31) +if(OLD_TREE) + # A build tree configured before the rename: Sanitizers.cmake declared these former options with option(). + option(ENABLE_COVERAGE "Enable coverage reporting for gcc/clang" FALSE) + option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" OFF) + return() +endif() include("${ROOT}/cmake/WebFrontTestOptions.cmake") webfront_declare_test_options(${TOP_LEVEL}) project(TestOptions LANGUAGES NONE) From 8bcf7a51378b142a99fdbabdd6e736834df3be99 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 20:00:47 +0100 Subject: [PATCH 3/5] Let an explicit former test option name switch a configured tree [#412] A former name given on the command line of an already configured tree was ignored because the prefixed option was cached, and a toolchain file's ENABLE_* variables were no longer read: the migration ran before project(), and only from the cache. The options are now declared after project(), by a function, and normal variables count. A name is given by this configure when it is a normal variable or an untyped -D (an UNINITIALIZED cache entry); a BOOL entry was left by an earlier configure. A given prefixed name decides; otherwise a given former name decides, even over a cached prefixed value; a true value left by an older tree is moved unless the prefixed option is cached, and its OFF defaults are dropped silently. An ignored value is now a warning that -Wno-deprecated does not hide, and repeating an identical value only reports the deprecation. From WebFront 0.7.0 on the migration refuses to configure, so its removal cannot be forgotten. TestOptionsConfiguration covers a cached prefixed value switched by a former name, the repeated command, both names, -Wno-deprecated, toolchain files, old trees and the removal guard. ADR-018 keeps the command of its recorded run, which predates the rename. --- AGENTS.md | 2 +- CMakeLists.txt | 5 +- cmake/WebFrontTestOptions.cmake | 113 +++++++++++++++++------- docs/CHANGELOG.md | 15 ++-- docs/adr/ADR-018-acces-au-dom.md | 2 +- test/cmake/CheckTestOptions.cmake | 80 +++++++++++++---- test/cmake/test-options/CMakeLists.txt | 12 ++- test/cmake/test-options/Toolchain.cmake | 7 ++ 8 files changed, 172 insertions(+), 64 deletions(-) create mode 100644 test/cmake/test-options/Toolchain.cmake diff --git a/AGENTS.md b/AGENTS.md index fe39714c..5055146f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -86,7 +86,7 @@ without network access. - `WEBFRONT_EMBED_WEBVIEW2=OFF` (default): Windows-only opt-in SDK and static loader for `WebView2Frontend`; requires the separately installed Evergreen runtime. Select it explicitly with `WebFrontWithFrontend`. With tests enabled, `WEBFRONT_WEBTEST_FRONTEND=WebView2` runs the shared Jasmine suite and lifecycle cases. - `WEBFRONT_EMBED_WKWEBVIEW=OFF` (default): macOS 13.3+ opt-in Cocoa/WebKit frontend, with no engine download. Select `WebFrontWithFrontend` on the main thread; `WEBFRONT_WEBTEST_FRONTEND=WKWebView` runs Jasmine and lifecycle coverage. -- `WEBFRONT_ENABLE_TESTING=ON` (default `OFF`): build Catch2 and Jasmine test targets. CI and contributor commands must pass it explicitly. The test, fuzzing, coverage and sanitizer options (`WEBFRONT_ENABLE_SANITIZER_*`) carry the `WEBFRONT_` prefix so that a parent's own `ENABLE_TESTING` or `ENABLE_SANITIZER_ADDRESS` never builds or instruments WebFront's tests; the former unprefixed names are accepted, with a deprecation warning, only at the top level and until 0.7.0, and a prefixed option already in the cache always wins (`cmake/WebFrontTestOptions.cmake`). +- `WEBFRONT_ENABLE_TESTING=ON` (default `OFF`): build Catch2 and Jasmine test targets. CI and contributor commands must pass it explicitly. The test, fuzzing, coverage and sanitizer options (`WEBFRONT_ENABLE_SANITIZER_*`) carry the `WEBFRONT_` prefix so that a parent's own `ENABLE_TESTING` or `ENABLE_SANITIZER_ADDRESS` never builds or instruments WebFront's tests; the former unprefixed names are accepted, with a deprecation warning, only at the top level and until 0.7.0, and a prefixed name given by the same configure always wins (`cmake/WebFrontTestOptions.cmake` documents the rules). - `WEBFRONT_BUILD_EXAMPLES` (default `ON` only for the top-level project): build the examples. As a subproject (`add_subdirectory`), link `WebFront::WebFront`; no examples, tests or global compiler settings are added. - `WEBFRONT_ENABLE_COVERAGE=ON`: add GCC/Clang coverage instrumentation to the C++ tests. diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e7f8f71..01124945 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,8 +11,6 @@ else() endif() option(BUILD_SHARED_LIBS "Enable compilation of shared libraries" OFF) -include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/WebFrontTestOptions.cmake) -webfront_declare_test_options(${WEBFRONT_IS_TOP_LEVEL}) option(WEBFRONT_BUILD_AUTOMATION "Build the optional local developer CLI/MCP launcher" OFF) option(WEBFRONT_BUILD_EXAMPLES "Build the example applications" ${WEBFRONT_IS_TOP_LEVEL}) option(WEBFRONT_GZIP_DIFFERENTIAL "Build test-only gzip/zlib differential checks" OFF) @@ -27,6 +25,9 @@ set(VERSION_STRING_REGEX "inline constexpr std::string_view version = \"([0-9]+\ file(STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/include/webfront/WebFront.hpp" VERSION_STRING REGEX ${VERSION_STRING_REGEX}) string(REGEX MATCH "([0-9]+\\.[0-9]+\\.[0-9]+)" VERSION_STRING "${VERSION_STRING}") project(WebFront LANGUAGES CXX VERSION ${VERSION_STRING}) +# After project(): a toolchain file's variables are then visible, as they were to the former option() calls. +include(cmake/WebFrontTestOptions.cmake) +webfront_declare_test_options(${WEBFRONT_IS_TOP_LEVEL}) include(cmake/Frontends.cmake) # Applications need no -DWEBFRONT_EMBED_* option: unless the user decided, this platform's native window diff --git a/cmake/WebFrontTestOptions.cmake b/cmake/WebFrontTestOptions.cmake index 80a32678..a9ecb5e5 100644 --- a/cmake/WebFrontTestOptions.cmake +++ b/cmake/WebFrontTestOptions.cmake @@ -3,20 +3,46 @@ # tests; a consumer that wants them sets WEBFRONT_ENABLE_ explicitly. # # The former unprefixed names are still read when WebFront is the top-level project, until WebFront 0.7.0, and are -# always removed from the cache: -# - a prefixed option already in the cache (given with -D, or created by an earlier configure) decides; a true former -# value is then ignored with a warning; -# - otherwise, a true former value (from the command line or left in the cache of an older build tree) is moved to the -# prefixed option with a deprecation warning. -# A false former value is dropped silently: older build trees hold the OFF defaults of the former option() calls, -# which the user never chose. -macro(webfront_declare_test_options is_top_level) - set(_webfront_names TESTING FUZZING COVERAGE SANITIZER_ADDRESS SANITIZER_LEAK SANITIZER_UNDEFINED_BEHAVIOR - SANITIZER_THREAD SANITIZER_MEMORY) - set(_webfront_chosen "") - foreach(_webfront_name IN LISTS _webfront_names) - if(DEFINED CACHE{WEBFRONT_ENABLE_${_webfront_name}}) - list(APPEND _webfront_chosen ${_webfront_name}) +# always removed from the cache. Like the former option() calls, the function runs after project() and reads normal +# variables too (a toolchain file's). A name is "given" by this configure when it is a normal variable or an untyped +# -D entry (an UNINITIALIZED cache entry: no option() declares it yet); a typed BOOL entry was left by an earlier +# configure, or given as -D:BOOL, which is read as left. Then: +# - a given prefixed name decides; a former name of another value is ignored with a warning; +# - otherwise a given former name decides and its value is moved to the prefixed option, even over a value an earlier +# configure left in the cache; +# - otherwise a true former value left by an older build tree is moved, unless an earlier configure already left the +# prefixed option; a false one is dropped silently: older trees hold the OFF defaults of the former option() calls. +# Moving or repeating a former name prints a deprecation warning. +set(_WEBFRONT_TEST_OPTION_NAMES TESTING FUZZING COVERAGE SANITIZER_ADDRESS SANITIZER_LEAK SANITIZER_UNDEFINED_BEHAVIOR + SANITIZER_THREAD SANITIZER_MEMORY) +set(_WEBFRONT_FORMER_NAMES_REMOVAL 0.7.0) + +# Whether `name` was given by this configure (see above). +function(_webfront_option_given name out) + set(given OFF) + if(DEFINED CACHE{${name}}) + get_property(type CACHE ${name} PROPERTY TYPE) + if(type STREQUAL "UNINITIALIZED" OR NOT "${${name}}" STREQUAL "$CACHE{${name}}") + set(given ON) + endif() + elseif(DEFINED ${name}) + set(given ON) + endif() + set(${out} ${given} PARENT_SCOPE) +endfunction() + +function(webfront_declare_test_options is_top_level) + if(PROJECT_VERSION VERSION_GREATER_EQUAL _WEBFRONT_FORMER_NAMES_REMOVAL) + message(FATAL_ERROR "WebFront ${PROJECT_VERSION} must no longer read the former ENABLE_* test options: remove " + "their migration from cmake/WebFrontTestOptions.cmake, as announced in docs/CHANGELOG.md") + endif() + foreach(name IN LISTS _WEBFRONT_TEST_OPTION_NAMES) + _webfront_option_given(WEBFRONT_ENABLE_${name} prefixed_given_${name}) + _webfront_option_given(ENABLE_${name} former_given_${name}) + if(DEFINED CACHE{WEBFRONT_ENABLE_${name}}) + set(prefixed_cached_${name} ON) + else() + set(prefixed_cached_${name} OFF) endif() endforeach() option(WEBFRONT_ENABLE_TESTING "Build WebFront's tests" OFF) @@ -27,27 +53,46 @@ macro(webfront_declare_test_options is_top_level) option(WEBFRONT_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR "Build WebFront's tests with the undefined behavior sanitizer" OFF) option(WEBFRONT_ENABLE_SANITIZER_THREAD "Build WebFront's tests with the thread sanitizer" OFF) option(WEBFRONT_ENABLE_SANITIZER_MEMORY "Build WebFront's tests with the memory sanitizer" OFF) - foreach(_webfront_name IN LISTS _webfront_names) - if(${is_top_level} AND DEFINED CACHE{ENABLE_${_webfront_name}}) - set(_webfront_value "$CACHE{ENABLE_${_webfront_name}}") - unset(ENABLE_${_webfront_name} CACHE) - if(NOT _webfront_value) - continue() - endif() - if(_webfront_name IN_LIST _webfront_chosen) - message(DEPRECATION "ENABLE_${_webfront_name} is deprecated and ignored: " - "WEBFRONT_ENABLE_${_webfront_name} is set (${WEBFRONT_ENABLE_${_webfront_name}}) and decides. " - "ENABLE_${_webfront_name} will be removed in WebFront 0.7.0.") + if(NOT is_top_level) + return() + endif() + foreach(name IN LISTS _WEBFRONT_TEST_OPTION_NAMES) + if(NOT DEFINED ENABLE_${name}) + continue() + endif() + set(former "ENABLE_${name}") + set(prefixed "WEBFRONT_ENABLE_${name}") + set(value OFF) + if(${former}) + set(value ON) + endif() + set(current OFF) + if(${prefixed}) + set(current ON) + endif() + unset(${former} CACHE) + if(NOT former_given_${name} AND NOT value) + continue() + endif() + if(prefixed_given_${name} OR (prefixed_cached_${name} AND NOT former_given_${name})) + if(value STREQUAL current) + if(former_given_${name}) + message(DEPRECATION "${former} is deprecated and will be removed in WebFront " + "${_WEBFRONT_FORMER_NAMES_REMOVAL}: use ${prefixed}, which already has this value") + endif() else() - message(DEPRECATION "ENABLE_${_webfront_name} is deprecated and will be removed in WebFront 0.7.0: " - "its value ${_webfront_value}, from the command line or the cache, now sets " - "WEBFRONT_ENABLE_${_webfront_name}") - set_property(CACHE WEBFRONT_ENABLE_${_webfront_name} PROPERTY VALUE "${_webfront_value}") + # Not a deprecation: -Wno-deprecated must not hide that an explicit value has no effect. + message(WARNING "${former} is ignored: ${prefixed} is set (${current}) and decides. ${former} is " + "deprecated and will be removed in WebFront ${_WEBFRONT_FORMER_NAMES_REMOVAL}.") endif() + elseif(prefixed_cached_${name} AND value STREQUAL current) + message(DEPRECATION "${former} is deprecated and will be removed in WebFront " + "${_WEBFRONT_FORMER_NAMES_REMOVAL}: use ${prefixed}, which already has this value") + else() + message(DEPRECATION "${former} is deprecated and will be removed in WebFront " + "${_WEBFRONT_FORMER_NAMES_REMOVAL}: its value ${value}, from the command line, a toolchain file or " + "the cache, now sets ${prefixed}") + set_property(CACHE ${prefixed} PROPERTY VALUE ${value}) endif() endforeach() - unset(_webfront_names) - unset(_webfront_chosen) - unset(_webfront_name) - unset(_webfront_value) -endmacro() +endfunction() diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 0d29301f..e16db1cf 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -6,11 +6,16 @@ `WEBFRONT_ENABLE_COVERAGE` and `WEBFRONT_ENABLE_SANITIZER_{ADDRESS,LEAK,UNDEFINED_BEHAVIOR,THREAD,MEMORY}` replace the unprefixed `ENABLE_*` names (still `OFF` by default). A parent project's own generic variables no longer build WebFront's tests or fuzzers, instrument it for coverage or sanitizers, or disable its native detection; a consumer - that wants WebFront's tests sets the prefixed option. At the top level the former names still work until WebFront - 0.7.0 and are removed from the cache: a prefixed option already in the cache decides, and a true former value is - then ignored with a warning; otherwise a true former value is moved to the prefixed option with a deprecation - warning. The `OFF` defaults left in older build trees are dropped silently. CI, the documentation and - `TestOptionsConfiguration` use the new names. + that wants WebFront's tests sets the prefixed option, and its build then keeps the explicit engine selection, as a + top-level test build does. A parent configured with an earlier WebFront keeps the unused `ENABLE_COVERAGE` and + `ENABLE_SANITIZER_*=OFF` entries in its cache; WebFront no longer reads them and leaves the parent's cache alone. + At the top level the former names, from the command line, a toolchain file or the cache, still work until WebFront + 0.7.0, which refuses to configure while the migration remains, and are removed from the cache. A prefixed name given + by the same configure decides, and a former name of another value is then ignored with a warning that + `-Wno-deprecated` does not hide; otherwise a former name given by this configure is moved to the prefixed option, + even over a value an earlier configure left. A true former value left by an older build tree is moved unless the + prefixed option is already cached; the `OFF` defaults left there are dropped silently. Moving or repeating a former + name prints a deprecation warning. CI, the documentation and `TestOptionsConfiguration` use the new names. - Stabilise the desktop-native tier (#416): before removing its temporary WebView2 profile, the automation owner waits up to 5 s for the browser processes it launched to exit and ends those still running (at once after a forced diff --git a/docs/adr/ADR-018-acces-au-dom.md b/docs/adr/ADR-018-acces-au-dom.md index 65561121..72da94c7 100644 --- a/docs/adr/ADR-018-acces-au-dom.md +++ b/docs/adr/ADR-018-acces-au-dom.md @@ -136,7 +136,7 @@ Les prototypes ne font pas partie du dépôt : ils sont consultables dans le com - `DomPrototype.cpp` et `dom-prototype.html` : les scénarios, les vérifications du DOM et le rapport. Le programme échoue sur un DOM faux ou un rapport absent, jamais sur une durée. -Exécution dans ce commit (build `-DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_ENABLE_TESTING=ON`, Release) : construire la cible +Exécution dans ce commit (build `-DWEBFRONT_EMBED_WEBKITGTK=ON -DENABLE_TESTING=ON`, Release) : construire la cible `webkitgtk_dom_prototype`, extraire les archives `react-19.3.1`, `react-dom-19.3.1` et `scheduler-0.28.0` de `build/registry-archives/` dans un répertoire de paquets, puis lancer le programme sous Xvfb depuis `test/web/dom` avec ce répertoire en argument. diff --git a/test/cmake/CheckTestOptions.cmake b/test/cmake/CheckTestOptions.cmake index a3c15a60..c3868cac 100644 --- a/test/cmake/CheckTestOptions.cmake +++ b/test/cmake/CheckTestOptions.cmake @@ -4,9 +4,10 @@ if(NOT ROOT OR NOT WORK_DIR) message(FATAL_ERROR "ROOT and WORK_DIR are required") endif() file(REMOVE_RECURSE "${WORK_DIR}") -# MIGRATED and IGNORED count the deprecation warnings of former names moved to, or overridden by, the prefixed ones. +# MIGRATED, KEPT and IGNORED count the messages of former names moved to the prefixed ones (deprecation), repeating a +# prefixed value (deprecation) and overridden by a prefixed one (a warning, which -Wno-deprecated does not hide). function(configure name directory) - cmake_parse_arguments(PARSE_ARGV 2 arg "" "MIGRATED;IGNORED" "EXPECT;OPTIONS") + cmake_parse_arguments(PARSE_ARGV 2 arg "" "MIGRATED;KEPT;IGNORED" "EXPECT;OPTIONS") execute_process(COMMAND "${CMAKE_COMMAND}" -S "${ROOT}/test/cmake/test-options" -B "${WORK_DIR}/${directory}" "-DROOT=${ROOT}" ${arg_OPTIONS} RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE error) @@ -19,23 +20,28 @@ function(configure name directory) message(FATAL_ERROR "${name}: expected '${expected}'\n${log}") endif() endforeach() - # CMake wraps warning text: compare it on one line. - string(REGEX REPLACE "\n +" " " flat "${log}") - foreach(kind MIGRATED IGNORED) - if(kind STREQUAL "MIGRATED") - set(pattern "ENABLE_[A-Z_]+ is deprecated and will be removed in WebFront 0\\.7\\.0: its value") - else() - set(pattern "ENABLE_[A-Z_]+ is deprecated and ignored") - endif() - string(REGEX MATCHALL "${pattern}" matches "${flat}") + # CMake wraps warning text: compare it with single spaces. + string(REGEX REPLACE "[\n ]+" " " flat "${log}") + set(prefix "\\(message\\): ENABLE_[A-Z_]+") + set(pattern_MIGRATED "CMake Deprecation Warning at [^ ]+ ${prefix} is deprecated and will be removed in WebFront 0\\.7\\.0: its value") + set(pattern_KEPT "CMake Deprecation Warning at [^ ]+ ${prefix} is deprecated [^:]+: use WEBFRONT_ENABLE_[A-Z_]+, which already has this value") + set(pattern_IGNORED "CMake Warning at [^ ]+ ${prefix} is ignored: WEBFRONT_ENABLE_[A-Z_]+ is set") + foreach(kind MIGRATED KEPT IGNORED) + string(REGEX MATCHALL "${pattern_${kind}}" matches "${flat}") list(LENGTH matches count) if(NOT arg_${kind}) set(arg_${kind} 0) endif() if(NOT count EQUAL arg_${kind}) - message(FATAL_ERROR "${name}: expected ${arg_${kind}} ${kind} warnings, got ${count}\n${log}") + message(FATAL_ERROR "${name}: expected ${arg_${kind}} ${kind} messages, got ${count}\n${log}") endif() endforeach() + string(REGEX MATCHALL "CMake (Deprecation )?Warning" all "${flat}") + list(LENGTH all total) + math(EXPR expected_total "${arg_MIGRATED} + ${arg_KEPT} + ${arg_IGNORED}") + if(NOT total EQUAL expected_total) + message(FATAL_ERROR "${name}: expected ${expected_total} warnings in all, got ${total}\n${log}") + endif() endfunction() configure("defaults" defaults @@ -44,28 +50,55 @@ configure("defaults" defaults configure("prefixed names at the top level" prefixed EXPECT "TESTING=ON LEGACY=" "FUZZING=ON LEGACY=" "COVERAGE=ON LEGACY=" OPTIONS -DTOP_LEVEL=ON -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_ENABLE_FUZZING=ON -DWEBFRONT_ENABLE_COVERAGE=ON) + +# A configured tree, then former names given on later command lines. configure("former names at the top level are migrated" legacy MIGRATED 3 EXPECT "TESTING=ON LEGACY=" "FUZZING=ON LEGACY=" "COVERAGE=ON LEGACY=" OPTIONS -DTOP_LEVEL=ON -DENABLE_TESTING=ON -DENABLE_FUZZING=ON -DENABLE_COVERAGE=ON) configure("a migrated value is kept without warning" legacy EXPECT "TESTING=ON LEGACY=" "COVERAGE=ON LEGACY=") -configure("the prefixed name then decides alone" legacy +configure("the prefixed name then decides" legacy EXPECT "TESTING=OFF LEGACY=" "FUZZING=ON LEGACY=" OPTIONS -DWEBFRONT_ENABLE_TESTING=OFF) -configure("a former name given again is ignored once the prefixed one exists" legacy IGNORED 1 - EXPECT "TESTING=OFF LEGACY=" "FUZZING=ON LEGACY=" +configure("a former name given later switches a cached prefixed value" legacy MIGRATED 2 + EXPECT "TESTING=ON LEGACY=" "FUZZING=OFF LEGACY=" OPTIONS -DENABLE_TESTING=ON -DENABLE_FUZZING=OFF) +configure("the same command again only reports the deprecation" legacy KEPT 2 + EXPECT "TESTING=ON LEGACY=" "FUZZING=OFF LEGACY=" + OPTIONS -DENABLE_TESTING=ON -DENABLE_FUZZING=OFF) + +# Both names on one command line: the prefixed one decides. configure("the prefixed name wins when both are given" both IGNORED 1 EXPECT "TESTING=OFF LEGACY=" OPTIONS -DTOP_LEVEL=ON -DENABLE_TESTING=ON -DWEBFRONT_ENABLE_TESTING=OFF) -# An old tree holds ENABLE_TESTING=ON and the FALSE/OFF defaults of the former sanitizer module. +configure("-Wno-deprecated does not hide an ignored value" both-quiet IGNORED 1 + EXPECT "TESTING=OFF LEGACY=" + OPTIONS -Wno-deprecated -DTOP_LEVEL=ON -DENABLE_TESTING=ON -DWEBFRONT_ENABLE_TESTING=OFF) +configure("both names with one value only report the deprecation" both-same KEPT 1 + EXPECT "TESTING=ON LEGACY=" + OPTIONS -DTOP_LEVEL=ON -DENABLE_TESTING=ON -DWEBFRONT_ENABLE_TESTING=ON) + +# An old tree holds typed entries: ENABLE_TESTING=ON and the FALSE/OFF defaults of the former sanitizer module. configure("an old build tree" upgraded OPTIONS -DOLD_TREE=ON -DENABLE_TESTING=ON) configure("an old tree's former defaults never override a new prefixed option" upgraded MIGRATED 1 EXPECT "TESTING=ON LEGACY=" "COVERAGE=ON LEGACY=" "SANITIZER_ADDRESS=ON LEGACY=" OPTIONS -DOLD_TREE=OFF -DTOP_LEVEL=ON -DWEBFRONT_ENABLE_COVERAGE=ON -DWEBFRONT_ENABLE_SANITIZER_ADDRESS=ON) -configure("the former OFF defaults of an old build tree are dropped silently" old-tree - EXPECT "TESTING=OFF LEGACY=" "SANITIZER_THREAD=OFF LEGACY=" - OPTIONS -DTOP_LEVEL=ON -DENABLE_TESTING=OFF -DENABLE_SANITIZER_THREAD=OFF) +configure("an old tree's OFF defaults" old-defaults OPTIONS -DOLD_TREE=ON) +configure("an old tree's OFF defaults are dropped silently" old-defaults + EXPECT "TESTING=OFF LEGACY=" "COVERAGE=OFF LEGACY=" "SANITIZER_ADDRESS=OFF LEGACY=" + OPTIONS -DOLD_TREE=OFF -DTOP_LEVEL=ON) + +# A toolchain file sets normal variables, read after project() as the former option() calls did. +set(toolchain "-DCMAKE_TOOLCHAIN_FILE=${ROOT}/test/cmake/test-options/Toolchain.cmake") +configure("a toolchain file's former name is migrated" toolchain MIGRATED 1 + EXPECT "TESTING=ON LEGACY=" + OPTIONS -DTOP_LEVEL=ON "${toolchain}" -DTOOLCHAIN_LEGACY=ON) +configure("the same toolchain file only reports the deprecation afterwards" toolchain KEPT 1 + EXPECT "TESTING=ON LEGACY=") +configure("a toolchain file's prefixed variable wins over its former name" toolchain-both IGNORED 1 + EXPECT "TESTING=OFF LEGACY=" + OPTIONS -DTOP_LEVEL=ON "${toolchain}" -DTOOLCHAIN_LEGACY=ON -DTOOLCHAIN_PREFIXED=OFF) + configure("a parent's generic names are ignored" subproject EXPECT "TESTING=OFF LEGACY=ON" "FUZZING=OFF LEGACY=ON" "COVERAGE=OFF LEGACY=ON" OPTIONS -DTOP_LEVEL=OFF -DENABLE_TESTING=ON -DENABLE_FUZZING=ON -DENABLE_COVERAGE=ON) @@ -81,4 +114,13 @@ configure("former sanitizer names at the top level are migrated" sanitizers MIGR configure("a parent's generic sanitizer names are ignored" subproject-sanitizers EXPECT "SANITIZER_ADDRESS=OFF LEGACY=ON" "SANITIZER_UNDEFINED_BEHAVIOR=OFF LEGACY=ON" OPTIONS -DTOP_LEVEL=OFF -DENABLE_SANITIZER_ADDRESS=ON -DENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON) + +# The announced removal cannot be forgotten: from 0.7.0 on, the migration refuses to configure. +execute_process(COMMAND "${CMAKE_COMMAND}" -S "${ROOT}/test/cmake/test-options" -B "${WORK_DIR}/removal" + "-DROOT=${ROOT}" -DTOP_LEVEL=ON -DFIXTURE_VERSION=0.7.0 + RESULT_VARIABLE status OUTPUT_VARIABLE output ERROR_VARIABLE error) +string(REGEX REPLACE "[\n ]+" " " flat "${output}${error}") +if(status EQUAL 0 OR NOT flat MATCHES "must no longer read the former ENABLE_\\* test options") + message(FATAL_ERROR "The migration of the former names must fail from WebFront 0.7.0 on: ${output}${error}") +endif() message(STATUS "WebFront's test options ignore a parent's generic names and migrate the former ones") diff --git a/test/cmake/test-options/CMakeLists.txt b/test/cmake/test-options/CMakeLists.txt index 0d61e8d0..334951b5 100644 --- a/test/cmake/test-options/CMakeLists.txt +++ b/test/cmake/test-options/CMakeLists.txt @@ -1,13 +1,21 @@ cmake_minimum_required(VERSION 3.31) if(OLD_TREE) - # A build tree configured before the rename: Sanitizers.cmake declared these former options with option(). + # A build tree configured before the rename: the root declared ENABLE_TESTING and Sanitizers.cmake the other + # former options with option(), so their cache entries are typed BOOL. + option(ENABLE_TESTING "Enable Test Builds" OFF) option(ENABLE_COVERAGE "Enable coverage reporting for gcc/clang" FALSE) option(ENABLE_SANITIZER_ADDRESS "Enable address sanitizer" OFF) + message(STATUS "Former options of ${ROOT} declared") return() endif() +if(FIXTURE_VERSION) + project(TestOptions VERSION ${FIXTURE_VERSION} LANGUAGES NONE) +else() + project(TestOptions LANGUAGES NONE) +endif() +# As in the root CMakeLists.txt, after project(), which reads CMAKE_TOOLCHAIN_FILE (test-options/Toolchain.cmake). include("${ROOT}/cmake/WebFrontTestOptions.cmake") webfront_declare_test_options(${TOP_LEVEL}) -project(TestOptions LANGUAGES NONE) foreach(name TESTING FUZZING COVERAGE SANITIZER_ADDRESS SANITIZER_LEAK SANITIZER_UNDEFINED_BEHAVIOR SANITIZER_THREAD SANITIZER_MEMORY) if(DEFINED CACHE{ENABLE_${name}}) diff --git a/test/cmake/test-options/Toolchain.cmake b/test/cmake/test-options/Toolchain.cmake new file mode 100644 index 00000000..7fc847bf --- /dev/null +++ b/test/cmake/test-options/Toolchain.cmake @@ -0,0 +1,7 @@ +# Normal variables, as a toolchain file sets them: TOOLCHAIN_LEGACY sets the former name, TOOLCHAIN_PREFIXED the new one. +if(TOOLCHAIN_LEGACY) + set(ENABLE_TESTING ON) +endif() +if(DEFINED TOOLCHAIN_PREFIXED) + set(WEBFRONT_ENABLE_TESTING ${TOOLCHAIN_PREFIXED}) +endif() From 260e42ba85a3b7ab5cd3f7479a1dc702099a6013 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 20:11:47 +0100 Subject: [PATCH 4/5] Recognize the deprecation warnings of CMake 4.4 in the option test [#412] CMake 4.4 prints "CMake Warning (deprecated) at" where earlier versions print "CMake Deprecation Warning at", so TestOptionsConfiguration found no migration message on the CI runners. The patterns accept both forms; the test passes with CMake 4.2 and 4.4.4. --- test/cmake/CheckTestOptions.cmake | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/cmake/CheckTestOptions.cmake b/test/cmake/CheckTestOptions.cmake index c3868cac..0ee50215 100644 --- a/test/cmake/CheckTestOptions.cmake +++ b/test/cmake/CheckTestOptions.cmake @@ -22,10 +22,11 @@ function(configure name directory) endforeach() # CMake wraps warning text: compare it with single spaces. string(REGEX REPLACE "[\n ]+" " " flat "${log}") - set(prefix "\\(message\\): ENABLE_[A-Z_]+") - set(pattern_MIGRATED "CMake Deprecation Warning at [^ ]+ ${prefix} is deprecated and will be removed in WebFront 0\\.7\\.0: its value") - set(pattern_KEPT "CMake Deprecation Warning at [^ ]+ ${prefix} is deprecated [^:]+: use WEBFRONT_ENABLE_[A-Z_]+, which already has this value") - set(pattern_IGNORED "CMake Warning at [^ ]+ ${prefix} is ignored: WEBFRONT_ENABLE_[A-Z_]+ is set") + # CMake 4.4 prints "CMake Warning (deprecated) at", earlier versions "CMake Deprecation Warning at". + set(deprecation "CMake (Deprecation Warning|Warning \\(deprecated\\)) at [^ ]+ \\(message\\): ENABLE_[A-Z_]+") + set(pattern_MIGRATED "${deprecation} is deprecated and will be removed in WebFront 0\\.7\\.0: its value") + set(pattern_KEPT "${deprecation} is deprecated [^:]+: use WEBFRONT_ENABLE_[A-Z_]+, which already has this value") + set(pattern_IGNORED "CMake Warning at [^ ]+ \\(message\\): ENABLE_[A-Z_]+ is ignored: WEBFRONT_ENABLE_[A-Z_]+ is set") foreach(kind MIGRATED KEPT IGNORED) string(REGEX MATCHALL "${pattern_${kind}}" matches "${flat}") list(LENGTH matches count) @@ -36,7 +37,7 @@ function(configure name directory) message(FATAL_ERROR "${name}: expected ${arg_${kind}} ${kind} messages, got ${count}\n${log}") endif() endforeach() - string(REGEX MATCHALL "CMake (Deprecation )?Warning" all "${flat}") + string(REGEX MATCHALL "CMake (Deprecation )?Warning" all "${flat}") # also "CMake Warning (deprecated)" list(LENGTH all total) math(EXPR expected_total "${arg_MIGRATED} + ${arg_KEPT} + ${arg_IGNORED}") if(NOT total EQUAL expected_total) From 2279ba856b12d2f707ce93b5ddd0fd5abc2c2788 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 09:59:47 +0100 Subject: [PATCH 5/5] Preserve explicit test options matching cached values [#412] --- cmake/WebFrontTestOptions.cmake | 15 ++++++++++++++- docs/CHANGELOG.md | 4 +++- test/cmake/CheckTestOptions.cmake | 20 ++++++++++++++++++++ test/cmake/test-options/CMakeLists.txt | 3 +++ test/cmake/test-options/Toolchain.cmake | 4 ++-- 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/cmake/WebFrontTestOptions.cmake b/cmake/WebFrontTestOptions.cmake index a9ecb5e5..b77e0fe4 100644 --- a/cmake/WebFrontTestOptions.cmake +++ b/cmake/WebFrontTestOptions.cmake @@ -21,9 +21,22 @@ set(_WEBFRONT_FORMER_NAMES_REMOVAL 0.7.0) function(_webfront_option_given name out) set(given OFF) if(DEFINED CACHE{${name}}) + set(resolved_value "${${name}}") get_property(type CACHE ${name} PROPERTY TYPE) - if(type STREQUAL "UNINITIALIZED" OR NOT "${${name}}" STREQUAL "$CACHE{${name}}") + if(type STREQUAL "UNINITIALIZED") set(given ON) + else() + # An equal value does not tell us whether a normal variable shadows the cache. Temporarily change + # only the cache value: a normal binding keeps its value, while a cache lookup sees the probe. + # Derive the probe from the resolved value so it cannot equal a normal binding; restore the cache + # before returning, preserving its type, help text and other properties. + set(cached_value "$CACHE{${name}}") + set(probe "${resolved_value};__webfront_option_probe") + set_property(CACHE ${name} PROPERTY VALUE "${probe}") + if(NOT "${${name}}" STREQUAL "${probe}") + set(given ON) + endif() + set_property(CACHE ${name} PROPERTY VALUE "${cached_value}") endif() elseif(DEFINED ${name}) set(given ON) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 09d3c37b..539160d7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -15,7 +15,9 @@ `-Wno-deprecated` does not hide; otherwise a former name given by this configure is moved to the prefixed option, even over a value an earlier configure left. A true former value left by an older build tree is moved unless the prefixed option is already cached; the `OFF` defaults left there are dropped silently. Moving or repeating a former - name prints a deprecation warning. CI, the documentation and `TestOptionsConfiguration` use the new names. + name prints a deprecation warning. A toolchain's normal variable also counts as given when it equals the cached + value, so a conflicting former name cannot change that prefixed cache entry. CI, the documentation and + `TestOptionsConfiguration` use the new names. ## 0.6.0 - 2026-10-31 diff --git a/test/cmake/CheckTestOptions.cmake b/test/cmake/CheckTestOptions.cmake index 0ee50215..58cca347 100644 --- a/test/cmake/CheckTestOptions.cmake +++ b/test/cmake/CheckTestOptions.cmake @@ -100,6 +100,26 @@ configure("a toolchain file's prefixed variable wins over its former name" toolc EXPECT "TESTING=OFF LEGACY=" OPTIONS -DTOP_LEVEL=ON "${toolchain}" -DTOOLCHAIN_LEGACY=ON -DTOOLCHAIN_PREFIXED=OFF) +# Normal variables still count as given when their values equal typed cache entries. +configure("cache before toolchain overrides" toolchain-cached + EXPECT "TESTING=OFF LEGACY=" "CACHED_TESTING=OFF" + OPTIONS -DTOP_LEVEL=ON "${toolchain}" -DWEBFRONT_ENABLE_TESTING=OFF) +configure("a matching prefixed normal variable preserves the cache" toolchain-cached IGNORED 1 + EXPECT "TESTING=OFF LEGACY=" "CACHED_TESTING=OFF" + OPTIONS -DTOOLCHAIN_LEGACY=ON -DTOOLCHAIN_PREFIXED=OFF) +configure("repeating the matching override preserves the cache" toolchain-cached IGNORED 1 + EXPECT "TESTING=OFF LEGACY=" "CACHED_TESTING=OFF") +configure("removing the toolchain overrides keeps tests disabled" toolchain-cached + EXPECT "TESTING=OFF LEGACY=" "CACHED_TESTING=OFF" + OPTIONS -UTOOLCHAIN_LEGACY -UTOOLCHAIN_PREFIXED) + +configure("cache before a matching former normal variable" toolchain-former-cached + EXPECT "TESTING=ON LEGACY=" "CACHED_TESTING=ON" + OPTIONS -DTOP_LEVEL=ON "${toolchain}" -DWEBFRONT_ENABLE_TESTING=ON) +configure("a matching former normal variable still migrates" toolchain-former-cached MIGRATED 1 + EXPECT "TESTING=OFF LEGACY=" "CACHED_TESTING=OFF" + OPTIONS -DENABLE_TESTING:BOOL=OFF -DTOOLCHAIN_LEGACY=OFF) + configure("a parent's generic names are ignored" subproject EXPECT "TESTING=OFF LEGACY=ON" "FUZZING=OFF LEGACY=ON" "COVERAGE=OFF LEGACY=ON" OPTIONS -DTOP_LEVEL=OFF -DENABLE_TESTING=ON -DENABLE_FUZZING=ON -DENABLE_COVERAGE=ON) diff --git a/test/cmake/test-options/CMakeLists.txt b/test/cmake/test-options/CMakeLists.txt index 334951b5..4aac041e 100644 --- a/test/cmake/test-options/CMakeLists.txt +++ b/test/cmake/test-options/CMakeLists.txt @@ -24,4 +24,7 @@ foreach(name TESTING FUZZING COVERAGE SANITIZER_ADDRESS SANITIZER_LEAK SANITIZER set(legacy "") endif() message(STATUS "${name}=${WEBFRONT_ENABLE_${name}} LEGACY=${legacy}") + if(DEFINED CACHE{WEBFRONT_ENABLE_${name}}) + message(STATUS "CACHED_${name}=$CACHE{WEBFRONT_ENABLE_${name}}") + endif() endforeach() diff --git a/test/cmake/test-options/Toolchain.cmake b/test/cmake/test-options/Toolchain.cmake index 7fc847bf..25c4ab8d 100644 --- a/test/cmake/test-options/Toolchain.cmake +++ b/test/cmake/test-options/Toolchain.cmake @@ -1,6 +1,6 @@ # Normal variables, as a toolchain file sets them: TOOLCHAIN_LEGACY sets the former name, TOOLCHAIN_PREFIXED the new one. -if(TOOLCHAIN_LEGACY) - set(ENABLE_TESTING ON) +if(DEFINED TOOLCHAIN_LEGACY) + set(ENABLE_TESTING ${TOOLCHAIN_LEGACY}) endif() if(DEFINED TOOLCHAIN_PREFIXED) set(WEBFRONT_ENABLE_TESTING ${TOOLCHAIN_PREFIXED})