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 01/33] 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 02/33] 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 03/33] 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 04/33] 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 b5c5475d6260d0118ebe931a84f0c36919771e6c Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:46:08 +0100 Subject: [PATCH 05/33] Build the desktop CI jobs with four parallel jobs [#435] --- .github/workflows/BuildAndTest.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/BuildAndTest.yml b/.github/workflows/BuildAndTest.yml index a951ee80..24eedf41 100644 --- a/.github/workflows/BuildAndTest.yml +++ b/.github/workflows/BuildAndTest.yml @@ -128,7 +128,7 @@ jobs: -DCMAKE_CXX_SCAN_FOR_MODULES=OFF ${{ matrix.options }} - name: Build - run: python3 test/tools/MeasureCommand.py --output build/build-resources.json -- cmake --build build --config ${{ matrix.build_type }} --parallel 2 + run: python3 test/tools/MeasureCommand.py --output build/build-resources.json -- cmake --build build --config ${{ matrix.build_type }} --parallel 4 - name: Ensure WebView2 Evergreen runtime if: runner.os == 'Windows' shell: pwsh From 6c56179512868370de7c816f0a60a98b9018946a Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:48:12 +0100 Subject: [PATCH 06/33] Add the build-time study workflow and its test options [#435] --- .github/workflows/BuildStudy.yml | 142 +++++++++++++++++++++++++++++++ test/tools/BuildStudy.py | 128 ++++++++++++++++++++++++++++ test/tools/BuildStudyReport.py | 47 ++++++++++ test/unit/CMakeLists.txt | 24 ++++++ 4 files changed, 341 insertions(+) create mode 100644 .github/workflows/BuildStudy.yml create mode 100644 test/tools/BuildStudy.py create mode 100644 test/tools/BuildStudyReport.py diff --git a/.github/workflows/BuildStudy.yml b/.github/workflows/BuildStudy.yml new file mode 100644 index 00000000..7b3a72de --- /dev/null +++ b/.github/workflows/BuildStudy.yml @@ -0,0 +1,142 @@ +name: Build time study + +# Measurements for #435, run by hand: each job times one configuration of the tests under the compiler-cache scenarios of a +# pull request (test/tools/BuildStudy.py) and the report job tabulates them. Nothing here gates a merge. +on: + # Temporary: a workflow absent from the default branch cannot be dispatched, so the study branch runs it on push. + push: + branches: [435-ci-build-time] + paths: ['.github/workflows/BuildStudy.yml', 'test/tools/BuildStudy*.py', 'test/unit/CMakeLists.txt'] + workflow_dispatch: + inputs: + variants: + description: 'Comma-separated variants to run (empty: all)' + default: '' + +permissions: + contents: read + +env: + CPM_SOURCE_CACHE: ${{ github.workspace }}/.cache/CPM + +jobs: + image: + runs-on: ubuntu-24.04 + outputs: + image: ${{ steps.tag.outputs.image }} + matrix: ${{ steps.matrix.outputs.matrix }} + steps: + - uses: actions/checkout@v7 + - id: tag + run: | + hash=$(sha256sum .github/docker/linux-ci.Dockerfile | cut -c1-16) + echo "image=ghcr.io/${GITHUB_REPOSITORY,,}/linux-ci:$hash" >> "$GITHUB_OUTPUT" + - id: matrix + env: + REQUESTED: ${{ inputs.variants }} + run: | + python3 - <<'PY' >> "$GITHUB_OUTPUT" + import json, os + all_variants = ['base-all-j2', 'base-all-j4', 'base-j2', 'base-j4', 'unity-b2', 'unity-b4', 'unity-b8', 'unity-b16', + 'unity-heavy-b4', 'unity-heavy-b13', 'pch', 'pch-unity-heavy-b4'] + requested = [v for v in os.environ.get('REQUESTED', '').replace(' ', '').split(',') if v] or all_variants + print('matrix=' + json.dumps({'os': ['windows', 'linux'], 'variant': requested})) + PY + + study: + needs: image + permissions: + contents: read + packages: read + strategy: + fail-fast: false + matrix: ${{ fromJSON(needs.image.outputs.matrix) }} + name: ${{ matrix.os }} ${{ matrix.variant }} + runs-on: ${{ matrix.os == 'windows' && 'windows-2025' || 'ubuntu-26.04' }} + container: ${{ matrix.os == 'linux' && fromJSON(format('{{"image":"{0}","credentials":{{"username":"{1}","password":"{2}"}},"options":"--shm-size=1g"}}', needs.image.outputs.image, github.actor, github.token)) || '' }} + timeout-minutes: 240 + steps: + - uses: actions/checkout@v7 + - uses: ./.github/actions/remove-node + - uses: ./.github/actions/setup-cmake + with: + version: '4.4.4' + - name: Point the CPM cache at the workspace + shell: bash + run: echo "CPM_SOURCE_CACHE=$GITHUB_WORKSPACE/.cache/CPM" >> "$GITHUB_ENV" + - uses: mozilla-actions/sccache-action@7d986dd989559c6ecdb630a3fd2557667be217ad # v0.0.9 + - uses: actions/cache@v4 + with: + path: .cache/CPM + key: cpm-study-${{ runner.os }}-${{ hashFiles('CMakeLists.txt', 'cmake/*.cmake', 'test/unit/CMakeLists.txt') }} + restore-keys: cpm-study-${{ runner.os }}- + - name: Initialize MSVC environment + if: matrix.os == 'windows' + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1 + - name: Local-disk compiler cache + shell: bash + run: | + echo "SCCACHE_GHA_ENABLED=false" >> "$GITHUB_ENV" + echo "SCCACHE_DIR=$RUNNER_TEMP/sccache-study" >> "$GITHUB_ENV" + echo "SCCACHE_CACHE_SIZE=20G" >> "$GITHUB_ENV" + - name: Machine + shell: bash + run: | + cmake --version | head -1 + (nproc || sysctl -n hw.ncpu || echo "$NUMBER_OF_PROCESSORS") 2>/dev/null + (cl 2>&1 | head -1) || g++ --version | head -1 + - name: Measure + shell: bash + run: | + case "${{ matrix.variant }}" in + base-all-j2) jobs=2; target=all; extra="" ;; + base-all-j4) jobs=4; target=all; extra="" ;; + base-j2) jobs=2; target=tests; extra="" ;; + base-j4) jobs=4; target=tests; extra="" ;; + unity-b2) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=2" ;; + unity-b4) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=4" ;; + unity-b8) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=8" ;; + unity-b16) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=16" ;; + unity-heavy-b4) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=4 -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; + unity-heavy-b13) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=13 -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; + pch) jobs=4; target=tests; extra="-DWEBFRONT_TEST_PCH=ON" ;; + pch-unity-heavy-b4) jobs=4; target=tests; extra="-DWEBFRONT_TEST_PCH=ON -DWEBFRONT_TEST_UNITY_BATCH=4 -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; + *) echo "unknown variant"; exit 1 ;; + esac + if [ "${{ matrix.os }}" = windows ]; then + config=Release + platform="-DWEBFRONT_EMBED_WEBVIEW2=ON -DWEBFRONT_WEBTEST_FRONTEND=WebView2" + else + config=Debug + platform="-DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DENABLE_COVERAGE=ON -DWEBFRONT_REQUIRE_REFLECTION_TESTS=ON" + fi + # shellcheck disable=SC2086 + python3 test/tools/BuildStudy.py --name "${{ matrix.os }}-${{ matrix.variant }}" --build-dir study/build \ + --jobs "$jobs" --target "$target" --config "$config" --output "study/${{ matrix.os }}-${{ matrix.variant }}.json" \ + -- $platform $extra + - uses: actions/upload-artifact@v4 + if: always() + with: + name: study-${{ matrix.os }}-${{ matrix.variant }} + path: study/*.json + if-no-files-found: ignore + + report: + needs: study + if: ${{ !cancelled() }} + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v7 + - uses: actions/download-artifact@v4 + with: + pattern: study-* + path: study-results + merge-multiple: true + - name: Tabulate + run: python3 test/tools/BuildStudyReport.py study-results | tee -a "$GITHUB_STEP_SUMMARY" > study-report.md + - uses: actions/upload-artifact@v4 + with: + name: study-report + path: | + study-report.md + study-results/ diff --git a/test/tools/BuildStudy.py b/test/tools/BuildStudy.py new file mode 100644 index 00000000..40cb53a4 --- /dev/null +++ b/test/tools/BuildStudy.py @@ -0,0 +1,128 @@ +"""Build-time study (#435): time one CMake configuration of the tests under the compiler-cache scenarios of a pull request. + +Every scenario is a clean build of one target. The compiler cache (sccache, local disk) is empty for `cold`, complete for +`warm`, and complete except for the translation units that include the file a scenario changed. The changed file is restored +afterwards. Writes one JSON report (stdlib only).""" +import argparse +import json +import os +from pathlib import Path +import re +import shutil +import subprocess +import sys + +sys.path.insert(0, str(Path(__file__).parent)) +from MeasureCommand import measure # noqa: E402 + +ROOT = Path(__file__).resolve().parents[2] +SCENARIOS = [ + ('cold', None), + ('warm', None), + ('header', 'include/webfront/WebFront.hpp'), + ('heavy-test', 'test/unit/WebFrontTests.cpp'), + ('light-test', 'test/unit/MimeTypeTests.cpp'), +] + + +def run(command, **kwargs): + print('+', ' '.join(map(str, command)), flush=True) + return subprocess.run(command, check=True, **kwargs) + + +def sccache_counts(): + output = subprocess.run(['sccache', '--show-stats'], capture_output=True, text=True, check=True).stdout + counts = {} + for key in ('Compile requests', 'Cache hits', 'Cache misses'): + match = re.search(r'^' + key + r'\s+(\d+)', output, re.MULTILINE) + counts[key] = int(match.group(1)) if match else None + return counts + + +def ninja_units(build): + """(output, milliseconds) of the last build, from .ninja_log (the log keeps the last run of each output).""" + units = [] + log = build / '.ninja_log' + if not log.exists(): + return units + for line in log.read_text().splitlines(): + fields = line.split('\t') + if len(fields) >= 4 and fields[0].isdigit(): + units.append((fields[3], int(fields[1]) - int(fields[0]))) + return units + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument('--name', required=True) + parser.add_argument('--build-dir', type=Path, required=True) + parser.add_argument('--jobs', type=int, required=True) + parser.add_argument('--target', default='tests') + parser.add_argument('--config', default='Release') + parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--scenarios', default=','.join(name for name, _ in SCENARIOS)) + parser.add_argument('cmake_args', nargs=argparse.REMAINDER) + args = parser.parse_args() + cmake_args = args.cmake_args[1:] if args.cmake_args[:1] == ['--'] else args.cmake_args + build = args.build_dir.resolve() + wanted = args.scenarios.split(',') + results = {'name': args.name, 'jobs': args.jobs, 'target': args.target, 'config': args.config, + 'cmake_args': cmake_args, 'platform': sys.platform, 'scenarios': {}} + + def write(): + args.output.parent.mkdir(parents=True, exist_ok=True) + args.output.write_text(json.dumps(results, indent=2) + '\n', encoding='utf-8') + + shutil.rmtree(build, ignore_errors=True) + configure = measure_command(['cmake', '-S', str(ROOT), '-B', str(build), '-G', 'Ninja', f'-DCMAKE_BUILD_TYPE={args.config}', + '-DENABLE_TESTING=ON', '-DWEBFRONT_EMBED_CEF=OFF', '-DENABLE_CACHE=OFF', + '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache', '-DCMAKE_CXX_SCAN_FOR_MODULES=OFF'] + cmake_args, + build.parent / (args.name + '-configure.json')) + results['configure_seconds'] = configure['wall_seconds'] + if configure['exit_code']: + results['error'] = 'configure failed' + write() + return 1 + subprocess.run(['sccache', '--stop-server'], capture_output=True) + subprocess.run(['sccache', '--start-server'], capture_output=True) + status = 0 + for name, changed in SCENARIOS: + if name not in wanted: + continue + original = None + if changed: + path = ROOT / changed + original = path.read_bytes() + path.write_bytes(original + b'\n// build study ' + name.encode() + b'\n') + try: + subprocess.run(['sccache', '--zero-stats'], capture_output=True, check=True) + command = ['cmake', '--build', str(build), '--config', args.config, '--target', args.target, + '--parallel', str(args.jobs), '--clean-first'] + report = measure_command(command, build.parent / (args.name + '-' + name + '.json')) + counts = sccache_counts() + units = sorted(ninja_units(build), key=lambda unit: -unit[1]) + report.update({'sccache': counts, 'units': len(units), + 'unit_seconds_total': sum(ms for _, ms in units) / 1000, + 'slowest_units': [{'output': out, 'seconds': ms / 1000} for out, ms in units[:15]]}) + results['scenarios'][name] = report + write() + if report['exit_code']: + status = 1 + break + finally: + if original is not None: + path.write_bytes(original) + write() + return status + + +def measure_command(command, output): + code_report = {} + exit_code = measure(command, output) + code_report.update(json.loads(output.read_text())) + code_report['exit_code'] = exit_code + return code_report + + +if __name__ == '__main__': + raise SystemExit(main()) diff --git a/test/tools/BuildStudyReport.py b/test/tools/BuildStudyReport.py new file mode 100644 index 00000000..b4e36ff9 --- /dev/null +++ b/test/tools/BuildStudyReport.py @@ -0,0 +1,47 @@ +"""Tabulate the reports of BuildStudy.py as Markdown (stdlib only).""" +import json +from pathlib import Path +import sys + +ORDER = ['cold', 'warm', 'header', 'heavy-test', 'light-test'] + + +def main(directory): + reports = [json.loads(path.read_text()) for path in sorted(Path(directory).rglob('*-*.json'))] + reports = [report for report in reports if 'scenarios' in report] + for system in sorted({report['name'].split('-')[0] for report in reports}): + mine = [report for report in reports if report['name'].startswith(system + '-')] + print(f'\n### {system}: wall seconds per scenario (clean build of the target)\n') + print('| variant | target | jobs | configure | ' + ' | '.join(ORDER) + ' | peak RSS MB (cold) |') + print('|---|---|---|---|' + '---|' * len(ORDER) + '---|') + for report in mine: + cells = [] + for name in ORDER: + scenario = report['scenarios'].get(name) + if not scenario: + cells.append('-') + continue + text = f"{scenario['wall_seconds']:.0f}" + ('' if not scenario['exit_code'] else ' FAIL') + counts = scenario.get('sccache') or {} + if counts.get('Compile requests') is not None: + text += f" ({counts['Cache hits']}/{counts['Compile requests']})" + cells.append(text) + cold = report['scenarios'].get('cold', {}) + rss = cold.get('sampled_peak_family_rss_bytes', 0) / 1e6 + variant = report['name'].split('-', 1)[1] + print(f"| {variant} | {report['target']} | {report['jobs']} | {report.get('configure_seconds', 0):.0f} | " + + ' | '.join(cells) + f' | {rss:.0f} |') + print('\nCells are wall seconds, then (sccache hits/requests). Cold: empty cache; warm: complete cache; ' + 'header/heavy-test/light-test: complete cache, one file changed.\n') + for report in mine: + cold = report['scenarios'].get('cold') + if cold and cold.get('slowest_units') and report['name'].endswith(('-base-j4', '-unity-b4', '-pch')): + print(f"
{report['name']}: slowest units, cold\n") + print('| unit | s |\n|---|---|') + for unit in cold['slowest_units'][:10]: + print(f"| {unit['output']} | {unit['seconds']:.0f} |") + print('\n
\n') + + +if __name__ == '__main__': + main(sys.argv[1] if len(sys.argv) > 1 else '.') diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index d02fd04e..b6acf8d8 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -47,6 +47,30 @@ if(MSVC) target_compile_options(tests PRIVATE /bigobj) endif() target_compile_definitions(tests PRIVATE WEBFRONT_SOURCE_DIR="${PROJECT_SOURCE_DIR}") + +# Build-time study (#435), measurements only (docs/BUILD_TIME_STUDY.md): both knobs default to the regular build. +# WEBFRONT_TEST_UNITY_BATCH=N groups the translation units of `tests` by N (0: no unity build); +# WEBFRONT_TEST_UNITY_HEAVY=ON limits the grouping to the heavy units (those instantiating a full application); +# WEBFRONT_TEST_PCH=ON precompiles the headers every test includes. +set(WEBFRONT_TEST_UNITY_BATCH 0 CACHE STRING "Study (#435): UNITY_BUILD_BATCH_SIZE of the tests target, 0 disables it") +option(WEBFRONT_TEST_UNITY_HEAVY "Study (#435): group only the heavy translation units of the tests target" OFF) +option(WEBFRONT_TEST_PCH "Study (#435): precompiled headers for the tests target" OFF) +if(WEBFRONT_TEST_UNITY_BATCH GREATER 0) + set_target_properties(tests PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE ${WEBFRONT_TEST_UNITY_BATCH}) + if(WEBFRONT_TEST_UNITY_HEAVY) + set(_heavy WebFrontTests BroadcastTests CommandsTests ApplicationTaskTests StdnetShutdownTests FrontendContractTests + JsFunctionSenderTests AutomationTests ReactStoreTests DeveloperTests CEFMacrosTests JasmineConsumerTests WfDriverTests) + foreach(_source IN LISTS TESTS_LIST) + cmake_path(GET _source STEM _stem) + if(NOT _stem IN_LIST _heavy) + set_source_files_properties(${_source} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) + endif() + endforeach() + endif() +endif() +if(WEBFRONT_TEST_PCH) + target_precompile_headers(tests PRIVATE ) +endif() configure_file(Version.hpp.in generated/Version.hpp @ONLY) target_include_directories(tests PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/generated") From b936616b5ce13a45f6ed35533fb1322937e36cac Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:49:49 +0100 Subject: [PATCH 07/33] Return from RunWithDeadline.sh when the command ends, not at the deadline [#435] --- .github/workflows/BuildStudy.yml | 2 +- cmake/RunWithDeadline.sh | 13 +++++++++---- test/cmake/CheckRunWithDeadline.cmake | 19 +++++++++++++++++++ test/unit/CMakeLists.txt | 3 +++ 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 test/cmake/CheckRunWithDeadline.cmake diff --git a/.github/workflows/BuildStudy.yml b/.github/workflows/BuildStudy.yml index 7b3a72de..a8ec9c56 100644 --- a/.github/workflows/BuildStudy.yml +++ b/.github/workflows/BuildStudy.yml @@ -6,7 +6,7 @@ on: # Temporary: a workflow absent from the default branch cannot be dispatched, so the study branch runs it on push. push: branches: [435-ci-build-time] - paths: ['.github/workflows/BuildStudy.yml', 'test/tools/BuildStudy*.py', 'test/unit/CMakeLists.txt'] + paths: ['.github/workflows/BuildStudy.yml', 'test/tools/BuildStudy*.py'] workflow_dispatch: inputs: variants: diff --git a/cmake/RunWithDeadline.sh b/cmake/RunWithDeadline.sh index 7202dbe5..9aafffab 100755 --- a/cmake/RunWithDeadline.sh +++ b/cmake/RunWithDeadline.sh @@ -9,14 +9,19 @@ expired=$(mktemp -u) "$@" & command_pid=$! ( - sleep "$limit" + sleep "$limit" & + sleeper=$! + trap 'kill "$sleeper" 2>/dev/null; exit 0' TERM + wait "$sleeper" || exit 0 : > "$expired" - kill -KILL -- "-$command_pid" 2>/dev/null -) & + kill -KILL -- "-$command_pid" 2>/dev/null || kill -KILL "$command_pid" 2>/dev/null +# The watchdog must not hold the caller's output pipes: the caller waits for them to close, so a sleeping watchdog would +# delay a command that already finished until the deadline (30 s per Jasmine case under dash, which has no job control here). +) >/dev/null 2>&1 & watchdog_pid=$! wait "$command_pid" status=$? -kill -KILL -- "-$watchdog_pid" 2>/dev/null +kill -TERM "$watchdog_pid" 2>/dev/null # Whatever the command left behind in its group goes with it. kill -KILL -- "-$command_pid" 2>/dev/null # Only the watchdog's flag makes a kill a timeout: an unrelated SIGKILL keeps its own status. diff --git a/test/cmake/CheckRunWithDeadline.cmake b/test/cmake/CheckRunWithDeadline.cmake new file mode 100644 index 00000000..dbc72602 --- /dev/null +++ b/test/cmake/CheckRunWithDeadline.cmake @@ -0,0 +1,19 @@ +# RunWithDeadline.sh must return when its command does, not when the deadline expires (#435), and still kill at the deadline. +function(run_timed) + string(TIMESTAMP start "%s") + execute_process(COMMAND sh "${SCRIPT}" ${ARGN} RESULT_VARIABLE status TIMEOUT 25) + string(TIMESTAMP end "%s") + math(EXPR elapsed "${end} - ${start}") + set(status "${status}" PARENT_SCOPE) + set(elapsed "${elapsed}" PARENT_SCOPE) +endfunction() + +run_timed(20 sh -c "exit 3") +if(NOT status EQUAL 3 OR elapsed GREATER 8) + message(FATAL_ERROR "A finished command must return its status at once: status ${status}, ${elapsed} s of a 20 s deadline") +endif() + +run_timed(1 sleep 20) +if(NOT status EQUAL 124 OR elapsed GREATER 8) + message(FATAL_ERROR "A command past its deadline must be killed: status ${status}, ${elapsed} s") +endif() diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index b6acf8d8..9ecf7471 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -165,6 +165,9 @@ add_test(NAME BootstrapProvisioning # Windows bash.exe may be the WSL launcher rather than a native Bash runtime. if(UNIX) + add_test(NAME RunWithDeadline COMMAND ${CMAKE_COMMAND} -DSCRIPT=${PROJECT_SOURCE_DIR}/cmake/RunWithDeadline.sh + -P ${PROJECT_SOURCE_DIR}/test/cmake/CheckRunWithDeadline.cmake) + set_tests_properties(RunWithDeadline PROPERTIES TIMEOUT 60 LABELS fast) find_program(WEBFRONT_TEST_BASH_EXECUTABLE bash) find_package(Git QUIET) if(WEBFRONT_TEST_BASH_EXECUTABLE AND Git_FOUND) From ada99ee7ea1e38cf75b4c1fbd16d3cbca313fcad Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:54:41 +0100 Subject: [PATCH 08/33] Compile the heavy unit tests as a unity build and study the variants [#435] --- .github/workflows/BuildStudy.yml | 18 ++++++++---------- test/unit/CMakeLists.txt | 23 +++++++++++++---------- test/unit/CommandsTests.cpp | 2 +- test/unit/FrontendContractTests.cpp | 12 ++++++------ test/unit/JsFunctionSenderTests.cpp | 10 +++++----- test/unit/Mocks.hpp | 2 ++ 6 files changed, 35 insertions(+), 32 deletions(-) diff --git a/.github/workflows/BuildStudy.yml b/.github/workflows/BuildStudy.yml index a8ec9c56..b041e84d 100644 --- a/.github/workflows/BuildStudy.yml +++ b/.github/workflows/BuildStudy.yml @@ -37,8 +37,9 @@ jobs: run: | python3 - <<'PY' >> "$GITHUB_OUTPUT" import json, os - all_variants = ['base-all-j2', 'base-all-j4', 'base-j2', 'base-j4', 'unity-b2', 'unity-b4', 'unity-b8', 'unity-b16', - 'unity-heavy-b4', 'unity-heavy-b13', 'pch', 'pch-unity-heavy-b4'] + all_variants = ['base-all-j2', 'base-all-j4', 'base-j2', 'base-j4', 'unity-heavy-b2', + 'unity-heavy-b3', 'unity-heavy-b4', 'unity-heavy-b6', 'unity-heavy-b12', 'pch', 'pch-unity-heavy-b4', + 'pch-unity-heavy-b12', 'unity-all-b16'] requested = [v for v in os.environ.get('REQUESTED', '').replace(' ', '').split(',') if v] or all_variants print('matrix=' + json.dumps({'os': ['windows', 'linux'], 'variant': requested})) PY @@ -88,19 +89,16 @@ jobs: - name: Measure shell: bash run: | - case "${{ matrix.variant }}" in + v="${{ matrix.variant }}" + case "$v" in base-all-j2) jobs=2; target=all; extra="" ;; base-all-j4) jobs=4; target=all; extra="" ;; base-j2) jobs=2; target=tests; extra="" ;; base-j4) jobs=4; target=tests; extra="" ;; - unity-b2) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=2" ;; - unity-b4) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=4" ;; - unity-b8) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=8" ;; - unity-b16) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=16" ;; - unity-heavy-b4) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=4 -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; - unity-heavy-b13) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=13 -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; pch) jobs=4; target=tests; extra="-DWEBFRONT_TEST_PCH=ON" ;; - pch-unity-heavy-b4) jobs=4; target=tests; extra="-DWEBFRONT_TEST_PCH=ON -DWEBFRONT_TEST_UNITY_BATCH=4 -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; + unity-heavy-b*) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=${v#unity-heavy-b} -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; + pch-unity-heavy-b*) jobs=4; target=tests; extra="-DWEBFRONT_TEST_PCH=ON -DWEBFRONT_TEST_UNITY_BATCH=${v#pch-unity-heavy-b} -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; + unity-all-b*) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=${v#unity-all-b}" ;; *) echo "unknown variant"; exit 1 ;; esac if [ "${{ matrix.os }}" = windows ]; then diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 9ecf7471..f483ba78 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -55,19 +55,22 @@ target_compile_definitions(tests PRIVATE WEBFRONT_SOURCE_DIR="${PROJECT_SOURCE_D set(WEBFRONT_TEST_UNITY_BATCH 0 CACHE STRING "Study (#435): UNITY_BUILD_BATCH_SIZE of the tests target, 0 disables it") option(WEBFRONT_TEST_UNITY_HEAVY "Study (#435): group only the heavy translation units of the tests target" OFF) option(WEBFRONT_TEST_PCH "Study (#435): precompiled headers for the tests target" OFF) +# The heavy units instantiate a full application; the others are light and keep the regular build. +set(_heavy WebFrontTests CommandsTests ApplicationTaskTests StdnetShutdownTests FrontendContractTests JsFunctionSenderTests + AutomationTests ReactStoreTests DeveloperTests CEFMacrosTests JasmineConsumerTests WfDriverTests) if(WEBFRONT_TEST_UNITY_BATCH GREATER 0) set_target_properties(tests PROPERTIES UNITY_BUILD ON UNITY_BUILD_BATCH_SIZE ${WEBFRONT_TEST_UNITY_BATCH}) - if(WEBFRONT_TEST_UNITY_HEAVY) - set(_heavy WebFrontTests BroadcastTests CommandsTests ApplicationTaskTests StdnetShutdownTests FrontendContractTests - JsFunctionSenderTests AutomationTests ReactStoreTests DeveloperTests CEFMacrosTests JasmineConsumerTests WfDriverTests) - foreach(_source IN LISTS TESTS_LIST) - cmake_path(GET _source STEM _stem) - if(NOT _stem IN_LIST _heavy) - set_source_files_properties(${_source} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) - endif() - endforeach() - endif() endif() +foreach(_source IN LISTS TESTS_LIST) + cmake_path(GET _source STEM _stem) + if(NOT _stem IN_LIST _heavy) + if(WEBFRONT_TEST_UNITY_HEAVY) + set_source_files_properties(${_source} PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON) + endif() + # WebFront.hpp declares names the light units define themselves (MSVC C4459): they must not receive it. + set_source_files_properties(${_source} PROPERTIES SKIP_PRECOMPILE_HEADERS ON) + endif() +endforeach() if(WEBFRONT_TEST_PCH) target_precompile_headers(tests PRIVATE ) endif() diff --git a/test/unit/CommandsTests.cpp b/test/unit/CommandsTests.cpp index c528b3a8..4ebaf590 100644 --- a/test/unit/CommandsTests.cpp +++ b/test/unit/CommandsTests.cpp @@ -64,7 +64,7 @@ struct FakeApp { function list; function start; function cancel; - shared_ptr> closed = make_shared>(); + shared_ptr> closed = make_shared>(); vector calls; [[nodiscard]] bool hasCppFunction(string_view name) const { diff --git a/test/unit/FrontendContractTests.cpp b/test/unit/FrontendContractTests.cpp index 2a12a0f3..9e8ff756 100644 --- a/test/unit/FrontendContractTests.cpp +++ b/test/unit/FrontendContractTests.cpp @@ -108,8 +108,8 @@ struct ContractFrontend { template void checkSession() { - using App = BasicWFWithFrontend, ContractFrontend>; - App app; + using ContractApp = BasicWFWithFrontend, ContractFrontend>; + ContractApp app; const auto state = ContractIoContext::current; std::exception_ptr error; std::jthread caller([&] { @@ -164,8 +164,8 @@ void checkSession() { template void checkStartupFailure() { - using App = BasicWFWithFrontend, ContractFrontend>; - App app; + using ContractApp = BasicWFWithFrontend, ContractFrontend>; + ContractApp app; const auto state = ContractIoContext::current; REQUIRE_THROWS_WITH(app.show(), "frontend failed before window creation"); std::lock_guard lock(state->mutex); @@ -250,9 +250,9 @@ struct WindowRecorder { }; WindowOptions windowReceivedBy(WebFrontConfig config) { - using App = BasicWFWithFrontend, WindowRecorder>; + using ContractApp = BasicWFWithFrontend, WindowRecorder>; WindowRecorder::received = {.title = "unset", .width = -1, .height = -1}; - App app(std::move(config)); + ContractApp app(std::move(config)); app.show(); app.stop(); return WindowRecorder::received; diff --git a/test/unit/JsFunctionSenderTests.cpp b/test/unit/JsFunctionSenderTests.cpp index 51e53b21..53f9cfce 100644 --- a/test/unit/JsFunctionSenderTests.cpp +++ b/test/unit/JsFunctionSenderTests.cpp @@ -294,7 +294,7 @@ SCENARIO("Typed browser senders can be awaited in a tracked task") { SCENARIO("Cancelled correlation IDs cannot be reused before a late reply") { GIVEN("a registry with one cancelled call") { - detail::PendingCalls calls; + webfront::detail::PendingCalls calls; auto retained = std::make_shared(42); std::weak_ptr released = retained; const auto cancelled = calls.add({[retained](const auto&) { }, [retained](auto) { }}); @@ -407,7 +407,7 @@ SCENARIO("Browser senders reject inconsistent return envelopes") { SCENARIO("Correlation exhaustion fails until an outstanding reply releases an ID") { GIVEN("a registry with every ID reserved by an unanswered cancelled call") { - detail::PendingCalls calls; + webfront::detail::PendingCalls calls; for (std::size_t i = 0; i < std::numeric_limits::max(); ++i) { const auto id = calls.add({}); calls.cancel(id); @@ -430,9 +430,9 @@ SCENARIO("Correlation exhaustion fails until an outstanding reply releases an ID SCENARIO("A sender reports a socket expiring independently of its correlation registry") { GIVEN("an expired socket and a still-owned registry") { - auto calls = std::make_shared>(); + auto calls = std::make_shared>(); std::vector payload(sizeof(msg::FunctionCallHeader)); - detail::BrowserCallSender sender{calls, {}, std::move(payload)}; + webfront::detail::BrowserCallSender sender{calls, {}, std::move(payload)}; Observed observed; ex::inplace_stop_source stop; auto operation = ex::connect(std::move(sender), Receiver{observed, stop.get_token()}); @@ -448,7 +448,7 @@ SCENARIO("A sender reports a socket expiring independently of its correlation re SCENARIO("An obsolete registration cannot cancel a replacement with the same wire ID") { GIVEN("a completed call whose operation is still delivering an error") { - detail::PendingCalls calls; + webfront::detail::PendingCalls calls; int originalOwner{}; int replacementOwner{}; const auto old = calls.add({.complete = [](const auto&) { }, .reject = {}, .owner = &originalOwner}); diff --git a/test/unit/Mocks.hpp b/test/unit/Mocks.hpp index 5a5394e3..0548a6dc 100644 --- a/test/unit/Mocks.hpp +++ b/test/unit/Mocks.hpp @@ -2,6 +2,8 @@ /// @author Ambroise Leclerc /// @brief Mocks +#pragma once + #include #include From 025a4411cef689ca801adffc28329e11ccf90f8f Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:55:53 +0100 Subject: [PATCH 09/33] Profile where the compile time of a heavy unit goes [#435] --- .github/workflows/BuildStudy.yml | 57 ++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/.github/workflows/BuildStudy.yml b/.github/workflows/BuildStudy.yml index b041e84d..e9564aa7 100644 --- a/.github/workflows/BuildStudy.yml +++ b/.github/workflows/BuildStudy.yml @@ -119,6 +119,63 @@ jobs: path: study/*.json if-no-files-found: ignore + # Where does the compile time of one heavy unit go? MSVC /d1reportTime, GCC -ftime-report, Clang -ftime-trace. + profile: + needs: image + permissions: + contents: read + packages: read + strategy: + fail-fast: false + matrix: + os: [windows, linux, macos] + name: profile ${{ matrix.os }} + runs-on: ${{ matrix.os == 'windows' && 'windows-2025' || matrix.os == 'macos' && 'macos-26' || 'ubuntu-26.04' }} + container: ${{ matrix.os == 'linux' && fromJSON(format('{{"image":"{0}","credentials":{{"username":"{1}","password":"{2}"}},"options":"--shm-size=1g"}}', needs.image.outputs.image, github.actor, github.token)) || '' }} + timeout-minutes: 90 + steps: + - uses: actions/checkout@v7 + - uses: ./.github/actions/remove-node + - uses: ./.github/actions/setup-cmake + with: + version: '4.4.4' + - name: Point the CPM cache at the workspace + shell: bash + run: echo "CPM_SOURCE_CACHE=$GITHUB_WORKSPACE/.cache/CPM" >> "$GITHUB_ENV" + - name: Initialize MSVC environment + if: matrix.os == 'windows' + uses: ilammy/msvc-dev-cmd@0b201ec74fa43914dc39ae48a89fd1d8cb592756 # v1 + - name: Setup Xcode + if: matrix.os == 'macos' + uses: maxim-lobanov/setup-xcode@ed7a3b1fda3918c0306d1b724322adc0b8cc0a90 # v1 + with: + xcode-version: latest + - name: Profile the compilation + shell: bash + run: | + case "${{ matrix.os }}" in + windows) flags="/d1reportTime"; config=Release ;; + linux) flags="-ftime-report"; config=Debug ;; + macos) flags="-ftime-trace -ftime-trace-granularity=2000"; config=Release ;; + esac + cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=$config -DENABLE_TESTING=ON -DWEBFRONT_EMBED_CEF=OFF \ + -DENABLE_CACHE=OFF -DCMAKE_CXX_SCAN_FOR_MODULES=OFF "-DCMAKE_CXX_FLAGS=$flags" + mkdir -p profile + # One minimal application (HelloWorld) and the two heaviest units of the tests, one at a time (-j1: clean timings). + for object in examples/CMakeFiles/HelloWorld.dir/hello-world/HelloWorld.cpp test/unit/CMakeFiles/tests.dir/WebFrontTests.cpp test/unit/CMakeFiles/tests.dir/DeveloperTests.cpp; do + suffix=o; [ "${{ matrix.os }}" = windows ] && suffix=obj + name=$(basename "$object") + ( cd build && ninja -j1 -v "$object.$suffix" ) > "profile/$name.log" 2>&1 || tail -n 30 "profile/$name.log" + done + find build -name '*.json' -path '*CMakeFiles*' -newer build/CMakeCache.txt -exec cp {} profile/ \; 2>/dev/null || true + ls -la profile + - uses: actions/upload-artifact@v4 + if: always() + with: + name: profile-${{ matrix.os }} + path: profile/ + if-no-files-found: ignore + report: needs: study if: ${{ !cancelled() }} From 981452bb38e4e1508ca9a32762d3e45b22dbce05 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:57:42 +0100 Subject: [PATCH 10/33] Do not hold the port lock while an embedded application is compiled [#435] --- test/web/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index 7488b3ec..b9b03618 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -411,7 +411,7 @@ if(_browser_tests_available) --config $ --target life_journey --parallel 2) # Serialize nested builds and browser executables sharing this output directory, while independent unit tests may run. set_tests_properties(JourneyEmbeddedBuild PROPERTIES FIXTURES_REQUIRED JourneyEmbedded - FIXTURES_SETUP JourneyApplication LABELS "web-integration" TIMEOUT 180 RESOURCE_LOCK "webfront_port_9002;webfront_build_tree" PROCESSORS 2) + FIXTURES_SETUP JourneyApplication LABELS "web-integration" TIMEOUT 180 RESOURCE_LOCK "webfront_build_tree" PROCESSORS 2) set(_journey_command "$") if(_developer_xvfb) set(_journey_command "${_developer_xvfb}" -a ${_journey_command}) @@ -576,7 +576,7 @@ if(_browser_tests_available) # Protect the shared build tree and browser DLLs/executables, especially on Windows. set_tests_properties(LifeEmbeddedBuild PROPERTIES FIXTURES_REQUIRED DeveloperGenerated FIXTURES_SETUP LifeEmbedded LABELS "web-integration" TIMEOUT 180 - RESOURCE_LOCK "webfront_port_9002;webfront_build_tree" PROCESSORS 2) + RESOURCE_LOCK "webfront_build_tree" PROCESSORS 2) set(_life_command "$") if(_developer_xvfb) set(_life_command "${_developer_xvfb}" -a ${_life_command}) From 51d3c35061199507dedb7a8dc04267ea96717c2c Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Fri, 30 Oct 2026 23:58:13 +0100 Subject: [PATCH 11/33] Profile with a flag Git Bash does not rewrite; allow profile-only runs [#435] [profile-only] --- .github/workflows/BuildStudy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildStudy.yml b/.github/workflows/BuildStudy.yml index e9564aa7..9d9571ae 100644 --- a/.github/workflows/BuildStudy.yml +++ b/.github/workflows/BuildStudy.yml @@ -46,6 +46,8 @@ jobs: study: needs: image + # A commit message with [profile-only] skips the measurements and runs only the profile job. + if: ${{ !contains(github.event.head_commit.message, '[profile-only]') }} permissions: contents: read packages: read @@ -154,7 +156,7 @@ jobs: shell: bash run: | case "${{ matrix.os }}" in - windows) flags="/d1reportTime"; config=Release ;; + windows) flags="-d1reportTime"; config=Release ;; linux) flags="-ftime-report"; config=Debug ;; macos) flags="-ftime-trace -ftime-trace-granularity=2000"; config=Release ;; esac @@ -178,7 +180,7 @@ jobs: report: needs: study - if: ${{ !cancelled() }} + if: ${{ !cancelled() && !contains(github.event.head_commit.message, '[profile-only]') }} runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v7 From e572947e42a6d38c2ab70bf87fc2be036a75a481 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 00:28:41 +0100 Subject: [PATCH 12/33] Measure the cost of MSVC /analyze; select study variants from the commit message [#435] [variants:noanalyze,noanalyze-pch,noanalyze-unity-heavy-b4,noanalyze-pch-unity-heavy-b4,base-j4,pch-unity-heavy-b4] --- .github/workflows/BuildStudy.yml | 15 ++++++++++++--- cmake/CompilerWarnings.cmake | 6 ++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/BuildStudy.yml b/.github/workflows/BuildStudy.yml index 9d9571ae..a856d623 100644 --- a/.github/workflows/BuildStudy.yml +++ b/.github/workflows/BuildStudy.yml @@ -34,20 +34,24 @@ jobs: - id: matrix env: REQUESTED: ${{ inputs.variants }} + MESSAGE: ${{ github.event.head_commit.message }} run: | python3 - <<'PY' >> "$GITHUB_OUTPUT" import json, os all_variants = ['base-all-j2', 'base-all-j4', 'base-j2', 'base-j4', 'unity-heavy-b2', 'unity-heavy-b3', 'unity-heavy-b4', 'unity-heavy-b6', 'unity-heavy-b12', 'pch', 'pch-unity-heavy-b4', - 'pch-unity-heavy-b12', 'unity-all-b16'] - requested = [v for v in os.environ.get('REQUESTED', '').replace(' ', '').split(',') if v] or all_variants + 'pch-unity-heavy-b12', 'unity-all-b16', 'noanalyze', 'noanalyze-pch', 'noanalyze-unity-heavy-b4', + 'noanalyze-pch-unity-heavy-b4'] + import re + tagged = re.search(r'\[variants:([^\]]*)\]', os.environ.get('MESSAGE', '')) # a push selects variants this way + requested = [v for v in (tagged.group(1) if tagged else os.environ.get('REQUESTED', '')).replace(' ', '').split(',') if v] or all_variants print('matrix=' + json.dumps({'os': ['windows', 'linux'], 'variant': requested})) PY study: needs: image # A commit message with [profile-only] skips the measurements and runs only the profile job. - if: ${{ !contains(github.event.head_commit.message, '[profile-only]') }} + if: ${{ !contains(github.event.head_commit.message, '[profile-only]') && !(matrix.os == 'linux' && startsWith(matrix.variant, 'noanalyze')) }} permissions: contents: read packages: read @@ -98,6 +102,10 @@ jobs: base-j2) jobs=2; target=tests; extra="" ;; base-j4) jobs=4; target=tests; extra="" ;; pch) jobs=4; target=tests; extra="-DWEBFRONT_TEST_PCH=ON" ;; + noanalyze) jobs=4; target=tests; extra="-DWEBFRONT_MSVC_ANALYZE=OFF" ;; + noanalyze-pch) jobs=4; target=tests; extra="-DWEBFRONT_MSVC_ANALYZE=OFF -DWEBFRONT_TEST_PCH=ON" ;; + noanalyze-unity-heavy-b4) jobs=4; target=tests; extra="-DWEBFRONT_MSVC_ANALYZE=OFF -DWEBFRONT_TEST_UNITY_BATCH=4 -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; + noanalyze-pch-unity-heavy-b4) jobs=4; target=tests; extra="-DWEBFRONT_MSVC_ANALYZE=OFF -DWEBFRONT_TEST_PCH=ON -DWEBFRONT_TEST_UNITY_BATCH=4 -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; unity-heavy-b*) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=${v#unity-heavy-b} -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; pch-unity-heavy-b*) jobs=4; target=tests; extra="-DWEBFRONT_TEST_PCH=ON -DWEBFRONT_TEST_UNITY_BATCH=${v#pch-unity-heavy-b} -DWEBFRONT_TEST_UNITY_HEAVY=ON" ;; unity-all-b*) jobs=4; target=tests; extra="-DWEBFRONT_TEST_UNITY_BATCH=${v#unity-all-b}" ;; @@ -124,6 +132,7 @@ jobs: # Where does the compile time of one heavy unit go? MSVC /d1reportTime, GCC -ftime-report, Clang -ftime-trace. profile: needs: image + if: ${{ !contains(github.event.head_commit.message, '[variants:') }} permissions: contents: read packages: read diff --git a/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index 8fb735a6..2657516a 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -4,6 +4,8 @@ function(set_project_warnings project_name) option(WARNINGS_AS_ERRORS "Treat compiler warnings as errors" ON) + # MSVC /analyze roughly doubles the front-end work of every unit (#435): OFF is for measuring that cost, not for CI. + option(WEBFRONT_MSVC_ANALYZE "Run the MSVC code analysis while compiling" ON) set(MSVC_WARNINGS /W4 # Baseline reasonable warnings @@ -35,6 +37,10 @@ function(set_project_warnings project_name) /permissive- # standards conformance mode for MSVC compiler. ) + if(NOT WEBFRONT_MSVC_ANALYZE) + list(FILTER MSVC_WARNINGS EXCLUDE REGEX "^/analyze") + endif() + set(CLANG_WARNINGS -Wall -Wextra # reasonable and standard From 49b9c2d2d65efece9d313cfca106bdab7f843163 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 00:36:13 +0100 Subject: [PATCH 13/33] Give the command its own process group when the shell has no job control [#435] --- cmake/RunWithDeadline.sh | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/cmake/RunWithDeadline.sh b/cmake/RunWithDeadline.sh index 9aafffab..e0e6c229 100755 --- a/cmake/RunWithDeadline.sh +++ b/cmake/RunWithDeadline.sh @@ -4,9 +4,20 @@ # the command started cannot outlive it. Exits with 124 on a timeout (the command was killed), else with its status. limit=$1 shift -set -m expired=$(mktemp -u) -"$@" & +# The command needs its own process group for the deadline to reach everything it started. Job control gives it one; dash +# without a terminal accepts `set -m` yet keeps job control off (and then a group kill reaches nothing), where setsid gives it one instead. +{ set -m; } 2>/dev/null +case $- in + *m*) "$@" & ;; + *) + if command -v setsid >/dev/null 2>&1; then + setsid "$@" & + else + "$@" & + fi + ;; +esac command_pid=$! ( sleep "$limit" & @@ -14,7 +25,7 @@ command_pid=$! trap 'kill "$sleeper" 2>/dev/null; exit 0' TERM wait "$sleeper" || exit 0 : > "$expired" - kill -KILL -- "-$command_pid" 2>/dev/null || kill -KILL "$command_pid" 2>/dev/null + kill -s KILL -- "-$command_pid" 2>/dev/null || kill -KILL "$command_pid" 2>/dev/null # The watchdog must not hold the caller's output pipes: the caller waits for them to close, so a sleeping watchdog would # delay a command that already finished until the deadline (30 s per Jasmine case under dash, which has no job control here). ) >/dev/null 2>&1 & @@ -23,7 +34,7 @@ wait "$command_pid" status=$? kill -TERM "$watchdog_pid" 2>/dev/null # Whatever the command left behind in its group goes with it. -kill -KILL -- "-$command_pid" 2>/dev/null +kill -s KILL -- "-$command_pid" 2>/dev/null # Only the watchdog's flag makes a kill a timeout: an unrelated SIGKILL keeps its own status. if [ -e "$expired" ]; then rm -f "$expired" From 08b43ddad08006cbb6df4ab000fe244638b7a6db Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 00:36:57 +0100 Subject: [PATCH 14/33] Build the study matrix as an include list; no matrix in a job condition [#435] [variants:noanalyze,noanalyze-pch,noanalyze-unity-heavy-b4,noanalyze-pch-unity-heavy-b4,base-j4,pch-unity-heavy-b4] --- .github/workflows/BuildStudy.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildStudy.yml b/.github/workflows/BuildStudy.yml index a856d623..2cf0be50 100644 --- a/.github/workflows/BuildStudy.yml +++ b/.github/workflows/BuildStudy.yml @@ -45,13 +45,15 @@ jobs: import re tagged = re.search(r'\[variants:([^\]]*)\]', os.environ.get('MESSAGE', '')) # a push selects variants this way requested = [v for v in (tagged.group(1) if tagged else os.environ.get('REQUESTED', '')).replace(' ', '').split(',') if v] or all_variants - print('matrix=' + json.dumps({'os': ['windows', 'linux'], 'variant': requested})) + # /analyze exists on MSVC only: its variants have no Linux counterpart. + include = [{'os': o, 'variant': v} for v in requested for o in ('windows', 'linux') if not (o == 'linux' and v.startswith('noanalyze'))] + print('matrix=' + json.dumps({'include': include})) PY study: needs: image # A commit message with [profile-only] skips the measurements and runs only the profile job. - if: ${{ !contains(github.event.head_commit.message, '[profile-only]') && !(matrix.os == 'linux' && startsWith(matrix.variant, 'noanalyze')) }} + if: ${{ !contains(github.event.head_commit.message, '[profile-only]') }} permissions: contents: read packages: read From 19448b729fa8c7d5f20fc9e42c17bf540ad2bf90 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 00:59:02 +0100 Subject: [PATCH 15/33] Repeat the Windows measurements and report their spread [#435] [windows-reps:3] [variants:base-j2,base-j4,base-all-j2,base-all-j4,unity-heavy-b4,unity-heavy-b12,noanalyze,noanalyze-unity-heavy-b4,pch] --- .github/workflows/BuildStudy.yml | 12 ++++++++---- test/tools/BuildStudy.py | 7 ++++--- test/tools/BuildStudyReport.py | 23 ++++++++++++++++------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/.github/workflows/BuildStudy.yml b/.github/workflows/BuildStudy.yml index 2cf0be50..2e1cc34f 100644 --- a/.github/workflows/BuildStudy.yml +++ b/.github/workflows/BuildStudy.yml @@ -46,7 +46,11 @@ jobs: tagged = re.search(r'\[variants:([^\]]*)\]', os.environ.get('MESSAGE', '')) # a push selects variants this way requested = [v for v in (tagged.group(1) if tagged else os.environ.get('REQUESTED', '')).replace(' ', '').split(',') if v] or all_variants # /analyze exists on MSVC only: its variants have no Linux counterpart. - include = [{'os': o, 'variant': v} for v in requested for o in ('windows', 'linux') if not (o == 'linux' and v.startswith('noanalyze'))] + reps = re.search(r'\[windows-reps:(\d+)\]', os.environ.get('MESSAGE', '')) + # Hosted Windows runners vary a lot from one job to the next: repeat there, Linux is stable. + count = {'windows': int(reps.group(1)) if reps else 1, 'linux': 1} + include = [{'os': o, 'variant': v, 'rep': r} for v in requested for o in ('windows', 'linux') for r in range(1, count[o] + 1) + if not (o == 'linux' and v.startswith('noanalyze'))] print('matrix=' + json.dumps({'include': include})) PY @@ -60,7 +64,7 @@ jobs: strategy: fail-fast: false matrix: ${{ fromJSON(needs.image.outputs.matrix) }} - name: ${{ matrix.os }} ${{ matrix.variant }} + name: ${{ matrix.os }} ${{ matrix.variant }} #${{ matrix.rep }} runs-on: ${{ matrix.os == 'windows' && 'windows-2025' || 'ubuntu-26.04' }} container: ${{ matrix.os == 'linux' && fromJSON(format('{{"image":"{0}","credentials":{{"username":"{1}","password":"{2}"}},"options":"--shm-size=1g"}}', needs.image.outputs.image, github.actor, github.token)) || '' }} timeout-minutes: 240 @@ -122,12 +126,12 @@ jobs: fi # shellcheck disable=SC2086 python3 test/tools/BuildStudy.py --name "${{ matrix.os }}-${{ matrix.variant }}" --build-dir study/build \ - --jobs "$jobs" --target "$target" --config "$config" --output "study/${{ matrix.os }}-${{ matrix.variant }}.json" \ + --jobs "$jobs" --target "$target" --config "$config" --rep ${{ matrix.rep }} --output "study/${{ matrix.os }}-${{ matrix.variant }}-r${{ matrix.rep }}.json" \ -- $platform $extra - uses: actions/upload-artifact@v4 if: always() with: - name: study-${{ matrix.os }}-${{ matrix.variant }} + name: study-${{ matrix.os }}-${{ matrix.variant }}-r${{ matrix.rep }} path: study/*.json if-no-files-found: ignore diff --git a/test/tools/BuildStudy.py b/test/tools/BuildStudy.py index 40cb53a4..a0194bf3 100644 --- a/test/tools/BuildStudy.py +++ b/test/tools/BuildStudy.py @@ -60,13 +60,14 @@ def main(): parser.add_argument('--target', default='tests') parser.add_argument('--config', default='Release') parser.add_argument('--output', type=Path, required=True) + parser.add_argument('--rep', type=int, default=1) parser.add_argument('--scenarios', default=','.join(name for name, _ in SCENARIOS)) parser.add_argument('cmake_args', nargs=argparse.REMAINDER) args = parser.parse_args() cmake_args = args.cmake_args[1:] if args.cmake_args[:1] == ['--'] else args.cmake_args build = args.build_dir.resolve() wanted = args.scenarios.split(',') - results = {'name': args.name, 'jobs': args.jobs, 'target': args.target, 'config': args.config, + results = {'name': args.name, 'rep': args.rep, 'jobs': args.jobs, 'target': args.target, 'config': args.config, 'cmake_args': cmake_args, 'platform': sys.platform, 'scenarios': {}} def write(): @@ -77,7 +78,7 @@ def write(): configure = measure_command(['cmake', '-S', str(ROOT), '-B', str(build), '-G', 'Ninja', f'-DCMAKE_BUILD_TYPE={args.config}', '-DENABLE_TESTING=ON', '-DWEBFRONT_EMBED_CEF=OFF', '-DENABLE_CACHE=OFF', '-DCMAKE_CXX_COMPILER_LAUNCHER=sccache', '-DCMAKE_CXX_SCAN_FOR_MODULES=OFF'] + cmake_args, - build.parent / (args.name + '-configure.json')) + build.parent / (args.name + f'-r{args.rep}-configure.json')) results['configure_seconds'] = configure['wall_seconds'] if configure['exit_code']: results['error'] = 'configure failed' @@ -98,7 +99,7 @@ def write(): subprocess.run(['sccache', '--zero-stats'], capture_output=True, check=True) command = ['cmake', '--build', str(build), '--config', args.config, '--target', args.target, '--parallel', str(args.jobs), '--clean-first'] - report = measure_command(command, build.parent / (args.name + '-' + name + '.json')) + report = measure_command(command, build.parent / (args.name + f'-r{args.rep}-' + name + '.json')) counts = sccache_counts() units = sorted(ninja_units(build), key=lambda unit: -unit[1]) report.update({'sccache': counts, 'units': len(units), diff --git a/test/tools/BuildStudyReport.py b/test/tools/BuildStudyReport.py index b4e36ff9..dab0e340 100644 --- a/test/tools/BuildStudyReport.py +++ b/test/tools/BuildStudyReport.py @@ -1,5 +1,6 @@ """Tabulate the reports of BuildStudy.py as Markdown (stdlib only).""" import json +import statistics from pathlib import Path import sys @@ -8,7 +9,12 @@ def main(directory): reports = [json.loads(path.read_text()) for path in sorted(Path(directory).rglob('*-*.json'))] - reports = [report for report in reports if 'scenarios' in report] + # A name may be reported by several runs (repetitions) and by the per-step JSON: keep the last full report of each. + runs = {} + for report in reports: + if 'scenarios' in report: + runs.setdefault(report['name'], {})[report.get('rep', 1)] = report + reports = [{'reps': list(by_rep.values()), **next(iter(by_rep.values()))} for by_rep in runs.values()] for system in sorted({report['name'].split('-')[0] for report in reports}): mine = [report for report in reports if report['name'].startswith(system + '-')] print(f'\n### {system}: wall seconds per scenario (clean build of the target)\n') @@ -17,21 +23,24 @@ def main(directory): for report in mine: cells = [] for name in ORDER: - scenario = report['scenarios'].get(name) - if not scenario: + scenarios = [rep['scenarios'][name] for rep in report['reps'] if name in rep['scenarios']] + if not scenarios: cells.append('-') continue - text = f"{scenario['wall_seconds']:.0f}" + ('' if not scenario['exit_code'] else ' FAIL') - counts = scenario.get('sccache') or {} + walls = sorted(scenario['wall_seconds'] for scenario in scenarios) + text = f"{statistics.median(walls):.0f}" + (' FAIL' if any(scenario['exit_code'] for scenario in scenarios) else '') + if len(walls) > 1: + text += f" [{walls[0]:.0f}-{walls[-1]:.0f}]" + counts = scenarios[0].get('sccache') or {} if counts.get('Compile requests') is not None: text += f" ({counts['Cache hits']}/{counts['Compile requests']})" cells.append(text) cold = report['scenarios'].get('cold', {}) rss = cold.get('sampled_peak_family_rss_bytes', 0) / 1e6 variant = report['name'].split('-', 1)[1] - print(f"| {variant} | {report['target']} | {report['jobs']} | {report.get('configure_seconds', 0):.0f} | " + print(f"| {variant}{' x' + str(len(report['reps'])) if len(report['reps']) > 1 else ''} | {report['target']} | {report['jobs']} | {report.get('configure_seconds', 0):.0f} | " + ' | '.join(cells) + f' | {rss:.0f} |') - print('\nCells are wall seconds, then (sccache hits/requests). Cold: empty cache; warm: complete cache; ' + print('\nCells are the median wall seconds over the repetitions, [min-max] when repeated, then (sccache hits/requests of the first). Cold: empty cache; warm: complete cache; ' 'header/heavy-test/light-test: complete cache, one file changed.\n') for report in mine: cold = report['scenarios'].get('cold') From 3f502c06e5ac9447d9ea695961f1011ece336b15 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 02:45:50 +0100 Subject: [PATCH 16/33] Change a declaration, not a comment, in the study scenarios; repeat Linux on request [#435] [windows-reps:0] [linux-reps:2] [variants:base-j4,unity-heavy-b4,unity-heavy-b6,unity-heavy-b12,pch] --- .github/workflows/BuildStudy.yml | 3 ++- test/tools/BuildStudy.py | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/BuildStudy.yml b/.github/workflows/BuildStudy.yml index 2e1cc34f..3ffe9e42 100644 --- a/.github/workflows/BuildStudy.yml +++ b/.github/workflows/BuildStudy.yml @@ -48,7 +48,8 @@ jobs: # /analyze exists on MSVC only: its variants have no Linux counterpart. reps = re.search(r'\[windows-reps:(\d+)\]', os.environ.get('MESSAGE', '')) # Hosted Windows runners vary a lot from one job to the next: repeat there, Linux is stable. - count = {'windows': int(reps.group(1)) if reps else 1, 'linux': 1} + linux = re.search(r'\[linux-reps:(\d+)\]', os.environ.get('MESSAGE', '')) + count = {'windows': int(reps.group(1)) if reps else 1, 'linux': int(linux.group(1)) if linux else 1} include = [{'os': o, 'variant': v, 'rep': r} for v in requested for o in ('windows', 'linux') for r in range(1, count[o] + 1) if not (o == 'linux' and v.startswith('noanalyze'))] print('matrix=' + json.dumps({'include': include})) diff --git a/test/tools/BuildStudy.py b/test/tools/BuildStudy.py index a0194bf3..fc55dc38 100644 --- a/test/tools/BuildStudy.py +++ b/test/tools/BuildStudy.py @@ -94,7 +94,13 @@ def write(): if changed: path = ROOT / changed original = path.read_bytes() - path.write_bytes(original + b'\n// build study ' + name.encode() + b'\n') + # A comment vanishes in preprocessing, and a preprocessor-keyed cache (GCC) would still hit: add a declaration. + identifier = 'build_study_' + name.replace('-', '_') + if path.suffix == '.hpp': + addition = f'\nnamespace webfront {{ inline constexpr int {identifier} = 0; }}\n' + else: + addition = f'\nnamespace {{ [[maybe_unused]] constexpr int {identifier} = 0; }}\n' + path.write_bytes(original + addition.encode()) try: subprocess.run(['sccache', '--zero-stats'], capture_output=True, check=True) command = ['cmake', '--build', str(build), '--config', args.config, '--target', args.target, From d349f2c3380a875ab0a9be33c6def66fe4724e2d Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 07:30:41 +0100 Subject: [PATCH 17/33] Compile the heavy unit tests in groups of four on the desktop jobs and report the study [#435] --- .github/workflows/BuildAndTest.yml | 2 + docs/BUILD_TIME_STUDY.md | 173 +++++++++++++++++++++++++++++ docs/CHANGELOG.md | 8 ++ docs/TEST_PERFORMANCE.md | 3 + test/unit/CMakeLists.txt | 11 +- 5 files changed, 192 insertions(+), 5 deletions(-) create mode 100644 docs/BUILD_TIME_STUDY.md diff --git a/.github/workflows/BuildAndTest.yml b/.github/workflows/BuildAndTest.yml index 24eedf41..2c657fd2 100644 --- a/.github/workflows/BuildAndTest.yml +++ b/.github/workflows/BuildAndTest.yml @@ -120,12 +120,14 @@ jobs: command -v sccache sccache --version # ENABLE_CACHE controls automatic ccache discovery; the explicit sccache launcher stays enabled. + # The heavy unit tests are compiled four to a file (docs/BUILD_TIME_STUDY.md); the portability and sanitizer jobs keep one object per test file. - name: Configure run: >- cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DWEBFRONT_EMBED_CEF=OFF -DENABLE_TESTING=ON -DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_SCAN_FOR_MODULES=OFF + -DWEBFRONT_TEST_UNITY_BATCH=4 -DWEBFRONT_TEST_UNITY_HEAVY=ON ${{ matrix.options }} - name: Build run: python3 test/tools/MeasureCommand.py --output build/build-resources.json -- cmake --build build --config ${{ matrix.build_type }} --parallel 4 diff --git a/docs/BUILD_TIME_STUDY.md b/docs/BUILD_TIME_STUDY.md new file mode 100644 index 00000000..958aff73 --- /dev/null +++ b/docs/BUILD_TIME_STUDY.md @@ -0,0 +1,173 @@ +# Pull-request CI time: measurements and decisions (#435) + +This report answers #435. Every number comes from a GitHub-hosted runner, measured by the `Build time study` workflow +(`.github/workflows/BuildStudy.yml`, driven by `test/tools/BuildStudy.py`, tabulated by `test/tools/BuildStudyReport.py`) +or read from the artifacts of `BuildAndTest.yml`. The workflow is a measuring instrument: it gates nothing. + +## Method + +Each study job configures `tests` the way CI does (Windows: Release, MSVC, WebView2; Linux: Debug, GCC 16, coverage, +WebKitGTK; both with `-DENABLE_TESTING=ON`), with a local-disk sccache, then times clean builds of one target: + +| Scenario | Compiler cache | What it models | +|---|---|---| +| `cold` | empty | first build of a branch, or a cache that expired | +| `warm` | complete | a rerun with no source change | +| `header` | complete, but `include/webfront/WebFront.hpp` changed | a pull request that touches the core header (#400, #401, #428) | +| `heavy-test` | complete, but `WebFrontTests.cpp` changed | a pull request that edits one heavy test | +| `light-test` | complete, but `MimeTypeTests.cpp` changed | a pull request that edits one light test | + +A cell is wall seconds. Linux cells are stable (two runs of the same variant: 170 and 172 s cold). **Hosted Windows runners are +not**: the same `base-j4` configuration took 725 s and 466 s cold in two runs. Windows variants are therefore repeated three +times and reported as a median with its range; a Windows difference smaller than that range is not a result. + +## Where the compile time goes + +Heavy units are the ones that instantiate a full application (`BasicWF` on stdnet with a frontend). Even the smallest one, +`HelloWorld.cpp`, costs 61 s on MSVC. + +| Compiler | Unit | Total | Parse of headers | Template instantiation | Optimise and generate | +|---|---|---|---|---|---| +| GCC 16, Debug + coverage | `HelloWorld.cpp` | 11.2 s | 21 % | 23 % | 49 % | +| GCC 16, Debug + coverage | `WebFrontTests.cpp` | 22.1 s | 12 % | 22 % | 56 % | +| Apple Clang, Release | `HelloWorld.cpp` | 21.6 s | frontend 11.9 s (sources 5.5 s) | `BasicWF` 8.5 s inclusive | backend 9.6 s | +| Apple Clang, Release | `WebFrontTests.cpp` | 53.2 s | frontend 19.7 s | mock `BasicWF` instantiations 6 to 9 s each | backend 33.1 s | +| MSVC, Release | `HelloWorld.cpp` | 61 s | `WebFront.hpp` alone 8.2 s | | | + +On MSVC the `/d1reportTime` report is printed twice, once per front-end pass; the `/analyze` section below measures what that costs. + +Across the translation units of `tests` (Clang `-ftime-trace`, 1,786 s of compile), identical `webfront::` and `stdexec::` +function instantiations that appear in more than one unit account for at most 165 s (9 %, an upper bound: nested +instantiations are counted at each level). That bounds what any sharing of instantiations could save. + +## Results + +### Parallelism: `--parallel 2` or `--parallel 4` + +Cold wall seconds. Windows: median and [range] of three runs; Linux: every run (a hosted Linux runner also varies, by up to +1.5x for `all`). + +| Target | Linux `-j2` | Linux `-j4` | Windows `-j2` | Windows `-j4` | +|---|---|---|---|---| +| `tests` | 285, 275 | 170, 172, 138, 181, 224 | 822 [757-828] | 640 [537-725] | +| `all` (what CI builds) | 515, 522 | 255, 376 | 1240 [1213-1253] | 1076 [786-1086] | + +`-j4` shortens every build: about 40 % on Linux, 13 to 22 % on Windows, where the runner spread is as wide as the gain. The +peak resident set of the whole process family stays under 1 GB (996 MB for `all` on Windows), well inside the 16 GB of a +hosted runner. Adopted (`BuildAndTest.yml`, desktop jobs). + +### Grouping the heavy units of `tests` + +`WEBFRONT_TEST_UNITY_BATCH=N` with `WEBFRONT_TEST_UNITY_HEAVY=ON` compiles the 12 heavy units of `tests` N to a file and +leaves the 140 light units alone. The `header`, `heavy-test` and `light-test` columns are the cost of a pull request that +changes `WebFront.hpp`, `WebFrontTests.cpp` or `MimeTypeTests.cpp` with a complete cache. + +Windows (median [range] of three runs, `-j4`): + +| Variant | cold | warm | header | heavy-test | light-test | peak RSS MB | +|---|---|---|---|---|---|---| +| no grouping | 640 [537-725] | 32 | 298 [252-339] | 102 [87-115] | 33 | 858 | +| groups of 4 | **355 [334-576]** | 18 | **111 [104-182]** | **74 [69-118]** | 19 | 569 | +| groups of 12 | 501 [297-511] | 29 | 166 [111-166] | 163 [113-169] | 30 | **460** | + +Linux (two runs, `-j4`): + +| Variant | cold | warm | header | heavy-test | light-test | peak RSS MB | +|---|---|---|---|---|---|---| +| no grouping | 202 [181-224] | 6 | 88 [80-95] | 43 [41-44] | 7 | 704 | +| groups of 4 | **143 [102-185]** | 4 | **45 [35-54]** | **40 [32-48]** | 6 | 553 | +| groups of 6 | 172 [169-174] | 5 | 57 [57-58] | 56 [56-57] | 6 | 518 | +| groups of 12 | 166 [162-171] | 5 | 76 [75-78] | 77 [74-80] | 6 | 506 | + +Groups of 4 win on both compilers in every scenario: the unit of work stays small enough to spread over four jobs, and a +change to one heavy test recompiles at most three others. Groups of 12 put every heavy test behind one compilation, which is +slowest when one of them changes. Grouping every unit instead of the heavy ones does not compile (`GzipExecutorTests.cpp`, +`DeveloperTests.cpp` and others define the same names); the heavy units needed four qualifications (`detail::` made +ambiguous by `using namespace webfront`, a local alias that shadowed a file-scope one, and a header without +`#pragma once`) and the whole suite passes. Adopted for the desktop CI jobs only (`BuildAndTest.yml`): the default build +keeps one object per test file, and the portability and sanitizer jobs still compile each file alone, which would expose +a clash that grouping hides. + +### Precompiled headers + +`WEBFRONT_TEST_PCH=ON` precompiles Catch2 and `WebFront.hpp` for the heavy units. + +| | Windows cold | Windows warm | Windows header | Linux cold | Linux header | +|---|---|---|---|---|---| +| no grouping, no PCH | 640 | 32 | 298 | 202 | 88 | +| PCH | 592 [591-601] | **231** | 227 | 215 | 96 | + +sccache cannot cache an MSVC compilation that uses a precompiled header, so every PCH unit is recompiled even with a complete +cache (warm 231 s instead of 32 s) and the build uses 1.7 GB. On GCC it is slower than no PCH. **Not adopted.** + +### MSVC `/analyze` + +`cmake/CompilerWarnings.cmake` compiles every unit with `/analyze`. `-DWEBFRONT_MSVC_ANALYZE=OFF` (the default is ON) measures +its cost on `tests` with `-j4`: + +| | cold | header | heavy-test | +|---|---|---|---| +| `/analyze` (CI) | 640 [537-725] | 298 [252-339] | 102 [87-115] | +| without | 497 [474-517] | 230 [225-231] | 80 [80-82] | +| groups of 4, without | 263 [259-420] | 82 [80-133] | 49 [48-83] | + +The analysis costs about 22 % of a Windows build. It is a quality gate (warnings are errors), so removing it from the +desktop job is a decision for the maintainers, not a build-time tweak. One way to keep the gate and the speed is to run it +in the portability job on pull requests into `master` only. **Not adopted; the option remains for measuring.** + +### What the pull request gains + +Test suite wall time on the pull request's own CI against run 41134609687 (same jobs, the compiler cache warm in both): + +| | Linux | Windows | +|---|---|---| +| Suite wall time | 256 s -> 174 s | 272 s -> 106 s | +| Worker time (sum of cases) | 869 s -> 576 s | 753 s -> 405 s | +| Dependency chain | 161 s -> 169 s | 143 s -> 62 s | + +The Linux gain is the 180 s of `ConsumerJasmine-*` that was waiting for nothing. The Windows chain shortened because +`LifeEmbeddedBuild` no longer waits behind the port lock and, this time, hit the compiler cache; part of the Windows gain is +therefore a faster runner and warm caches, and only the Linux figure is a clean before/after. + + +## Run time + +The suite takes 256 s on Linux and 271 s on Windows (run 41134609687). Measured from `ctest-graph.json` and the JUnit timings: + +- **The dependency chain** is `SelfBuildSession` -> `DeveloperFixtures` -> `DeveloperBrowserIntegration` -> `LifeEmbeddedBuild` + -> `LifeEmbeddedIntegration` (161 s on Linux, 143 s on Windows). `DeveloperFixtures` assembles the environment that + `SelfBuildSession` builds from the current sources and `DeveloperBrowserIntegration` runs it: the order is the point of + the tests, so the fixtures cannot be shared to shorten it. `DeveloperBrowserIntegration` alone is 59 to 113 s; most of + it is one test process (`terminal and sessions` 32 s, `Life preview and bridge` 21 s, `Jasmine runs` 17 s on Linux), so + splitting it into independent CTest cases is the only way to shorten the chain further. +- **The port lock** `webfront_port_9002` serialised 175 s (Linux) and 203 s (Windows) of tests, which is why the suite did + not scale with the number of workers. 22 and 23 cases hold it. Two of them, `JourneyEmbeddedBuild` and + `LifeEmbeddedBuild`, only compile (48 s each on Windows, uncached) and bind no port; they still held it. They now hold + `webfront_build_tree` alone. +- **`ConsumerJasmine-*` took 30.0 s each on Linux** (six cases, 180 s of worker time) for no work: `RunWithDeadline.sh` + left a watchdog `sleep` holding the output pipe, so `execute_process` returned only when the deadline expired. Under + dash, which `/bin/sh` is on Ubuntu, `set -m` succeeds without enabling job control, so the group kill of the same script + also reached nothing. The script now returns when the command does and gives the command a process group with + `setsid`. `RunWithDeadline` is the regression test. +- **Consumer projects** (`FrontendConsumerConfiguration` 67 s, `AddSubdirectoryNativeConsumer` 64 s on Windows) configure and + build separate projects on purpose: each case proves a different option set from a clean state. They are off the + dependency path, and with the suite bounded by its lock and chain rather than by its workers, parallelising them would not + shorten the wall time. + +## What was not adopted, and why + +- **Sharing objects between executables.** `life_journey` and `life_embedded` compile the same `LifeEmbeddedTest.cpp` + against two different generated asset headers; the filesystem type is a template argument of the application, so the two + objects differ. The developer application is instantiated with a different frontend or filesystem type in + `webfront-agent`, `webfront-wf`, `developer_integration` and `DeveloperTests`. The 9 % ceiling above is what an + `extern template` scheme could reach, at the price of explicitly instantiating `stdexec` internals. +- **Merging small executables.** `jasmine_consumer`, `frontend_lifecycle` and `webview2_*` each cost 66 to 69 s on MSVC and + each instantiates its own frontend type, so a merged executable would still instantiate every type once. The CTest cases + would also lose their separate process, which is what several of them prove (exit status, hang, early close). + +## Left for later + +- Split `DeveloperBrowserIntegration` (59 to 113 s, the longest case and on the dependency chain) into independent cases. +- `/analyze` in one job instead of every MSVC compilation (about 22 % of a Windows build; a policy decision). +- The examples (`HelloWorld`, `LifeDeveloper`, `LifeReact`, 61 to 67 s each on MSVC) are built by every desktop job; building + them in one job per pull request would save about 190 s of compiler time per job. diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 9922fc2e..319cd881 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -2,6 +2,14 @@ ## Unreleased +- Cut pull-request CI time (#435): the desktop jobs build with `--parallel 4` and compile the 12 heavy unit-test files in + groups of four (`WEBFRONT_TEST_UNITY_BATCH`, `WEBFRONT_TEST_UNITY_HEAVY`; the default build keeps one object per file), + `JourneyEmbeddedBuild` and `LifeEmbeddedBuild` no longer hold the `webfront_port_9002` lock while they compile, and + `RunWithDeadline.sh` returns when its command does instead of at the deadline, which took 30 s from each of the six + `ConsumerJasmine-*` cases under dash. It also gives the command its own process group when the shell has no job + control. `WEBFRONT_MSVC_ANALYZE` (default ON) and `WEBFRONT_TEST_PCH` exist to measure `/analyze` and precompiled headers. + The `Build time study` workflow and `docs/BUILD_TIME_STUDY.md` hold the measurements and the decisions. + - 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/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index 494b5223..6329e9fa 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -172,3 +172,6 @@ compilation constraints before changing their coverage. GCC parallel coverage relies on libgcov's filesystem locking; filesystems without locking require isolated profiles and merging. macOS failures retain WebKit system/crash diagnostics and phase logs. + +Build-time measurements (compiler cache scenarios, grouping, precompiled headers, `/analyze`) and the decisions taken are in +[BUILD_TIME_STUDY.md](BUILD_TIME_STUDY.md). diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index f483ba78..307433f7 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -48,13 +48,14 @@ if(MSVC) endif() target_compile_definitions(tests PRIVATE WEBFRONT_SOURCE_DIR="${PROJECT_SOURCE_DIR}") -# Build-time study (#435), measurements only (docs/BUILD_TIME_STUDY.md): both knobs default to the regular build. +# Build-time options (#435, docs/BUILD_TIME_STUDY.md). They default to one object per test file, which keeps rebuilds +# fine-grained; the desktop CI jobs group the heavy units. # WEBFRONT_TEST_UNITY_BATCH=N groups the translation units of `tests` by N (0: no unity build); # WEBFRONT_TEST_UNITY_HEAVY=ON limits the grouping to the heavy units (those instantiating a full application); -# WEBFRONT_TEST_PCH=ON precompiles the headers every test includes. -set(WEBFRONT_TEST_UNITY_BATCH 0 CACHE STRING "Study (#435): UNITY_BUILD_BATCH_SIZE of the tests target, 0 disables it") -option(WEBFRONT_TEST_UNITY_HEAVY "Study (#435): group only the heavy translation units of the tests target" OFF) -option(WEBFRONT_TEST_PCH "Study (#435): precompiled headers for the tests target" OFF) +# WEBFRONT_TEST_PCH=ON precompiles the headers of the heavy units (measured, not adopted: sccache cannot cache it on MSVC). +set(WEBFRONT_TEST_UNITY_BATCH 0 CACHE STRING "UNITY_BUILD_BATCH_SIZE of the tests target, 0 disables it") +option(WEBFRONT_TEST_UNITY_HEAVY "Group only the heavy translation units of the tests target" OFF) +option(WEBFRONT_TEST_PCH "Precompiled headers for the heavy units of the tests target" OFF) # The heavy units instantiate a full application; the others are light and keep the regular build. set(_heavy WebFrontTests CommandsTests ApplicationTaskTests StdnetShutdownTests FrontendContractTests JsFunctionSenderTests AutomationTests ReactStoreTests DeveloperTests CEFMacrosTests JasmineConsumerTests WfDriverTests) From 6fce707515bfd8151731a7ee52a69bdaf79cd1cc Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 07:44:38 +0100 Subject: [PATCH 18/33] Add the measured pull-request run to the build-time report [#435] --- docs/BUILD_TIME_STUDY.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/docs/BUILD_TIME_STUDY.md b/docs/BUILD_TIME_STUDY.md index 958aff73..bccdee1f 100644 --- a/docs/BUILD_TIME_STUDY.md +++ b/docs/BUILD_TIME_STUDY.md @@ -58,7 +58,7 @@ hosted runner. Adopted (`BuildAndTest.yml`, desktop jobs). ### Grouping the heavy units of `tests` -`WEBFRONT_TEST_UNITY_BATCH=N` with `WEBFRONT_TEST_UNITY_HEAVY=ON` compiles the 12 heavy units of `tests` N to a file and +`WEBFRONT_TEST_UNITY_BATCH=N` with `WEBFRONT_TEST_UNITY_HEAVY=ON` compiles the 13 heavy units of `tests` N to a file and leaves the 140 light units alone. The `header`, `heavy-test` and `light-test` columns are the cost of a pull request that changes `WebFront.hpp`, `WebFrontTests.cpp` or `MimeTypeTests.cpp` with a complete cache. @@ -82,9 +82,9 @@ Linux (two runs, `-j4`): Groups of 4 win on both compilers in every scenario: the unit of work stays small enough to spread over four jobs, and a change to one heavy test recompiles at most three others. Groups of 12 put every heavy test behind one compilation, which is slowest when one of them changes. Grouping every unit instead of the heavy ones does not compile (`GzipExecutorTests.cpp`, -`DeveloperTests.cpp` and others define the same names); the heavy units needed four qualifications (`detail::` made -ambiguous by `using namespace webfront`, a local alias that shadowed a file-scope one, and a header without -`#pragma once`) and the whole suite passes. Adopted for the desktop CI jobs only (`BuildAndTest.yml`): the default build +`DeveloperTests.cpp` and others define the same names); the heavy units needed five changes (`detail::` made +ambiguous by `using namespace webfront`, a local alias that shadowed a file-scope one, two helpers of `BroadcastTests.cpp` +named like those of `StdnetShutdownTests.cpp`, and a header without `#pragma once`) and the whole suite passes. Adopted for the desktop CI jobs only (`BuildAndTest.yml`): the default build keeps one object per test file, and the portability and sanitizer jobs still compile each file alone, which would expose a clash that grouping hides. @@ -115,6 +115,21 @@ The analysis costs about 22 % of a Windows build. It is a quality gate (warnings desktop job is a decision for the maintainers, not a build-time tweak. One way to keep the gate and the speed is to run it in the portability job on pull requests into `master` only. **Not adopted; the option remains for measuring.** +### The pull request that touches a core header + +The pull request's own run after merging `develop` (which changes `WebFront.hpp`, the situation of #400, #401 and #428), with +the changes of this pull request in place (`-j4`, heavy units in groups of four), against run 41134609687 on the same kind of +change: + +| | Linux | Windows | +|---|---|---| +| Build step | 328 s -> 85 s | 876 s -> 213 s | +| Job | 12 min -> 6.8 min | about 20 min -> 7.7 min | + +A fully cached build takes 23 s (Linux) and 33 s (Windows) on this branch, so these builds did recompile the heavy units. The +runs are single samples on runners that vary; the study tables above are the evidence, this is the check that they carry +over to a real pull request. + ### What the pull request gains Test suite wall time on the pull request's own CI against run 41134609687 (same jobs, the compiler cache warm in both): From e3ee1b7f1ddb65744682c016163a4f7e36c0a085 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:42:58 +0100 Subject: [PATCH 19/33] Record why the remaining items of the build-time study are left [#435] --- docs/BUILD_TIME_STUDY.md | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/docs/BUILD_TIME_STUDY.md b/docs/BUILD_TIME_STUDY.md index bccdee1f..92353dd9 100644 --- a/docs/BUILD_TIME_STUDY.md +++ b/docs/BUILD_TIME_STUDY.md @@ -180,9 +180,31 @@ The suite takes 256 s on Linux and 271 s on Windows (run 41134609687). Measured each instantiates its own frontend type, so a merged executable would still instantiate every type once. The CTest cases would also lose their separate process, which is what several of them prove (exit status, hang, early close). -## Left for later +## What is left, and why it is not done -- Split `DeveloperBrowserIntegration` (59 to 113 s, the longest case and on the dependency chain) into independent cases. -- `/analyze` in one job instead of every MSVC compilation (about 22 % of a Windows build; a policy decision). -- The examples (`HelloWorld`, `LifeDeveloper`, `LifeReact`, 61 to 67 s each on MSVC) are built by every desktop job; building - them in one job per pull request would save about 190 s of compiler time per job. +After these changes a desktop job spends its time as follows (run 41177164644, a pull request that touches a core header): + +| Step | Linux | Windows | +|---|---|---| +| Container start / checkout and CMake | 53 s | 23 s | +| Configure | | 20 s | +| Build | 85 s | 214 s | +| Fast tests | 15 s | 17 s | +| Test suite | 195 s | 163 s | +| Coverage (Linux only) | 42 s | | + +The compiler-cache probe after the suite (a clean rebuild of `life_embedded`, `life_journey` and the consumer, run for #388) costs +1 to 2 s, so it is not worth removing. + +- **`DeveloperBrowserIntegration`** (59 to 113 s) is the longest case and ends the dependency chain (`SelfBuildSession` -> + `DeveloperBrowserIntegration` -> `LifeEmbeddedBuild`). It is one 1,061-line script (`test/web/developer-specs.mjs`) run in one + browser over one project: later sections rely on the packages, lock and files the earlier ones installed (`terminal and sessions` + 32 s, `Life preview and bridge` 21 s, `Jasmine runs` 17 s, the TypeScript installs 12 + 8 s). Splitting it into parallel CTest + cases means giving each section its own project and setup, and it also produces the generated `LifeUI.hpp` that + `LifeEmbeddedBuild` compiles. That is a rewrite of the test, to be validated on all three frontends; it is not a build-time + tweak and was left alone. +- **`/analyze`** and **the examples** (61 to 67 s each on MSVC) cost Windows compile time, but moving either to another job does + not shorten a pull request: a parallel job that compiles the same code takes as long, and the pull request waits for both. + Only dropping them from the pull-request path (`/analyze` into the `master` tier, the examples into one job) shortens it, and + that removes a check from every pull request into `develop`. The numbers are above (about 22 % of a Windows build for + `/analyze`, about 190 s of compiler time for the examples) so the maintainers can decide. From 61e79765078f4aa65c7b89bdf6fbfc6a4fd6da03 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:52:58 +0100 Subject: [PATCH 20/33] Run the MSVC analysis and compile the examples in the master and weekly tier only [#435] --- .github/workflows/BuildAndTest.yml | 4 ++++ docs/BUILD_TIME_STUDY.md | 2 +- docs/TEST_TIERS.md | 12 ++++++++++-- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/BuildAndTest.yml b/.github/workflows/BuildAndTest.yml index 2c657fd2..68ca066c 100644 --- a/.github/workflows/BuildAndTest.yml +++ b/.github/workflows/BuildAndTest.yml @@ -25,6 +25,9 @@ concurrency: env: CPM_SOURCE_CACHE: ${{ github.workspace }}/.cache/CPM SCCACHE_GHA_ENABLED: 'true' + # The full tier of the desktop jobs (weekly, pull requests into and pushes to master, manual dispatch with repeat_desktop_tests) + # also runs the MSVC code analysis and compiles the examples; a pull request into develop does neither (#435, docs/BUILD_TIME_STUDY.md). + FULL_TIER: ${{ (github.event_name == 'schedule' || (github.event_name == 'pull_request' && github.base_ref == 'master') || (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'workflow_dispatch' && inputs.repeat_desktop_tests)) && 'true' || 'false' }} # Third-party actions are pinned to commit SHAs; GitHub-owned actions/* use version tags. jobs: @@ -128,6 +131,7 @@ jobs: -DENABLE_CACHE=OFF -DCMAKE_CXX_COMPILER_LAUNCHER=sccache -DCMAKE_CXX_SCAN_FOR_MODULES=OFF -DWEBFRONT_TEST_UNITY_BATCH=4 -DWEBFRONT_TEST_UNITY_HEAVY=ON + ${{ env.FULL_TIER == 'true' && '' || '-DWEBFRONT_MSVC_ANALYZE=OFF -DWEBFRONT_BUILD_EXAMPLES=OFF' }} ${{ matrix.options }} - name: Build run: python3 test/tools/MeasureCommand.py --output build/build-resources.json -- cmake --build build --config ${{ matrix.build_type }} --parallel 4 diff --git a/docs/BUILD_TIME_STUDY.md b/docs/BUILD_TIME_STUDY.md index 92353dd9..150e57b4 100644 --- a/docs/BUILD_TIME_STUDY.md +++ b/docs/BUILD_TIME_STUDY.md @@ -113,7 +113,7 @@ its cost on `tests` with `-j4`: The analysis costs about 22 % of a Windows build. It is a quality gate (warnings are errors), so removing it from the desktop job is a decision for the maintainers, not a build-time tweak. One way to keep the gate and the speed is to run it -in the portability job on pull requests into `master` only. **Not adopted; the option remains for measuring.** +in the portability job on pull requests into `master` only. **Moved to the master tier** (see "What is left"); the option stays for measuring. ### The pull request that touches a core header diff --git a/docs/TEST_TIERS.md b/docs/TEST_TIERS.md index c22ec6a8..030a6ea6 100644 --- a/docs/TEST_TIERS.md +++ b/docs/TEST_TIERS.md @@ -38,13 +38,21 @@ spec expected the refusal. A wait is labelled `timeout (expected)` only for a ti and `cancelled (expected)` only when the spec pressed Ctrl+C; any other time limit or cancellation appears as `timeout` or `cancelled`. This trace comes from the specs (`test/web/developer-specs.mjs`), not from the published environment. +## What the desktop jobs compile + +A pull request into `develop` builds the library, the tests and the test applications, with the MSVC code analysis (`/analyze`) +off and without the examples (`WEBFRONT_MSVC_ANALYZE=OFF`, `WEBFRONT_BUILD_EXAMPLES=OFF`): about 22 % and 190 s of compiler +time on Windows (docs/BUILD_TIME_STUDY.md). The advanced checks below turn both on again, so a warning that only the analysis +reports, or an example that no longer compiles, is found by the weekly run, by the pull request into `master` or by a manual +dispatch with `repeat_desktop_tests`, not by a pull request into `develop`. A local build has both by default. + ## Advanced checks These run on the weekly schedule (Monday 04:23 UTC), on every pull request whose base is `master`, and on a manual dispatch with `repeat_desktop_tests`: -- the complete desktop suite on the three desktop platforms, repeated three times with its fixtures reset on each pass, - including the portability tests; +- the complete desktop suite on the three desktop platforms, built with the MSVC code analysis and the examples, repeated + three times with its fixtures reset on each pass, including the portability tests; - the `portability` job: the consumer project configured with Ninja (GCC on Linux, MSVC on Windows, Apple clang on macOS), with Unix Makefiles (Clang 23) and, reported but never blocking until it has run on a hosted runner, the Visual Studio 2026 generator. There is no compiler cache: a new user compiles everything; From 4a3efcce5a20340221e62d2f37dee2a3ab5234b1 Mon Sep 17 00:00:00 2001 From: Ambroise Leclerc <6860842+ambroise-leclerc@users.noreply.github.com> Date: Sat, 31 Oct 2026 08:59:17 +0100 Subject: [PATCH 21/33] Cut DeveloperBrowserIntegration into five parts that run in parallel [#435] --- docs/BUILD_TIME_STUDY.md | 28 +- docs/CHANGELOG.md | 5 +- docs/DEVELOPER_ENVIRONMENT.md | 2 +- docs/TEST_PERFORMANCE.md | 2 +- docs/TEST_TIERS.md | 9 +- test/web/CMakeLists.txt | 20 +- test/web/DeveloperTest.cpp | 56 +- test/web/developer-specs.mjs | 1819 +++++++++++++++++---------------- 8 files changed, 1015 insertions(+), 926 deletions(-) diff --git a/docs/BUILD_TIME_STUDY.md b/docs/BUILD_TIME_STUDY.md index 150e57b4..2ca11490 100644 --- a/docs/BUILD_TIME_STUDY.md +++ b/docs/BUILD_TIME_STUDY.md @@ -180,9 +180,9 @@ The suite takes 256 s on Linux and 271 s on Windows (run 41134609687). Measured each instantiates its own frontend type, so a merged executable would still instantiate every type once. The CTest cases would also lose their separate process, which is what several of them prove (exit status, hang, early close). -## What is left, and why it is not done +## What was left after the first pass, and what was done about it -After these changes a desktop job spends its time as follows (run 41177164644, a pull request that touches a core header): +After the changes above a desktop job spends its time as follows (run 41177164644, a pull request that touches a core header): | Step | Linux | Windows | |---|---|---| @@ -196,15 +196,15 @@ After these changes a desktop job spends its time as follows (run 41177164644, a The compiler-cache probe after the suite (a clean rebuild of `life_embedded`, `life_journey` and the consumer, run for #388) costs 1 to 2 s, so it is not worth removing. -- **`DeveloperBrowserIntegration`** (59 to 113 s) is the longest case and ends the dependency chain (`SelfBuildSession` -> - `DeveloperBrowserIntegration` -> `LifeEmbeddedBuild`). It is one 1,061-line script (`test/web/developer-specs.mjs`) run in one - browser over one project: later sections rely on the packages, lock and files the earlier ones installed (`terminal and sessions` - 32 s, `Life preview and bridge` 21 s, `Jasmine runs` 17 s, the TypeScript installs 12 + 8 s). Splitting it into parallel CTest - cases means giving each section its own project and setup, and it also produces the generated `LifeUI.hpp` that - `LifeEmbeddedBuild` compiles. That is a rewrite of the test, to be validated on all three frontends; it is not a build-time - tweak and was left alone. -- **`/analyze`** and **the examples** (61 to 67 s each on MSVC) cost Windows compile time, but moving either to another job does - not shorten a pull request: a parallel job that compiles the same code takes as long, and the pull request waits for both. - Only dropping them from the pull-request path (`/analyze` into the `master` tier, the examples into one job) shortens it, and - that removes a check from every pull request into `develop`. The numbers are above (about 22 % of a Windows build for - `/analyze`, about 190 s of compiler time for the examples) so the maintainers can decide. +- **`/analyze` and the examples** (about 22 % of a Windows build, and 61 to 67 s each on MSVC) moved to the master tier. Putting + them in a parallel job would not have shortened a pull request, which waits for both, so a pull request into `develop` no longer + builds either; the weekly run, a pull request into `master`, a push to `master` and a manual dispatch with + `repeat_desktop_tests` do (`FULL_TIER` in `BuildAndTest.yml`, `docs/TEST_TIERS.md`). +- **`DeveloperBrowserIntegration`** (59 to 113 s, the longest case, at the end of the chain `SelfBuildSession` -> + `DeveloperBrowserIntegration` -> `LifeEmbeddedBuild`) was one 1,061-line script in one browser over one project. It is now + five parts, selected by `developer_integration --part=`: `app` (starter, build, `wf dev`, Life preview, embedding, and + the `LifeUI.hpp` that `LifeEmbeddedBuild` compiles), `scripts` (package commands, `wf run`, `wf exec`), `typescript` + (`wf check`), `jasmine` (`wf test`) and `terminal` (the terminal, sessions and history). Each part creates and initialises its + own project, installs what it needs and listens on a port the system picks, so none holds `webfront_port_9002`; with no + `--part` the executable plays them all in one session as before. Locally on macOS (WKWebView) the four cases other than `app` + take 3 to 6 s each once the environment is built. diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 5d06c97b..8d9fbc02 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -8,7 +8,10 @@ `RunWithDeadline.sh` returns when its command does instead of at the deadline, which took 30 s from each of the six `ConsumerJasmine-*` cases under dash. It also gives the command its own process group when the shell has no job control. `WEBFRONT_MSVC_ANALYZE` (default ON) and `WEBFRONT_TEST_PCH` exist to measure `/analyze` and precompiled headers. - The `Build time study` workflow and `docs/BUILD_TIME_STUDY.md` hold the measurements and the decisions. + The `Build time study` workflow and `docs/BUILD_TIME_STUDY.md` hold the measurements and the decisions. The + MSVC code analysis and the examples are built by the master and weekly tier only, and `DeveloperBrowserIntegration` + is cut into five parts (`DeveloperBrowserIntegration`, `-scripts`, `-typescript`, `-jasmine`, `-terminal`) that + run in parallel from their own projects on ephemeral ports. - Reject a stale `UI` after its connection identifier is reused (#428): each connection gets a 64-bit generation, never reused, kept in the application next to its link. `UI`, `JsFunction` and diff --git a/docs/DEVELOPER_ENVIRONMENT.md b/docs/DEVELOPER_ENVIRONMENT.md index 89718ee6..bd26b085 100644 --- a/docs/DEVELOPER_ENVIRONMENT.md +++ b/docs/DEVELOPER_ENVIRONMENT.md @@ -678,7 +678,7 @@ WKWebView and all 14 Linux CEF/Xvfb cases with both GCC and Clang in The packed 0.3.0 version passes WKWebView and all 14 GCC CEF/Xvfb cases in [run 39490581423](https://github.com/ambroise-leclerc/WebFront/actions/runs/39490581423). For Linux, select CEF and Xvfb instead; the same developer tests use the selected test frontend. -`DeveloperBrowserIntegration` exercises the real WASM compiler, local registry, `wf test` under the locked jasmine-core (pass, fail, pending, asynchronous failures, pattern, time limit, Ctrl+C, non-interactive report to C++), build without navigation, incremental dev reload/error/recovery/Ctrl+C, the Life preview, C++ generation/animation and repeatable header generation. Its CTest fixtures then build that +`DeveloperBrowserIntegration` (the application part: starter, build, `wf dev`, Life preview, embedding) and `DeveloperBrowserIntegration-scripts`, `-typescript`, `-jasmine` and `-terminal` exercise, in parallel and each from its own project, the real WASM compiler, local registry, `wf test` under the locked jasmine-core (pass, fail, pending, asynchronous failures, pattern, time limit, Ctrl+C, non-interactive report to C++), build without navigation, incremental dev reload/error/recovery/Ctrl+C, the Life preview, C++ generation/animation and repeatable header generation. Its CTest fixtures then build that **browser-generated** header and run `LifeEmbeddedIntegration` from an empty working directory with no developer callbacks. Deadline and grace-period regressions advance a scoped clock instead of sleeping for seconds; Worker startup, diff --git a/docs/TEST_PERFORMANCE.md b/docs/TEST_PERFORMANCE.md index 6329e9fa..de57d04b 100644 --- a/docs/TEST_PERFORMANCE.md +++ b/docs/TEST_PERFORMANCE.md @@ -120,7 +120,7 @@ sampled bounds, not precise unique-memory or process-creation counts. Pre-existi sccache server and its compiler children can fall outside this process family; sccache's own statistics complement the sampled build report. It preserves the measured command's failure status. -`DeveloperBrowserIntegration` emits begin/end timestamps for each major phase and every actual command, including +`DeveloperBrowserIntegration` and its four sibling parts emit begin/end timestamps for each major phase and every actual command, including expected failures. `DeveloperSpecs` reports both ends of each spec. The driver reports browser opening/return and shutdown, and every suite case, so process-exit costs remain distinguishable. `LastTest-.log` keeps the full transcript of each pass; the suite runner raises the CTest output cap to 2 MiB per case so JUnit retains these details too. The analyzer ranks the emitted diff --git a/docs/TEST_TIERS.md b/docs/TEST_TIERS.md index 030a6ea6..61f47d39 100644 --- a/docs/TEST_TIERS.md +++ b/docs/TEST_TIERS.md @@ -21,7 +21,8 @@ cmake -DBUILD_DIR=build -DLABEL_EXCLUDE=portability -P test/cmake/RunTestSuite.c ## Following a browser test live -`DeveloperBrowserIntegration`, the `Automation*` cases and the `WfDriver*` cases run `wf` commands (`create`, `install`, +`DeveloperBrowserIntegration` and its siblings `DeveloperBrowserIntegration-scripts`, `-typescript`, `-jasmine` and `-terminal` +(the parts of `test/web/developer-specs.mjs`, which run in parallel on a port the system picks), the `Automation*` cases and the `WfDriver*` cases run `wf` commands (`create`, `install`, `build`, `dev`, `preview`, `embed`, ...) that can take several seconds each. CTest hides the output of a passing test, so to watch one: @@ -30,6 +31,12 @@ ctest --test-dir build -R DeveloperBrowserIntegration -V # CTest prints t ctest --test-dir build -R DeveloperBrowserIntegration -N -V # prints the command to run `developer_integration` directly ``` +Run `developer_integration` with a fixtures directory and an output directory but no `--part=` to play every part in one +session, as the test did before it was cut; `--part=app|scripts|typescript|jasmine|terminal` plays one. + +```bash +``` + The process prints a `Developer integration: