diff --git a/.github/actions/wf-driver/action.yml b/.github/actions/wf-driver/action.yml index d39fe7ec..7043be1e 100644 --- a/.github/actions/wf-driver/action.yml +++ b/.github/actions/wf-driver/action.yml @@ -37,7 +37,7 @@ runs: shell: bash run: | 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 \ + -DWEBFRONT_EMBED_WEBKITGTK=ON -DWEBFRONT_WEBTEST_FRONTEND=WebKitGTK -DWEBFRONT_TEST_REPRODUCIBILITY=ON \ -DCMAKE_CXX_SCAN_FOR_MODULES=OFF cmake --build build-driver --target webfront-wf --parallel 2 - name: Install the wf command diff --git a/.github/workflows/BuildAndTest.yml b/.github/workflows/BuildAndTest.yml index fbcae7eb..47d46a0f 100644 --- a/.github/workflows/BuildAndTest.yml +++ b/.github/workflows/BuildAndTest.yml @@ -145,6 +145,7 @@ jobs: 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. + # No job relies on a default of the test options: the defaults are those of a quick local build (docs/TEST_TIERS.md). # The unit tests run as four Catch2 shards instead of one process per scenario (docs/TEST_TIERS.md). - name: Configure run: >- @@ -155,7 +156,7 @@ jobs: -DWEBFRONT_TEST_UNITY_BATCH=4 -DWEBFRONT_TEST_UNIT_SHARDS=4 -DWEBFRONT_TEST_REPRODUCIBILITY=${{ env.WEBFRONT_REPRODUCIBILITY }} - ${{ env.FULL_TIER == 'true' && '' || '-DWEBFRONT_MSVC_ANALYZE=OFF -DWEBFRONT_BUILD_EXAMPLES=OFF' }} + ${{ env.FULL_TIER == 'true' && '-DWEBFRONT_MSVC_ANALYZE=ON -DWEBFRONT_BUILD_EXAMPLES=ON' || '-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 @@ -370,7 +371,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 -DWEBFRONT_ENABLE_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 -DWEBFRONT_TEST_UNITY_BATCH=0 -DWEBFRONT_MSVC_ANALYZE=ON -DWEBFRONT_TEST_REPRODUCIBILITY=ON - name: Portability tests shell: bash run: ctest --test-dir build -C Release -L portability --output-on-failure --no-tests=error @@ -489,6 +490,7 @@ jobs: cmake -S . -B build-sanitizers -DCMAKE_BUILD_TYPE=RelWithDebInfo -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 + -DWEBFRONT_TEST_UNITY_BATCH=0 -DWEBFRONT_TEST_REPRODUCIBILITY=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 @@ -571,7 +573,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 -DWEBFRONT_ENABLE_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 -DWEBFRONT_TEST_REPRODUCIBILITY=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/AGENTS.md b/AGENTS.md index 749f14a8..a753bd33 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -90,6 +90,7 @@ without network access. - `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 no longer configure WebFront (`cmake/WebFrontTestOptions.cmake` documents the options). - `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. +- The project has no CMake presets: the defaults are the quick local build (`WEBFRONT_TEST_UNITY_BATCH=4`, `WEBFRONT_MSVC_ANALYZE=OFF`, `WEBFRONT_TEST_REPRODUCIBILITY=OFF`) and every CI job passes these options explicitly (`docs/TEST_TIERS.md`). 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/cmake/CompilerWarnings.cmake b/cmake/CompilerWarnings.cmake index 2657516a..f0eedc24 100644 --- a/cmake/CompilerWarnings.cmake +++ b/cmake/CompilerWarnings.cmake @@ -4,8 +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) + # MSVC /analyze roughly doubles the front-end work of every unit (#435): a local build leaves it out, and the + # advanced CI tier turns it on (docs/TEST_TIERS.md). set(MSVC_WARNINGS /W4 # Baseline reasonable warnings diff --git a/cmake/WebFrontTestOptions.cmake b/cmake/WebFrontTestOptions.cmake index 843ab263..886bc163 100644 --- a/cmake/WebFrontTestOptions.cmake +++ b/cmake/WebFrontTestOptions.cmake @@ -1,5 +1,9 @@ # WebFront options are independent of an embedding project's generic ENABLE_* variables. function(webfront_declare_test_options is_top_level) + # Keep the quick-build defaults here so the lightweight configuration fixture tests the actual declarations. + set(WEBFRONT_TEST_UNITY_BATCH 4 CACHE STRING "Compile the heavy unit tests this many to a file; 0 compiles each file alone") + option(WEBFRONT_MSVC_ANALYZE "Run the MSVC code analysis while compiling" OFF) + option(WEBFRONT_TEST_REPRODUCIBILITY "Build the self-built environment again, to prove it reproducible and equal to the checked-in bundles" OFF) 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) diff --git a/docs/BUILD_TIME_STUDY.md b/docs/BUILD_TIME_STUDY.md index bec79c66..1fd9cf5e 100644 --- a/docs/BUILD_TIME_STUDY.md +++ b/docs/BUILD_TIME_STUDY.md @@ -15,7 +15,7 @@ runs; Linux runs are steadier. | Change | Effect | |---|---| | `--parallel 4` on the desktop builds | Linux `tests` 280 -> 170 s cold, `all` 520 -> 255-375 s; Windows `tests` 820 -> 640 s, `all` 1240 -> 1080 s. Peak memory stays under 1 GB. | -| The 13 heavy unit tests compile four to a file (`WEBFRONT_TEST_UNITY_BATCH=4` on the desktop jobs) | Windows cold 640 -> 355 s, `WebFront.hpp` changed 298 -> 111 s; Linux 202 -> 143 s and 88 -> 45 s. Less memory. | +| The 13 heavy unit tests compile four to a file (`WEBFRONT_TEST_UNITY_BATCH=4`, the default) | Windows cold 640 -> 355 s, `WebFront.hpp` changed 298 -> 111 s; Linux 202 -> 143 s and 88 -> 45 s. Less memory. | | MSVC `/analyze` and the examples only in the master and weekly tier | `/analyze` is about 22 % of a Windows build (640 -> 497 s cold); the examples about 190 s of compiler time. | | The reproducibility builds only when a pull request changes their inputs | About 45 s of worker time per job (`SelfBuildRepeat`, `SelfBuildRefresh`). | | `JourneyEmbeddedBuild` and `LifeEmbeddedBuild` do not hold `webfront_port_9002` | They only compile; the lock had serialised 175 s (Linux) and 203 s (Windows) of tests. | diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 27ee162a..8b972b26 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -19,6 +19,7 @@ these entries stays in the GitHub releases and the Git history. - Declare GCC 13 as the best-effort S2 minimum for the library and examples, document the GCC 14 exit clause and qualified Clang scope, and add GCC 13 ASan/UBSan fast tests (#525, ADR-022). - Open the developer page on the interface, over the whole window, once the project has a preview; the terminal moves to a floating, movable window behind a tab on the right edge that shows the session's state, and keeps its session when collapsed. Its shortcut is F9, or the manifest's new optional `developer.terminalShortcut`. Environment sources 0.9.1, not published yet (#539, `docs/DEVELOPER_ENVIRONMENT.md`). +- Make the default test build the quick one: the heavy unit tests compile four to a file, the MSVC code analysis and the reproducibility proofs are off unless `-DWEBFRONT_MSVC_ANALYZE=ON` or `-DWEBFRONT_TEST_REPRODUCIBILITY=ON` asks for them. The CI passes every option explicitly and checks what it checked before (#546). - Run the unit tests as a few processes instead of one per scenario with `-DWEBFRONT_TEST_UNIT_SHARDS=`: each of the `n` CTest cases is a Catch2 shard that reports every scenario in `unit-results-.xml`. The default still registers one CTest case per scenario; the desktop CI jobs pass 4 and no longer run the fast tier twice on a pull request (#543). ### Fixed diff --git a/docs/TEST_TIERS.md b/docs/TEST_TIERS.md index 9ae17a24..f1bd57f9 100644 --- a/docs/TEST_TIERS.md +++ b/docs/TEST_TIERS.md @@ -54,20 +54,29 @@ 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. +## A quick local build by default + +The defaults of the test options are those of the quickest useful build, and the project has no CMake preset to choose +between: `-DWEBFRONT_ENABLE_TESTING=ON` alone compiles the heavy unit tests four to a file +(`WEBFRONT_TEST_UNITY_BATCH=4`), leaves the MSVC code analysis out (`WEBFRONT_MSVC_ANALYZE=OFF`) and does not register +the reproducibility proofs (`WEBFRONT_TEST_REPRODUCIBILITY=OFF`). The CI passes every one of these options explicitly, +so a default can change without changing what a job checks. While working, `ctest -L fast` then the cases the change +touches (`ctest -R `) are enough; the complete suite runs before the work is declared complete. + ## 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. +dispatch with `repeat_desktop_tests`, not by a pull request into `develop`. The proofs that the self-built environment is reproducible and equal to the checked-in bundles (`SelfBuildRepeat`, `SelfBuildReproducible`, `SelfBuildRefresh`, `SelfBuildRefreshMatchesSources`) build it twice more, about 45 s on a hosted runner. A pull request into `develop` runs them only when it changes one of their inputs (`js/`, `examples/life/ui/`, `test/developer/`, `test/web/registry/` and `test/web/CMakeLists.txt`, `include/webfront/system/`, the CMake scripts that prepare, compare and assemble the self-build project, `LICENSE` and the workflow itself); a push to `develop` and the advanced -checks always run them. `-DWEBFRONT_TEST_REPRODUCIBILITY=OFF` leaves them out locally; the default is ON. +checks always run them. They are off by default: `-DWEBFRONT_TEST_REPRODUCIBILITY=ON` adds them to a local build. ## Advanced checks diff --git a/test/cmake/CheckTestOptions.cmake b/test/cmake/CheckTestOptions.cmake index a8f87f68..65171047 100644 --- a/test/cmake/CheckTestOptions.cmake +++ b/test/cmake/CheckTestOptions.cmake @@ -19,7 +19,8 @@ function(configure name directory) endforeach() endfunction() configure("defaults" defaults OPTIONS -DTOP_LEVEL=ON - EXPECT "TESTING=OFF LEGACY=" "FUZZING=OFF LEGACY=" "COVERAGE=OFF LEGACY=") + EXPECT "TESTING=OFF LEGACY=" "FUZZING=OFF LEGACY=" "COVERAGE=OFF LEGACY=" + "TEST_UNITY_BATCH=4" "MSVC_ANALYZE=OFF" "TEST_REPRODUCIBILITY=OFF") foreach(level ON OFF) configure("generic options at level ${level}" "generic-${level}" OPTIONS -DTOP_LEVEL=${level} -DENABLE_TESTING=ON -DENABLE_FUZZING=ON -DENABLE_COVERAGE=ON @@ -31,10 +32,12 @@ foreach(level ON OFF) "SANITIZER_MEMORY=OFF LEGACY=ON") configure("explicit options at level ${level}" "generic-${level}" OPTIONS -DWEBFRONT_ENABLE_TESTING=ON -DWEBFRONT_ENABLE_FUZZING=ON -DWEBFRONT_ENABLE_COVERAGE=ON + -DWEBFRONT_TEST_UNITY_BATCH=0 -DWEBFRONT_MSVC_ANALYZE=ON -DWEBFRONT_TEST_REPRODUCIBILITY=ON -DWEBFRONT_ENABLE_SANITIZER_ADDRESS=ON -DWEBFRONT_ENABLE_SANITIZER_LEAK=ON -DWEBFRONT_ENABLE_SANITIZER_UNDEFINED_BEHAVIOR=ON -DWEBFRONT_ENABLE_SANITIZER_THREAD=ON -DWEBFRONT_ENABLE_SANITIZER_MEMORY=ON EXPECT "TESTING=ON LEGACY=ON" "FUZZING=ON LEGACY=ON" "COVERAGE=ON LEGACY=ON" + "TEST_UNITY_BATCH=0" "MSVC_ANALYZE=ON" "TEST_REPRODUCIBILITY=ON" "SANITIZER_ADDRESS=ON LEGACY=ON" "SANITIZER_LEAK=ON LEGACY=ON" "SANITIZER_UNDEFINED_BEHAVIOR=ON LEGACY=ON" "SANITIZER_THREAD=ON LEGACY=ON" "SANITIZER_MEMORY=ON LEGACY=ON") diff --git a/test/cmake/test-options/CMakeLists.txt b/test/cmake/test-options/CMakeLists.txt index f8562781..94374930 100644 --- a/test/cmake/test-options/CMakeLists.txt +++ b/test/cmake/test-options/CMakeLists.txt @@ -19,6 +19,9 @@ 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}) +foreach(name TEST_UNITY_BATCH MSVC_ANALYZE TEST_REPRODUCIBILITY) + message(STATUS "${name}=${WEBFRONT_${name}}") +endforeach() 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/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 086f63cd..c2c76e26 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -55,10 +55,9 @@ add_dependencies(tests host_probe) target_compile_definitions(tests PRIVATE WEBFRONT_HOST_PROBE="$") # The heavy units instantiate a full application, and compile four to a file in about half the time of four apart -# (docs/BUILD_TIME_STUDY.md). The desktop CI jobs set the batch size; the default keeps one object per test file, which -# keeps a rebuild after one edit small. The light units stay apart: grouping every unit does not compile, as their +# (docs/BUILD_TIME_STUDY.md): that is the default. 0 keeps one object per test file, which the portability and +# sanitizer jobs ask for. The light units stay apart: grouping every unit does not compile, as their # helpers share names. -set(WEBFRONT_TEST_UNITY_BATCH 0 CACHE STRING "Compile the heavy unit tests this many to a file; 0 compiles each file alone") if(WEBFRONT_TEST_UNITY_BATCH GREATER 0) set(_heavy WebFrontTests ReadBindingTests ViewAssociationTests BroadcastTests CommandsTests ApplicationTaskTests DeferredCallTests StdnetShutdownTests FrontendContractTests JsFunctionSenderTests AutomationTests ReactStoreTests DeveloperTests CEFMacrosTests JasmineConsumerTests WfDriverTests) diff --git a/test/web/CMakeLists.txt b/test/web/CMakeLists.txt index 06004ac7..cf645e67 100644 --- a/test/web/CMakeLists.txt +++ b/test/web/CMakeLists.txt @@ -645,8 +645,8 @@ if(_browser_tests_available) webfront_add_self_build_test(DeveloperSpecs 0 "test|--timeout|240" OUTPUT "PASSED: [0-9]+ specs" TIMEOUT 300 REQUIRES SelfBuildInstalled) # The reproducibility proofs build the environment again, the second time from a refreshed bootstrap: about 45 s on a - # hosted runner. A pull request that changes none of their inputs may leave them to the master tier (#435). - option(WEBFRONT_TEST_REPRODUCIBILITY "Build the self-built environment again, to prove it reproducible and equal to the checked-in bundles" ON) + # hosted runner. A pull request that changes none of their inputs may leave them to the master tier (#435), and a + # local build leaves them out unless it asks for them. if(WEBFRONT_TEST_REPRODUCIBILITY) webfront_add_self_build_test(SelfBuildRepeat 0 "run|build|build-distribution-repeat" OUTPUT "Script build completed" REQUIRES SelfBuilt PROVIDES SelfBuiltTwice)