From 3c3ceefa529e1920f0e0ce0583ad586b67f3aaf9 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Thu, 26 Nov 2026 22:25:06 +0100 Subject: [PATCH 1/3] ci: run Linux tests in parallel, skip the unit suites in the ladder's ASan leg, and the install self-test where nothing it reads changed Three changes to the jobs that set a pull request's wall time on master's last green run (CI 45369799802): Application ladder / ASan+UBSan 108 min, clang-asan 87, consumability 86. - Every Linux ctest runs one test per CPU. catch_discover_tests makes each case its own process, so a serial run is mostly process start-up: the asan leg's 5,689 cases took 3,391 s one at a time. Locally the clang-asan suite (4,911 cases, the OomInjector exclusion applied) passed three runs out of three at --parallel 4, in 686-711 s. Tests sharing a resource already say so with RESOURCE_LOCK or RUN_SERIAL. - MORPH_BUILD_UNIT_TESTS (default ON) gates everything under tests/ itself. The ladder's ASan leg turns it off: it runs the ladder and the Qt transport suites only, and morph_tests and morph_table_tests were 302 of its 862 compiles; clang-asan builds and runs them under the same sanitizers. The plain ladder leg keeps them, since its name-collision check covers every ctest test. - The consumability job's self-test builds morph from scratch nine times (61 min). It tests the checker, so a pull request runs it only when the checker, its self-test, the build and install rules, or a header its mutations name changed; a master push always runs it. The install check itself still runs on every pull request. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01No1NzndCGtpCccptcyk6Tb --- .github/workflows/ci.yml | 58 +++++++++++++++++++++++++++++++++------- CMakeLists.txt | 4 +++ docs/BUILDING.md | 1 + tests/CMakeLists.txt | 5 ++++ 4 files changed, 59 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3686f147f..4cd737844 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -414,8 +414,14 @@ jobs: # Release legs run the suite too: these are the only builds with NDEBUG # defined, so code on those paths runs nowhere else. + # + # Every Linux ctest runs one test per CPU (--parallel "$(nproc)"). + # catch_discover_tests makes each test case its own process, so a serial + # run is mostly process start-up: ~6,000 cases, about half a second each + # under ASan, ran 56 minutes one at a time. Tests that share a resource + # say so with RESOURCE_LOCK (the ladder's database) or RUN_SERIAL. - name: Test - run: ctest --preset ${{ matrix.preset }} + run: ctest --preset ${{ matrix.preset }} --parallel "$(nproc)" # Cumulative hit/miss for this leg. Without it the cache is # unfalsifiable: a thrashing cache and a working one look identical @@ -637,7 +643,7 @@ jobs: if [ "${{ matrix.preset }}" = "clang-asan" ] || [ "${{ matrix.preset }}" = "clang-tsan" ]; then EXCLUDE_ARGS+=(-E "OomInjector|morph#108") fi - ctest --preset ${{ matrix.preset }} "${EXCLUDE_ARGS[@]}" + ctest --preset ${{ matrix.preset }} --parallel "$(nproc)" "${EXCLUDE_ARGS[@]}" # The tui suite ran at all. The step above passes just as well when # MORPH_BUILD_TUI was dropped from the configure, or quietly turned off, @@ -645,7 +651,7 @@ jobs: # tui cases, and `--no-tests=error` turns "selected nothing" red. - name: The tui suite was built and ran if: "!cancelled()" - run: ctest --preset ${{ matrix.preset }} -L tui --no-tests=error --output-on-failure + run: ctest --preset ${{ matrix.preset }} --parallel "$(nproc)" -L tui --no-tests=error --output-on-failure # Cache statistics for this leg. The `sccache stats` step is skipped # whenever the probe put this job on the self-hosted fleet, because @@ -802,7 +808,7 @@ jobs: # on a runner with no display. QT_QPA_PLATFORM: offscreen run: | - LLVM_PROFILE_FILE="build/clang-coverage/%p.profraw" ctest --preset clang-coverage -LE stress + LLVM_PROFILE_FILE="build/clang-coverage/%p.profraw" ctest --preset clang-coverage --parallel "$(nproc)" -LE stress # Deliberately left on the implicit `success()`, unlike the three test # steps that carry `!cancelled()` (ladder-tests' scenario corpus, @@ -934,7 +940,7 @@ jobs: - name: Test (offscreen Qt platform) env: QT_QPA_PLATFORM: offscreen - run: ctest --preset gcc-debug + run: ctest --preset gcc-debug --parallel "$(nproc)" # Cumulative hit/miss for this leg. Without it the cache is # unfalsifiable: a thrashing cache and a working one look identical @@ -1272,7 +1278,7 @@ jobs: if: steps.filter.outputs.run == 'true' env: QT_QPA_PLATFORM: offscreen - run: ctest --preset gcc-debug -L ladder -LE stress --output-on-failure + run: ctest --preset gcc-debug --parallel "$(nproc)" -L ladder -LE stress --output-on-failure # The Qt Quick renderer's suites, on the Qt this job installs (Ubuntu's # packaged Qt is older than the 6.5 Qt Quick needs). `--no-tests=error` @@ -1282,7 +1288,7 @@ jobs: if: "!cancelled() && steps.filter.outputs.run == 'true'" env: QT_QPA_PLATFORM: offscreen - run: ctest --preset gcc-debug -L qt_quick --no-tests=error --output-on-failure + run: ctest --preset gcc-debug --parallel "$(nproc)" -L qt_quick --no-tests=error --output-on-failure # ── The scenario corpus, against the servers just built ──────────── # This step is the only place in CI that runs @@ -1516,6 +1522,10 @@ jobs: # No -DCMAKE_..._COMPILER_LAUNCHER=sccache: see linux-compilers' # Configure steps for why leaving it unset is what lets pace-cc # be selected. + # MORPH_BUILD_UNIT_TESTS=OFF: this job runs the ladder and the Qt + # transport suites only, and morph_tests and morph_table_tests were a + # third of its compiles. "Linux / clang-asan" builds and runs them under + # the same sanitizers. - name: Configure (clang-asan, ladder + Qt on) if: steps.filter.outputs.run == 'true' run: | @@ -1523,6 +1533,7 @@ jobs: -DMORPH_BUILD_QT=ON \ -DMORPH_BUILD_LADDER=ON \ -DMORPH_LADDER_RUNGS=all \ + -DMORPH_BUILD_UNIT_TESTS=OFF \ -DCMAKE_C_COMPILER=clang-${{ env.CLANG_VERSION }} \ -DCMAKE_CXX_COMPILER=clang++-${{ env.CLANG_VERSION }} \ $MORPH_PACE_AUTO_INSTALL_FLAG @@ -1583,7 +1594,7 @@ jobs: QT_QPA_PLATFORM: offscreen ASAN_OPTIONS: detect_leaks=0 UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1 - run: ctest --preset clang-asan -L ladder -LE stress --output-on-failure + run: ctest --preset clang-asan --parallel "$(nproc)" -L ladder -LE stress --output-on-failure # The Qt transport suites, which no other sanitizer leg runs. # Instrumenting a suite nothing runs swaps one vacuous control for @@ -1616,7 +1627,7 @@ jobs: ASAN_OPTIONS: detect_leaks=0 UBSAN_OPTIONS: print_stacktrace=1:halt_on_error=1 run: | - ctest --preset clang-asan --no-tests=error --output-on-failure \ + ctest --preset clang-asan --parallel "$(nproc)" --no-tests=error --output-on-failure \ -R 'morph::qt::|qt_tls_example_runs' # Cumulative hit/miss for this leg. Without it the cache is @@ -2370,6 +2381,8 @@ jobs: runs-on: ubuntu-24.04 steps: - uses: actions/checkout@v4 + with: + fetch-depth: 0 # need history for the self-test's changed-paths diff below # CPM's source cache (CMakeLists.txt defaults CPM_SOURCE_CACHE to # .cache/cpm): restored, a configure clones nothing; missed, it clones @@ -2392,10 +2405,37 @@ jobs: sudo apt-get update -q sudo apt-get install -y gcc-15 g++-15 ninja-build + # The self-test builds morph from scratch once per mutation, nine times, + # which is most of this job. It tests the checker, so a pull request runs + # it only when the checker, its self-test, or what they read and mutate + # changed: the build and install rules (CMakeLists.txt, cmake/) and the + # three headers the mutations name. A master push always runs it, so a + # header the mutations name cannot drift away unnoticed. The check itself + # (the two steps after it) runs on every pull request. + - name: Does this change reach the install/export checker? + id: selftest + run: | + if [ "${{ github.event_name }}" != "pull_request" ]; then + echo "run=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + base="${{ github.event.pull_request.base.sha }}" + if [ -z "$base" ] || ! git cat-file -e "$base" 2>/dev/null; then + echo "run=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + pattern='^(CMakeLists\.txt|cmake/|scripts/(test_)?check_install_export\.sh|\.github/workflows/ci\.yml|include/morph/detail/(fixed_string|selftest_not_standalone)\.hpp|include/morph/util/rational\.hpp)' + if git diff --name-only "$base" HEAD | grep -qE "$pattern"; then + echo "run=true" >> "$GITHUB_OUTPUT" + else + echo "run=false" >> "$GITHUB_OUTPUT" + fi + # See scripts/test_check_install_export.sh's own comment: a gate nobody # tests reports green whether or not it still detects anything, and this # one guards a defect whose whole character was reporting success. - name: Self-test the install/export checker + if: steps.selftest.outputs.run == 'true' env: CC: gcc-15 CXX: g++-15 diff --git a/CMakeLists.txt b/CMakeLists.txt index d49c3125f..1a39bce0e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,10 @@ if(CMAKE_GENERATOR MATCHES "Ninja" AND MORPH_LINK_JOBS GREATER 0) endif() option(MORPH_BUILD_TESTS "Build tests" ON) +# OFF builds no target under tests/ itself: morph_tests, morph_table_tests and the compile checks. A job that runs only +# the ladder's or a frontend's suites sets it, since those targets are most of its build and another job builds and +# runs them. The suites in tests// and the ladder's are still built under MORPH_BUILD_TESTS. +option(MORPH_BUILD_UNIT_TESTS "Build the library's own suites in tests/ (morph_tests, morph_table_tests, compile checks)" ON) option(MORPH_BUILD_SHARED "Build morph::morph as a shared library (MORPH_API marks what it exports; symbols are hidden by default)" OFF) # A shared morph links a shared core-cpp (CORE_CPP_BUILD_SHARED): core-cpp keeps # process and thread state of its own, such as the current executor, and a diff --git a/docs/BUILDING.md b/docs/BUILDING.md index 158e8c74c..1a2665735 100644 --- a/docs/BUILDING.md +++ b/docs/BUILDING.md @@ -44,6 +44,7 @@ need `VCPKG_ROOT` set. | Option | Default | What it builds | |---|---|---| | `MORPH_BUILD_TESTS` | `ON` | The unit tests | +| `MORPH_BUILD_UNIT_TESTS` | `ON` | With `MORPH_BUILD_TESTS`, the library's own suites in `tests/` (`morph_tests`, `morph_table_tests`, the compile checks); a job running only the ladder or a frontend suite turns it off | | `MORPH_BUILD_SHARED` | `OFF` | Build `morph::morph` as a shared library. Every symbol is hidden unless `MORPH_API` marks it, on every platform; see below | | `MORPH_BUILD_EXAMPLES` | `ON` | The dependency-free examples (forms, concepts, gallery, LIMS gallery); the generic client when a frontend is on | | `MORPH_BUILD_CLIENT` | `ON` | `morph::client`, the generic client's source and shell | diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 8a8f22cc1..8b50b8a62 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,3 +1,8 @@ +# MORPH_BUILD_UNIT_TESTS=OFF: nothing in this file is built (see its option in the root CMakeLists.txt). +if(NOT MORPH_BUILD_UNIT_TESTS) + return() +endif() + # ── The SYSTEM-include demotion helper's own self-test ────────────────────── # cmake/morph_demote_interface_includes.cmake moves unixODBC's `-I` out of the # fetched Lightweight target's INTERFACE_COMPILE_OPTIONS. On Linux that flag is From fe8e165ff4918b5720def11d532d9f6786157d63 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Fri, 27 Nov 2026 00:01:15 +0100 Subject: [PATCH 2/3] test: hold the reopened-view check reply off the owner, and give the net channel conformance a TSan-sized wait Under parallel ctest the check's reply could run inside the click's settle and mount the draft before the view was reopened; pressing Preview without running the owner keeps the reply queued until the view is reopened. The net channel fixture waited the default two seconds for 50 socket events, which TSan on a loaded runner can exceed. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01No1NzndCGtpCccptcyk6Tb --- tests/net/test_push_net.cpp | 4 +++- tests/test_ui_custom_screen_chrome.cpp | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/net/test_push_net.cpp b/tests/net/test_push_net.cpp index 0783960a5..7b54fa9de 100644 --- a/tests/net/test_push_net.cpp +++ b/tests/net/test_push_net.cpp @@ -622,9 +622,11 @@ TEST_CASE("net_channel_conformance", "[push][channel]") { auto const cid = nextConnectionId(*server); ::morph::net::SocketBackend backend{wsUrl(wsServer.port())}; REQUIRE(backend.waitForConnected()); + // Every wait here is for something that must happen, so a generous budget costs nothing on a green run; + // it is sized for a socket round trip per event under TSan on a runner that runs other tests beside it. ::morph::testing::push::ChannelFixture fixture{ .server = server.get(), .cid = cid, .backend = &backend, .waitFor = [](const std::function& done) { - return ::morph::testing::waitUntil(done); + return ::morph::testing::waitUntil(done, ::morph::testing::WaitBudget{std::chrono::seconds{20}}); }}; body(fixture); }); diff --git a/tests/test_ui_custom_screen_chrome.cpp b/tests/test_ui_custom_screen_chrome.cpp index 4f064a1d9..8b5958aff 100644 --- a/tests/test_ui_custom_screen_chrome.cpp +++ b/tests/test_ui_custom_screen_chrome.cpp @@ -284,7 +284,8 @@ TEST_CASE("custom screen chrome: a reply to a check made for a view that was reo rig.open("notes.edit", note(1)); rig.click("source_button_notes.edit"); rig.type("source_text", screens_test::replaced(rig.field("source_text"), "\"Edit note\"", "\"Stale\"")); - rig.click("source_preview"); + // Pressed without running the owner, so the check's reply cannot arrive before the source view is reopened. + rig.harness.backend.click(*rig.find("Button", "source_preview")); REQUIRE(rig.find("Dialog", "source_dialog").has_value()); rig.chrome->showSource(rig.tabAt(0)); REQUIRE(rig.pump([&rig] { return rig.field("source_text") == morph::ui::prettyJson(kEdit); })); From c1ebee1b31716f44b3fd5b6abf18232ba2cc4199 Mon Sep 17 00:00:00 2001 From: Yaraslau Tamashevich Date: Fri, 27 Nov 2026 01:48:51 +0100 Subject: [PATCH 3/3] test: hold the server's pool while the chrome looks at a check in flight The two tests that inspect the source view while a check runs relied on the reply not arriving within the click's settle. Under parallel ctest it sometimes did. They now occupy the test server's pool threads until they have looked, so the reply waits for the release. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01No1NzndCGtpCccptcyk6Tb --- tests/test_ui_custom_screen_chrome.cpp | 45 ++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/tests/test_ui_custom_screen_chrome.cpp b/tests/test_ui_custom_screen_chrome.cpp index 8b5958aff..1c6d64e17 100644 --- a/tests/test_ui_custom_screen_chrome.cpp +++ b/tests/test_ui_custom_screen_chrome.cpp @@ -5,10 +5,12 @@ // Save as… and Discard, and the store's refusal shown to the person. #include +#include #include #include #include #include +#include #include #include #include @@ -29,6 +31,42 @@ using custom_client::Offer; using morph::ui::DocumentScreenHost; using morph::ui::ParamMap; +namespace { + +/// Occupies every thread of the rig's server pool until it is released or destroyed, so a call sent meanwhile is +/// answered only after the release, however fast the server would otherwise be. +class ServerHold { +public: + explicit ServerHold(ChromeRig& rig) { + REQUIRE(rig.server.has_value()); + std::latch started{kThreads}; + for (std::ptrdiff_t thread = 0; thread < kThreads; ++thread) { + rig.server->pool.post([this, &started] { + started.count_down(); + _released.wait(false); + }); + } + started.wait(); + } + ~ServerHold() { release(); } + ServerHold(ServerHold const&) = delete; + ServerHold& operator=(ServerHold const&) = delete; + ServerHold(ServerHold&&) = delete; + ServerHold& operator=(ServerHold&&) = delete; + + void release() { + _released.store(true); + _released.notify_all(); + } + +private: + // The size of the test server's pool. + static constexpr std::ptrdiff_t kThreads = 2; + std::atomic _released{false}; +}; + +} // namespace + // Mutation: skip mountDraft after the server's check (the heading stays "Edit note"). TEST_CASE( "custom screen chrome: Source shows the screen's document, and Preview mounts the edit as the window's draft", @@ -265,6 +303,7 @@ TEST_CASE("custom screen chrome: while a check runs the editor is read only, and rig.click("source_button_notes.edit"); int const editor = *rig.find("TextInput", "source_text"); CHECK(rig.harness.backend.prop(editor, "readonly") != "true"); + ServerHold hold{rig}; rig.click("source_preview"); REQUIRE(rig.find("TextInput", "source_text").has_value()); CHECK(rig.harness.backend.prop(*rig.find("TextInput", "source_text"), "readonly") == "true"); @@ -273,6 +312,7 @@ TEST_CASE("custom screen chrome: while a check runs the editor is read only, and rig.chrome->preview([&again](bool drafted) { again = drafted; }); REQUIRE(again.has_value()); CHECK_FALSE(*again); + hold.release(); REQUIRE(rig.pump([&rig] { return rig.shown("Row", "draft_bar_notes.edit"); })); } @@ -284,11 +324,12 @@ TEST_CASE("custom screen chrome: a reply to a check made for a view that was reo rig.open("notes.edit", note(1)); rig.click("source_button_notes.edit"); rig.type("source_text", screens_test::replaced(rig.field("source_text"), "\"Edit note\"", "\"Stale\"")); - // Pressed without running the owner, so the check's reply cannot arrive before the source view is reopened. - rig.harness.backend.click(*rig.find("Button", "source_preview")); + ServerHold hold{rig}; + rig.click("source_preview"); REQUIRE(rig.find("Dialog", "source_dialog").has_value()); rig.chrome->showSource(rig.tabAt(0)); REQUIRE(rig.pump([&rig] { return rig.field("source_text") == morph::ui::prettyJson(kEdit); })); + hold.release(); static_cast( rig.pump([&rig] { return rig.shown("Row", "draft_bar_notes.edit"); }, std::chrono::milliseconds{300})); CHECK(rig.text("heading") == "Edit note");