diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c33eb4372..1d58ebffa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -102,16 +102,10 @@ jobs: - name: Catch2 failure report (runtime logs filtered out) if: failure() run: | - # The unit test binary emits thousands of structured runtime log - # lines (timestamp + + module:) that bury Catch2's own - # failure report. Drop those so what remains is Catch2 section - # headers, FAILED assertions, and the test-case summary — i.e. the - # failing test name + file:line. Mirrors the NetBSD job's inline - # equivalent below. - if [ -f build/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build/meson-logs/testlog.txt \ - | tail -n 300 - fi + # Prints each failed test's Catch2 output (scenario, file:line, + # FAILED:, expansion) with the runtime log lines that bury it + # removed. Every job's report runs the same script (ADR-0877). + sh scripts/catch2-failure-report.sh build/meson-logs/testlog.txt - name: Conformance gate run: sh scripts/check-conformance-gate.sh build @@ -213,10 +207,7 @@ jobs: - name: Catch2 failure report (runtime logs filtered out) if: failure() run: | - if [ -f build-ubuntu-interim/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build-ubuntu-interim/meson-logs/testlog.txt \ - | tail -n 300 - fi + sh scripts/catch2-failure-report.sh build-ubuntu-interim/meson-logs/testlog.txt - name: Conformance gate run: sh scripts/check-conformance-gate.sh build-ubuntu-interim @@ -325,14 +316,6 @@ jobs: ./build-hardened/tests/merovingian-integration-tests \ "[startup][binary]" --success - - name: Catch2 failure report (runtime logs filtered out) - if: failure() - run: | - if [ -f build-hardened/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build-hardened/meson-logs/testlog.txt \ - | tail -n 300 - fi - # -- Fedora / Red Hat family ----------------------------------------------- fedora-suite: needs: queue-after-analyses @@ -397,10 +380,7 @@ jobs: - name: Catch2 failure report (runtime logs filtered out) if: failure() run: | - if [ -f build-fedora/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build-fedora/meson-logs/testlog.txt \ - | tail -n 300 - fi + sh scripts/catch2-failure-report.sh build-fedora/meson-logs/testlog.txt - name: Conformance gate run: sh scripts/check-conformance-gate.sh build-fedora @@ -485,10 +465,7 @@ jobs: - name: Catch2 failure report (runtime logs filtered out) if: failure() run: | - if [ -f build-debian/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build-debian/meson-logs/testlog.txt \ - | tail -n 300 - fi + sh scripts/catch2-failure-report.sh build-debian/meson-logs/testlog.txt - name: Conformance gate run: sh scripts/check-conformance-gate.sh build-debian @@ -576,10 +553,7 @@ jobs: - name: Catch2 failure report (runtime logs filtered out) if: failure() run: | - if [ -f build-rhel/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build-rhel/meson-logs/testlog.txt \ - | tail -n 300 - fi + sh scripts/catch2-failure-report.sh build-rhel/meson-logs/testlog.txt - name: Conformance gate run: sh scripts/check-conformance-gate.sh build-rhel @@ -697,10 +671,7 @@ jobs: - name: Catch2 failure report (runtime logs filtered out) if: failure() run: | - if [ -f "${BUILDDIR}/meson-logs/testlog.txt" ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' "${BUILDDIR}/meson-logs/testlog.txt" \ - | tail -n 300 - fi + sh scripts/catch2-failure-report.sh "${BUILDDIR}/meson-logs/testlog.txt" - name: Conformance gate run: sh scripts/check-conformance-gate.sh "${BUILDDIR}" @@ -750,10 +721,7 @@ jobs: pkg install -y meson ninja llvm catch2 pkgconf git perl5 bison flex gmake openssl libsodium postgresql17-client curl png libjpeg-turbo if ! sh scripts/build-bsd.sh --builddir build --skip-job freebsd; then echo "::group::FreeBSD Catch2 failure report (runtime logs filtered out)" - if [ -f build/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build/meson-logs/testlog.txt \ - | tail -n 300 - fi + sh scripts/catch2-failure-report.sh build/meson-logs/testlog.txt echo "::endgroup::" # The report above drops runtime log lines to keep Catch2's output # readable, which also hides why a runtime refused to start. List @@ -812,10 +780,7 @@ jobs: run: | if ! sh scripts/build-bsd.sh --builddir build --skip-job openbsd; then echo "::group::OpenBSD Catch2 failure report (runtime logs filtered out)" - if [ -f build/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build/meson-logs/testlog.txt \ - | tail -n 300 - fi + sh scripts/catch2-failure-report.sh build/meson-logs/testlog.txt echo "::endgroup::" # The report above drops runtime log lines to keep Catch2's output # readable, which also hides why a runtime refused to start. List @@ -983,16 +948,7 @@ jobs: rm -rf netbsd-packages if ! sh scripts/build-bsd.sh --builddir build --skip-job netbsd; then echo "::group::NetBSD Catch2 failure report (runtime logs filtered out)" - if [ -f build/meson-logs/testlog.txt ]; then - # The unit test binary emits thousands of structured runtime - # log lines (timestamp + + module:) that bury Catch2's - # own failure report. Drop those and the [netbsd-diag] markers - # so what remains is Catch2 section headers, FAILED assertions, - # and the test-case summary — i.e. the failing test name + file:line. - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build/meson-logs/testlog.txt \ - | grep -vE '^\[netbsd-diag\]' \ - | tail -n 150 - fi + sh scripts/catch2-failure-report.sh --exclude '^\[netbsd-diag\]' build/meson-logs/testlog.txt echo "::endgroup::" echo "::group::NetBSD core backtraces" for core in $(find build -name '*.core' 2>/dev/null); do diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index 62e67a512..02d18d84f 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -210,10 +210,7 @@ jobs: - name: Catch2 failure report (runtime logs filtered out) if: failure() run: | - if [ -f build-coverage/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build-coverage/meson-logs/testlog.txt \ - | tail -n 300 - fi + sh scripts/catch2-failure-report.sh build-coverage/meson-logs/testlog.txt - name: Generate coverage reports id: reports diff --git a/.github/workflows/sanitizers.yml b/.github/workflows/sanitizers.yml index 769c6e5a1..7d6331071 100644 --- a/.github/workflows/sanitizers.yml +++ b/.github/workflows/sanitizers.yml @@ -71,10 +71,7 @@ jobs: - name: Catch2 failure report (runtime logs filtered out) if: failure() run: | - if [ -f build/meson-logs/testlog.txt ]; then - grep -vE '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]+ \+[0-9]{4} <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>' build/meson-logs/testlog.txt \ - | tail -n 300 - fi + sh scripts/catch2-failure-report.sh build/meson-logs/testlog.txt tsan: runs-on: ubuntu-latest @@ -134,6 +131,11 @@ jobs: shell: bash run: sh scripts/build-linux.sh --builddir build-tsan --buildtype debug --sanitize thread --skip-job tsan 2>&1 | tee tsan-ci-log.txt + - name: Catch2 failure report (runtime logs filtered out) + if: failure() + run: | + sh scripts/catch2-failure-report.sh build-tsan/meson-logs/testlog.txt + - name: Upload TSan logs if: always() uses: actions/upload-artifact@v7 diff --git a/CHANGELOG.md b/CHANGELOG.md index 411d439ac..dba9254cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,8 @@ Changes before 1.0.0 are in [CHANGELOG-pre-release.md](CHANGELOG-pre-release.md) unavailable (error) and no TURN configured (debug), with the user ID and never a credential (ADR-0871). * Tests set a log module's level through one shared helper, `tests/support/ModuleLogLevel.hpp`, instead of a copy per file; the security coding rules state the TURN logging rule and why the username is withheld. +* The documentation site uses OMG Software's outlined-toggle brand: switch orange and charcoal, the G knob, + and Merovingian's project icon, copied from the brand package with only line endings changed (ADR-0878). ## Security Fixes @@ -197,6 +199,8 @@ Changes before 1.0.0 are in [CHANGELOG-pre-release.md](CHANGELOG-pre-release.md) gone), and a tooling test fails when that list and the modules the sources name differ (ADR-0872). * The TURN log calls mark GCC's cleanup of their braced field lists excluded from coverage, a compiler path no test can reach; the testing standards say when such a marker is allowed (ADR-0874). +* A CI failure report shows each failed test's Catch2 output, however early it ran, within a 4000-line cap that it + reports; a tail of the log lost it behind later tests. The `tsan` job gets a report too (ADR-0877). ## Release notes diff --git a/docs/adr/0223-the-documentation-site-wears-the-omg-software-theme-dark-first-with-system-fonts.md b/docs/adr/0223-the-documentation-site-wears-the-omg-software-theme-dark-first-with-system-fonts.md index 9604a2540..abf9c28aa 100644 --- a/docs/adr/0223-the-documentation-site-wears-the-omg-software-theme-dark-first-with-system-fonts.md +++ b/docs/adr/0223-the-documentation-site-wears-the-omg-software-theme-dark-first-with-system-fonts.md @@ -1,6 +1,6 @@ # The documentation site wears the OMG Software theme, dark first, with system fonts -* Status: accepted +* Status: accepted; colours and marks superseded by [ADR-0878](0878-the-documentation-takes-the-outlined-toggle-brand-colours-and-marks.md) (2026-11-24) * Date: 2026-10-25 Technical Story: match the published documentation site to the OMG Software organisation site (0.12.46). diff --git a/docs/adr/0877-ci-failure-reports-print-each-failed-test-not-a-tail-of-the-log.md b/docs/adr/0877-ci-failure-reports-print-each-failed-test-not-a-tail-of-the-log.md new file mode 100644 index 000000000..60f741f47 --- /dev/null +++ b/docs/adr/0877-ci-failure-reports-print-each-failed-test-not-a-tail-of-the-log.md @@ -0,0 +1,64 @@ +# CI failure reports print each failed test's section of the Meson log, not a tail of the whole log + +* Status: accepted +* Date: 2026-11-24 + +Technical Story: an `asan-ubsan` run on the presence-flood pull request (run 44948590233, job 136981278297) said +"1 failed" and showed no failed assertion anywhere. + +## Context and Problem Statement + +When `meson test` fails, each CI job's "Catch2 failure report" step printed `testlog.txt` without the homeserver's +runtime log lines, then the last 300 lines of that (150 on NetBSD). Meson writes tests in the order they finish, so an +early failure, such as `integration-tests-shard-1-of-4`, is followed by every smoke test that finished after it, and +those pushed its Catch2 output out of the window. `--print-errorlogs` shows only the last 100 lines of a failed test, +which were runtime logging. How should a failure report find the failed assertion? + +## Decision Drivers + +* Where a failed Catch2 case (scenario, file and line, `FAILED:`, expansion, exception message) appears in the report + must not depend on how early its test ran or how much passed after it. +* It must run unchanged on the Ubuntu, Debian, Fedora and AlmaLinux jobs and inside the FreeBSD, OpenBSD and NetBSD + VMs, none of which is sure to have a `python3` on `PATH`. +* A broken run must not print an unbounded log. + +## Considered Options + +1. `scripts/catch2-failure-report.sh`: one POSIX `awk` pass over `testlog.txt` that keeps the section of each test + whose `result:` is neither `exit status 0` nor `exit status 77` (Meson's skip), drops runtime log lines, and caps + each test (first 400 and last 100 lines) and the whole report (4000 lines, summary included: a test that does + not fit is cut further, or counted as not shown). +2. Raise the tail (say to 3000 lines). +3. Read `testlog.json` in Python, whose records carry a `result` of `FAIL`, `TIMEOUT` and so on. +4. Fix the order instead (run the integration shards last), or rely on `--print-errorlogs`. + +## Decision Outcome + +Chosen option: 1, run by every report step: `ci.yml`'s Linux and BSD jobs, `coverage.yml`, and both jobs of +`sanitizers.yml` (`tsan` had no report step). NetBSD passes `--exclude '^\[netbsd-diag\]'`. A job that never runs +`meson test` writes no `testlog.txt` and has no report step: `ubuntu-hardened-listener-coverage` builds with +`--no-tests` and runs its Catch2 binary in its own step, whose log shows any failure. + +* A tail of any length can lose a failure: the number of lines after it depends on what finished later, which changes + with the platform, the sanitizer and the scheduling. +* `testlog.json` would be read more simply in Python, but the BSD VMs install only a versioned Python as Meson's + dependency (see `check_expected_skips.py` in `scripts/AGENTS.md`), and a second implementation for them would drift. + The text log's format is stable: each test opens with a `==== N/M ====` banner and closes with a 78-character rule, + and `result:` holds Meson's `returncode_to_status` text. +* The order of tests is not the report's to fix, and `--print-errorlogs` cannot be told to skip runtime log lines. +* The script uses no `awk` interval expressions (`{4}`), which older releases of `mawk` and the BSDs' `awk` did not + accept, and reads its patterns from the environment, since `awk -v` would process their backslashes. + +### Negative Consequences + +* The caps can leave out failure output, assertions included: a failed test with more than 500 lines of its own + output shows its first 400 and last 100, and once the report nears 4000 lines a test is cut further or not shown. + The report counts every gap and every test left out, and names `testlog.txt`, which holds the whole output: the + `tsan` job uploads it, and elsewhere the failed test is run again locally. +* A change to Meson's text log format would make the report find no failed test. It then says so, rather than + printing nothing, and `tests/tooling/test_catch2_failure_report.py` pins the format it reads. + +## Links + +* Covered by `tests/tooling/test_catch2_failure_report.py`, which also checks that every workflow's report runs the + script and tails nothing. diff --git a/docs/adr/0878-the-documentation-takes-the-outlined-toggle-brand-colours-and-marks.md b/docs/adr/0878-the-documentation-takes-the-outlined-toggle-brand-colours-and-marks.md new file mode 100644 index 000000000..3c3123498 --- /dev/null +++ b/docs/adr/0878-the-documentation-takes-the-outlined-toggle-brand-colours-and-marks.md @@ -0,0 +1,57 @@ +# The documentation takes the outlined-toggle brand's colours and marks + +* Status: accepted +* Date: 2026-11-24 + +Technical Story: OMG Software's outlined-toggle brand package and its project icons replace the angular four-square +mark and the `#ff8954` orange the documentation site took from the organisation site in ADR-0223. + +## Context and Problem Statement + +The brand package sets two colours, switch orange `#FF761F` and charcoal `#151515`, a full toggle mark, a standalone G +knob for small sizes, and a project icon for each repository: Merovingian's is the toggle with a server stack cut out of +its knob. Its guide keeps about one border-width of clear space round the toggle and uses the knob below about 120 px +wide; the project icons use their compact knob at 32 px and below. How should the documentation site take them on? + +## Decision Drivers + +* The marks are the package's own: a reader should see the same shapes and colours as everywhere else OMG Software + shows them. +* ADR-0223 still holds: dark first, system fonts, nothing fetched from another origin, and text and links that meet + WCAG AA in both schemes. + +## Considered Options + +1. Copy the package's SVG files unchanged into `docs/assets/`, choose each by its size as the guide says, and set the + theme's orange and charcoal to the palette's. +2. Show the full OMG toggle as the header logo. +3. Load the marks from the organisation's site. +4. Use `#FF761F` for links in the light scheme too. + +## Decision Outcome + +Chosen option: 1. + +* The header logo, about 24 px high, is the standalone G knob (`omg-g-knob-orange.svg`): the full toggle there would be + about 50 px wide, well under the guide's 120 px. The favicon is Merovingian's compact knob + (`merovingian-compact.svg`), the project icon's design for 32 px and below. The home page shows Merovingian's full + toggle (`merovingian-toggle-mark.svg`), cropped to keep about one border-width of clear space. +* The README shows no mark. It is shipped on its own, in the CI artifacts, the RPM, BSD and static packages, where an + image path into `docs/assets/` would show as a broken image, and staging the SVG beside every copy is packaging + churn for a decoration. Its opening lines link to the site. +* The files are byte-for-byte the package's, except that the package's CRLF line endings are LF here, as + `.gitattributes` requires; a new version of the package replaces them, and none is edited by hand. + `tests/tooling/test_docs_site.py` checks their outlines and colours and that none can run or fetch anything. +* `--omg-orange` is `#ff761f` and `--omg-ink` `#151515`; the dark scheme's page, header, footer, links and accent use + them. The greys between them are neutral (`#1f1f1f` panels, `#333333` rules), as charcoal is, where the earlier + theme's were tinted. +* The light scheme keeps its darker oranges for links (`#a8461c`) and their hover (`#8f3a15`): `#FF761F` on its + `#f4f3ee` page is about 2.4:1, under AA's 4.5:1. The brand orange stays for buttons, the eyebrow and focus rings. +* Loading the marks from another origin would report each reader's visit to it, which ADR-0223 rules out. + +This supersedes ADR-0223's colours and marks; the rest of ADR-0223 stands. + +### Negative Consequences + +* The dark scheme's orange is a little deeper than before; its links measure about 6.8:1 on the page and 6.2:1 on + cards, still above AA. diff --git a/docs/adr/index.md b/docs/adr/index.md index 836b538ec..4d0869850 100644 --- a/docs/adr/index.md +++ b/docs/adr/index.md @@ -750,3 +750,5 @@ * [0874 - A braced log-field list may mark GCC's cleanup branches excluded from coverage](0874-a-braced-log-field-list-may-mark-gcc-s-cleanup-branches-excluded-from-coverage.md) * [0875 - A device syncing online holds its account online against another device syncing unavailable](0875-a-device-syncing-online-holds-its-account-online.md) * [0876 - The first presence change in a five-second window is kept, and every other one in it is dropped](0876-the-first-presence-change-in-a-five-second-window-is-kept.md) +* [0877 - CI failure reports print each failed test's section of the Meson log, not a tail of the whole log](0877-ci-failure-reports-print-each-failed-test-not-a-tail-of-the-log.md) +* [0878 - The documentation takes the outlined-toggle brand's colours and marks](0878-the-documentation-takes-the-outlined-toggle-brand-colours-and-marks.md) diff --git a/docs/assets/merovingian-compact.svg b/docs/assets/merovingian-compact.svg new file mode 100644 index 000000000..df3102e3b --- /dev/null +++ b/docs/assets/merovingian-compact.svg @@ -0,0 +1,5 @@ + + Merovingian icon + + + diff --git a/docs/assets/merovingian-logo.svg b/docs/assets/merovingian-logo.svg deleted file mode 100644 index ecb21cf65..000000000 --- a/docs/assets/merovingian-logo.svg +++ /dev/null @@ -1 +0,0 @@ -Merovingian diff --git a/docs/assets/merovingian-toggle-mark.svg b/docs/assets/merovingian-toggle-mark.svg new file mode 100644 index 000000000..ac3ea7f1e --- /dev/null +++ b/docs/assets/merovingian-toggle-mark.svg @@ -0,0 +1,5 @@ + + Merovingian icon + + + diff --git a/docs/assets/omg-favicon.svg b/docs/assets/omg-favicon.svg deleted file mode 100644 index 6f11293e1..000000000 --- a/docs/assets/omg-favicon.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/docs/assets/omg-g-knob-orange.svg b/docs/assets/omg-g-knob-orange.svg new file mode 100644 index 000000000..1b5056f45 --- /dev/null +++ b/docs/assets/omg-g-knob-orange.svg @@ -0,0 +1,4 @@ + + OMG Software + + diff --git a/docs/assets/omg-logo.svg b/docs/assets/omg-logo.svg deleted file mode 100644 index 85bf4bb97..000000000 --- a/docs/assets/omg-logo.svg +++ /dev/null @@ -1 +0,0 @@ -OMG Software diff --git a/docs/dev-environment.md b/docs/dev-environment.md index 5337f6e9c..2a695c33e 100644 --- a/docs/dev-environment.md +++ b/docs/dev-environment.md @@ -539,13 +539,19 @@ What the site expects of each branch: - **The theme is OMG Software's.** Colours live in `docs/stylesheets/extra.css`, not in Material palette names; the site opens dark, uses system fonts and loads nothing from another origin - ([ADR-0223](adr/0223-the-documentation-site-wears-the-omg-software-theme-dark-first-with-system-fonts.md)). + ([ADR-0223](adr/0223-the-documentation-site-wears-the-omg-software-theme-dark-first-with-system-fonts.md), + colours from ADR-0878). `docs-site-tooling` checks text and link contrast in both schemes. -- **Use the published brand marks.** `docs/assets/omg-logo.svg` and - `omg-favicon.svg` reproduce the angular OMG mark and favicon from - [OMG Software](https://omg-software.org/projects/merovingian/index.html). - The home page uses its separate `merovingian-logo.svg` project mark. - These SVG files are local, so readers make no request to the organisation site. +- **Use the brand package's marks, unchanged.** OMG Software's outlined-toggle + brand sets switch orange `#FF761F` and charcoal `#151515` + ([ADR-0878](adr/0878-the-documentation-takes-the-outlined-toggle-brand-colours-and-marks.md)). + `docs/assets/` holds verbatim copies of its marks: the header logo is the + standalone G knob (`omg-g-knob-orange.svg`), since the guide uses the knob + below about 120 px wide; the favicon is Merovingian's compact knob + (`merovingian-compact.svg`); the home page shows Merovingian's full toggle + (`merovingian-toggle-mark.svg`). The README shows no mark, since it is + packaged without `docs/assets/`. Replace a file with the package's new version + rather than editing it. They are local, so readers make no request elsewhere. ## Complement diff --git a/docs/index.md b/docs/index.md index abd999752..ba669df68 100644 --- a/docs/index.md +++ b/docs/index.md @@ -2,7 +2,7 @@
- +

OMG SOFTWARE / MEROVINGIAN

diff --git a/docs/stylesheets/extra.css b/docs/stylesheets/extra.css index c99815058..fffde49e6 100644 --- a/docs/stylesheets/extra.css +++ b/docs/stylesheets/extra.css @@ -1,12 +1,13 @@ -/* The OMG Software theme (ADR-0223): the colours, type and shapes of the - organisation's site, laid over Material for MkDocs. Both schemes keep the - dark OMG header; the dark scheme is the one a first visit opens in. */ +/* The OMG Software theme: the outlined-toggle brand's switch orange (#FF761F) + and charcoal (#151515), with neutral greys between them (ADR-0878), laid + over Material for MkDocs (ADR-0223). Both schemes keep the charcoal header; + the dark scheme is the one a first visit opens in. */ :root { - --omg-orange: #ff8954; - --omg-orange-hover: #ffa170; - --omg-ink: #151616; - --omg-paper: #efeee8; + --omg-orange: #ff761f; + --omg-orange-hover: #ff9149; + --omg-ink: #151515; + --omg-paper: #ffffff; --omg-mono: Consolas, "Courier New", monospace; --omg-sans: Arial, Helvetica, sans-serif; --md-text-font: "Arial"; @@ -14,64 +15,64 @@ } [data-md-color-scheme="slate"] { - --omg-panel: #1b1c1b; - --omg-line: #343632; - --md-hue: 80; - --md-default-bg-color: #151616; - --md-default-bg-color--light: #151616b3; - --md-default-bg-color--lighter: #1516164d; - --md-default-bg-color--lightest: #1516161f; - --md-default-fg-color: #efeee8; - --md-default-fg-color--light: #a6a8a0; - --md-default-fg-color--lighter: #777c73; - --md-default-fg-color--lightest: #343632; - --md-primary-fg-color: #151616; - --md-primary-fg-color--light: #1b1c1b; - --md-primary-fg-color--dark: #101111; - --md-primary-bg-color: #efeee8; - --md-primary-bg-color--light: #a6a8a0; - --md-accent-fg-color: #ff8954; - --md-accent-fg-color--transparent: #ff89541a; - --md-accent-bg-color: #191a17; - --md-typeset-a-color: #ff8954; - --md-typeset-color: #efeee8; - --md-typeset-table-color: #343632; - --md-typeset-table-color--light: #1b1c1b; - --md-code-bg-color: #1b1c1b; - --md-code-fg-color: #e0e0d6; - --md-footer-bg-color: #151616; - --md-footer-bg-color--dark: #101111; - --md-footer-fg-color: #efeee8; - --md-footer-fg-color--light: #a6a8a0; - --md-footer-fg-color--lighter: #777c73; + --omg-panel: #1f1f1f; + --omg-line: #333333; + --md-hue: 23; + --md-default-bg-color: #151515; + --md-default-bg-color--light: #151515b3; + --md-default-bg-color--lighter: #1515154d; + --md-default-bg-color--lightest: #1515151f; + --md-default-fg-color: #ededed; + --md-default-fg-color--light: #a8a8a8; + --md-default-fg-color--lighter: #7a7a7a; + --md-default-fg-color--lightest: #333333; + --md-primary-fg-color: #151515; + --md-primary-fg-color--light: #1f1f1f; + --md-primary-fg-color--dark: #0f0f0f; + --md-primary-bg-color: #ffffff; + --md-primary-bg-color--light: #a8a8a8; + --md-accent-fg-color: #ff761f; + --md-accent-fg-color--transparent: #ff761f1a; + --md-accent-bg-color: #151515; + --md-typeset-a-color: #ff761f; + --md-typeset-color: #ededed; + --md-typeset-table-color: #333333; + --md-typeset-table-color--light: #1f1f1f; + --md-code-bg-color: #1f1f1f; + --md-code-fg-color: #e0e0e0; + --md-footer-bg-color: #151515; + --md-footer-bg-color--dark: #0f0f0f; + --md-footer-fg-color: #ffffff; + --md-footer-fg-color--light: #a8a8a8; + --md-footer-fg-color--lighter: #7a7a7a; } [data-md-color-scheme="default"] { --omg-panel: #e9e8e1; --omg-line: #d6d5cc; --md-default-bg-color: #f4f3ee; - --md-default-fg-color: #151616; + --md-default-fg-color: #151515; --md-default-fg-color--light: #55574f; --md-default-fg-color--lighter: #8a8c83; --md-default-fg-color--lightest: #d6d5cc; - --md-primary-fg-color: #151616; - --md-primary-fg-color--light: #1b1c1b; - --md-primary-fg-color--dark: #101111; - --md-primary-bg-color: #efeee8; - --md-primary-bg-color--light: #a6a8a0; + --md-primary-fg-color: #151515; + --md-primary-fg-color--light: #1f1f1f; + --md-primary-fg-color--dark: #0f0f0f; + --md-primary-bg-color: #ffffff; + --md-primary-bg-color--light: #a8a8a8; --md-accent-fg-color: #8f3a15; --md-accent-fg-color--transparent: #8f3a151a; --md-accent-bg-color: #f4f3ee; --md-typeset-a-color: #a8461c; - --md-typeset-color: #151616; + --md-typeset-color: #151515; --md-typeset-table-color: #d6d5cc; --md-code-bg-color: #e9e8e1; --md-code-fg-color: #2a2b28; - --md-footer-bg-color: #151616; - --md-footer-bg-color--dark: #101111; - --md-footer-fg-color: #efeee8; - --md-footer-fg-color--light: #a6a8a0; - --md-footer-fg-color--lighter: #777c73; + --md-footer-bg-color: #151515; + --md-footer-bg-color--dark: #0f0f0f; + --md-footer-fg-color: #ffffff; + --md-footer-fg-color--light: #a8a8a8; + --md-footer-fg-color--lighter: #7a7a7a; } ::selection { @@ -84,7 +85,7 @@ outline-offset: 3px; } -/* Header and tabs: the OMG site's dark bar with a hairline rule. */ +/* Header and tabs: the charcoal bar with a hairline rule. */ .md-header, .md-tabs { @@ -94,11 +95,11 @@ .md-header { box-shadow: none; - border-bottom: 1px solid #343632; + border-bottom: 1px solid #333333; } .md-tabs { - border-bottom: 1px solid #343632; + border-bottom: 1px solid #333333; } .md-header__topic:first-child { @@ -119,7 +120,7 @@ } .md-footer { - border-top: 1px solid #343632; + border-top: 1px solid #333333; } /* Type: tight, light headings as on the OMG site. */ @@ -166,14 +167,14 @@ .md-typeset .md-button--primary { background-color: var(--omg-orange); border-color: var(--omg-orange); - color: #191a17; + color: var(--omg-ink); } .md-typeset .md-button--primary:focus, .md-typeset .md-button--primary:hover { background-color: var(--omg-orange-hover); border-color: var(--omg-orange-hover); - color: #191a17; + color: var(--omg-ink); } /* Home page hero: the OMG eyebrow label above the strapline. */ @@ -186,10 +187,14 @@ margin-bottom: .25rem; } +/* Merovingian's full toggle. Its square file has wide empty bands above and + below the toggle; the crop keeps about one border-width of clear space round + it, as the brand guide asks. */ .md-typeset .merovingian-mark { display: block; - width: 4.8rem; - height: 4.8rem; + width: 9.6rem; + height: 5.6rem; + object-fit: cover; margin-bottom: 1.2rem; } diff --git a/docs/testing-standards.md b/docs/testing-standards.md index 86ab6c4f6..22a9ac877 100644 --- a/docs/testing-standards.md +++ b/docs/testing-standards.md @@ -408,7 +408,13 @@ Never list `MEROVINGIAN_TEST_FEDERATION_WORKER is not defined`: on CI that skip the `asan-ubsan` job (`-Db_sanitize=address,undefined`) catches memory and undefined-behaviour defects, and the `tsan` job (`-Db_sanitize=thread`) catches data races. ThreadSanitizer is the only sanitizer that detects data - races; ASan and UBSan are blind to them. + races; ASan and UBSan are blind to them. When the suite fails, each job's + "Catch2 failure report" step prints each failed test's Catch2 output from + `testlog.txt` (`scripts/catch2-failure-report.sh`, ADR-0877); read it there, + not in the tail of the build step. It caps each test at its first 400 and + last 100 lines and the report at 4000, so it can leave out an assertion: it + says how many lines and tests it left out, and then the whole output is in + `testlog.txt` (uploaded by the `tsan` job; elsewhere, run the test locally). - Any type shared across threads at runtime must have a test that exercises `perform`/`run`/dispatch concurrently from multiple threads so TSan can check the exercised accesses for data races. A thread-safety claim in a header comment is diff --git a/mkdocs.yml b/mkdocs.yml index 1126a4a6a..0369f1973 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -52,7 +52,7 @@ theme: - content.action.edit # The OMG Software theme: the site opens dark, as the organisation's site # does, whatever the system preference; the toggle offers a light scheme. - # Both take their colours from stylesheets/extra.css (ADR-0223). + # Both take their colours from stylesheets/extra.css (ADR-0223, ADR-0878). palette: - scheme: slate primary: custom @@ -68,8 +68,11 @@ theme: name: Switch to dark mode # System fonts only, so no page view is reported to a font host. font: false - logo: assets/omg-logo.svg - favicon: assets/omg-favicon.svg + # The OMG Software outlined-toggle brand (ADR-0878): the header shows the + # standalone G knob, which the guide uses below about 120 px wide, and the + # browser tab Merovingian's compact knob, its project icon's small size. + logo: assets/omg-g-knob-orange.svg + favicon: assets/merovingian-compact.svg icon: repo: fontawesome/brands/github diff --git a/scripts/AGENTS.md b/scripts/AGENTS.md index fba898011..5cc2e2c7e 100644 --- a/scripts/AGENTS.md +++ b/scripts/AGENTS.md @@ -23,6 +23,7 @@ called by it rather than directly. | `ci-openbsd-pkg-add.sh` | CI only: `ci-openbsd-pkg-add.sh --require "command ..." [--require-pkg-config "module ..."] package ...` installs packages in the vmactions OpenBSD VMs, three tries through `cdn.openbsd.org` then three through `ftp.openbsd.org` (`PKG_PATH` for the VM's release and architecture). Judges each try by whether every `--require` command is on `PATH` and every `--require-pkg-config` module passes `pkg-config --exists`, because `pkg_add` exits 0 having installed nothing; fails naming what is missing (ADR-0650). Both OpenBSD jobs run it from `prepare`, which vmactions runs in the synced checkout. Covered by `tests/tooling/test_ci_workflow.py` against a fake `pkg_add` | | `check-catch2-bdd-tests.sh` | Rejects unit test files that use `TEST_CASE`, use comment-only Given/When/Then markers, or lack any of `SCENARIO`/`GIVEN`/`WHEN`/`THEN` (`test_main.cpp` exempt). One `awk` pass over all files: run per file it timed out on the OpenBSD VM. Covered by `tests/tooling/test_check_catch2_bdd.py` | | `check_expected_skips.py` | CI skip gate (ADR-0546): reads the XML reports the Catch2 binaries write when `MEROVINGIAN_CATCH_REPORT_DIR` is set and fails on any skipped test case that `tests/expected_skips.json` does not list for the `--job`. Exit 0 ok, 1 unexpected skip (or a stale entry with `--strict-stale`), 2 unusable input (no report, truncated report, bad list, unknown job). `` is a key of the `jobs` object in `tests/expected_skips.json`. `build-linux.sh` and `build-bsd.sh` run it after the suite when given `--skip-job `; `build-wsl.sh` has no `--skip-job`, and `build.py vm` passes none, so WSL and VM runs are not skip-gated; `build-bsd.sh` runs it with `python3`, else the interpreter in `meson`'s shebang, else a `python3.N` on `PATH` (FreeBSD and NetBSD install only a versioned Python, as meson's dependency), and fails the gate when it finds none. Covered by `tests/tooling/test_expected_skips.py` | +| `catch2-failure-report.sh` | CI only: `catch2-failure-report.sh [--exclude ERE] TESTLOG` prints, from a Meson `testlog.txt`, the section of each test whose `result:` is neither `exit status 0` nor `exit status 77` (a skip), without the runtime log lines, so each failed Catch2 case shows whatever ran after it; a tail of the whole log lost an early failure (ADR-0877). Each test prints at most its first 400 and last 100 lines, and the whole report, summary included, at most 4000: a test that does not fit is cut further or counted as not shown (`CATCH2_REPORT_HEAD_LINES`, `_TAIL_LINES`, `_TOTAL_LINES`). The caps can leave out an assertion; the report counts every gap and names the log. Says so and exits 0 when there is no log or no failed test; exit 2 for bad arguments, a cap that is not a whole number, or a total under 20 (the summary and one cut test). POSIX `sh` and `awk` without interval expressions, so it runs in every Linux container and BSD VM. Every workflow's "Catch2 failure report" runs it; covered by `tests/tooling/test_catch2_failure_report.py`, which also checks that every workflow's report runs it and tails nothing | | `check-conformance-gate.sh` | Runs `meson test conformance-tests --print-errorlogs` in the build directory given as its argument (default `build`) and fails if that suite fails or the directory is missing. It does not detect a removed or commented-out test; CI runs it after each build | | `check-elf-hardening.sh` | Build-time hardening gate: inspects a built ELF binary's headers with `readelf` and fails if PIE (`ET_DYN`), `PT_GNU_RELRO`, `DT_BIND_NOW`, or a non-executable stack (`PT_GNU_STACK` without `E`) is missing; the CI-time counterpart to the runtime self-check in `src/platform/`, since that check can only run inside a live, correctly-privileged `merovingian-server` process. Pass `--static` for the static-PIE binary, which has no `PT_DYNAMIC` section to apply `BIND_NOW` to. Accepts both GNU binutils' and the BSDs' elftoolchain `readelf` output, and uses POSIX ERE only (ADR-0757). Covered by `tests/tooling/test_check_elf_hardening.py` against a fake `readelf` | | `check-startup-hardening-gate.sh` | Runtime counterpart to `check-elf-hardening.sh` for shipped artifacts (audit OPS-5): boots a packaged `merovingian-server` against a throwaway loopback SQLite config with a fresh 0400 master key, and passes only when every `Hardening self-check:` line is `enabled`, their count matches `Startup hardening checks: N`, readiness is `ready=true blockers=0`, the federation worker is spawned and still up `--worker-settle` seconds (3) later, and the server exits 0 on `SIGTERM`. Run it as the unprivileged service user with an empty capability bounding set. Leaves the worker path to the binary's libexec default unless `--federation-worker` is given. Off Linux it sets `federation.worker.apply_hardening=false`, because the worker's in-process sandbox exists only on Linux. Run by the `deb`, `debian-pkg`, `rpm`, `freebsd-pkg` and `docker-image` jobs in `packages.yml`; covered by `tests/tooling/test_startup_hardening_gate.py` | diff --git a/scripts/catch2-failure-report.sh b/scripts/catch2-failure-report.sh new file mode 100755 index 000000000..9cd60ecbf --- /dev/null +++ b/scripts/catch2-failure-report.sh @@ -0,0 +1,175 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-3.0-or-later +# +# catch2-failure-report.sh [--exclude ERE] TESTLOG +# +# Prints, from a Meson testlog.txt, the output of every test that did not pass, +# with the homeserver's runtime log lines removed, so what remains is each +# failed Catch2 case: its scenario header, file and line, FAILED:, the +# expansion and any exception message, then the run's totals. CI runs it when a +# build-and-test step fails (ADR-0877). +# +# A tail of the whole log is not enough: Meson writes tests in the order they +# finish, so the smoke tests that run after an early integration shard push its +# failure out of any fixed number of trailing lines. +# +# Meson starts each test with a "==== N/M ====" banner and ends it with a line +# of exactly 78 "=" (78 "-" in older Meson; Catch2's own rules are 79 wide, so +# neither is mistaken for the other). A test failed unless its +# "result:" is "exit status 0", or "exit status 77", which Meson reads as a +# skip. Each failed test prints at most the first HEAD_LINES of its filtered +# output and its last TAIL_LINES, and the whole report at most TOTAL_LINES: a +# test that does not fit is cut further, or counted as not shown. Lines left out +# can hold an assertion, so the report says how many and where the full log is. +# --exclude drops more lines (an extended regular expression), as the NetBSD +# job does for its [netbsd-diag] markers. POSIX sh and awk only, with no +# interval expressions, so it runs as is on the BSD VMs and in every container. + +set -eu + +exclude='' +while [ $# -gt 0 ]; do + case "$1" in + --exclude) + [ $# -ge 2 ] || { echo "catch2-failure-report.sh: --exclude needs a pattern" >&2; exit 2; } + exclude=$2 + shift 2 + ;; + --) + shift + break + ;; + -*) + echo "catch2-failure-report.sh: unknown option $1" >&2 + exit 2 + ;; + *) + break + ;; + esac +done +if [ $# -ne 1 ]; then + echo "usage: catch2-failure-report.sh [--exclude ERE] TESTLOG" >&2 + exit 2 +fi +testlog=$1 + +head_lines=${CATCH2_REPORT_HEAD_LINES:-400} +tail_lines=${CATCH2_REPORT_TAIL_LINES:-100} +total_lines=${CATCH2_REPORT_TOTAL_LINES:-4000} +for cap in "$head_lines" "$tail_lines" "$total_lines"; do + case "$cap" in + '' | *[!0-9]*) + echo "catch2-failure-report.sh: a line cap must be a whole number, not '$cap'" >&2 + exit 2 + ;; + esac +done +# The smallest total that holds the closing summary (3 lines) and one test cut to +# its fewest lines (10, its 4 markers and the omission note), so no cap is broken. +if [ "$total_lines" -lt 20 ]; then + echo "catch2-failure-report.sh: CATCH2_REPORT_TOTAL_LINES must be at least 20, not $total_lines" >&2 + exit 2 +fi + +if [ ! -f "$testlog" ]; then + printf 'No test log at %s: meson test did not run, so read the failed step above.\n' "$testlog" + exit 0 +fi + +REPORT_TESTLOG=$testlog \ +EXCLUDE_ERE=$exclude \ +HEAD_LINES=$head_lines \ +TAIL_LINES=$tail_lines \ +TOTAL_LINES=$total_lines \ + awk ' +function is_rule(line, ch) { + if (length(line) != 78) return 0 + return (ch == "=" && line ~ /^=+$/) || (ch == "-" && line ~ /^-+$/) +} +function is_runtime_log(line) { + # 2026-11-24 10:00:00.123456 +0000 module: message + return line ~ /^[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9]+ \+[0-9][0-9][0-9][0-9] <(INFO|WARNING|ERROR|DEBUG|CRITICAL)>/ +} +function out(line) { + print line + printed++ +} +function finish_test( i, first_tail, per_test, room, body, head, tail) { + if (!inside) return + inside = 0 + if (result == "exit status 0" || result == "exit status 77") return + failed++ + # The lines left for the output of this test once its own markers (a blank line, FAILED, the command and the + # end line) and the closing summary are counted, so the report never passes TOTAL_LINES. + room = total_cap - SUMMARY_LINES - printed - 3 - (command != "" ? 1 : 0) + per_test = head_cap + tail_cap + if (n <= per_test && n <= room) { + head = n + tail = 0 + } else { + # Cut: one line goes to the note that counts what was left out. + body = per_test < room - 1 ? per_test : room - 1 + if (body < MIN_CUT_LINES && body < per_test) { + unshown++ + return + } + head = per_test > 0 ? int(body * head_cap / per_test) : 0 + tail = body - head + } + out("") + out("########## FAILED " name " (" result ", " duration ")") + if (command != "") out("command: " command) + for (i = 1; i <= head; i++) out(buf[i]) + if (head + tail < n) { + first_tail = n - tail + 1 + out("[... " (first_tail - head - 1) " lines omitted; the full output is in " testlog " ...]") + for (i = first_tail; i <= n; i++) out(buf[i]) + } + out("########## end of " name) +} +BEGIN { + # Read from the environment, not -v, which would process backslash escapes. + testlog = ENVIRON["REPORT_TESTLOG"] + exclude = ENVIRON["EXCLUDE_ERE"] + head_cap = ENVIRON["HEAD_LINES"] + 0 + tail_cap = ENVIRON["TAIL_LINES"] + 0 + total_cap = ENVIRON["TOTAL_LINES"] + 0 + inside = 0; failed = 0; printed = 0; unshown = 0 + # The closing summary: a blank line, the count, and the not-shown count. + SUMMARY_LINES = 3 + # A test cut to fewer lines than this by the total cap is counted as not shown instead. + MIN_CUT_LINES = 10 +} +{ sub(/\r$/, "") } +length($0) == 78 && /^=+ [0-9]+\/[0-9]+ =+$/ { + finish_test() + inside = 1; n = 0; name = "(unnamed test)"; result = ""; duration = ""; command = "" + in_header = 1 + next +} +!inside { next } +is_rule($0, "=") || is_rule($0, "-") { + finish_test() + next +} +in_header && /^test: / { name = substr($0, 15); next } +in_header && /^result: / { result = substr($0, 15); next } +in_header && /^duration: / { duration = substr($0, 15); next } +in_header && /^command: / { command = substr($0, 15); next } +in_header && /^start time: / { next } +/^-+ (stdout|output|stderr) -+$/ { in_header = 0; buf[++n] = $0; next } +is_runtime_log($0) { next } +exclude != "" && $0 ~ exclude { next } +{ buf[++n] = $0 } +END { + finish_test() + if (failed == 0) { + print "No failed test in " testlog "; Meson failed before or outside a test (read the step above)." + } else { + print "" + print failed " failed test(s) in " testlog "." + if (unshown > 0) print unshown " of them not shown: the report reached " total_cap " lines." + } +} +' "$testlog" diff --git a/tests/meson.build b/tests/meson.build index 0f1970d2d..b9b998930 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -34,6 +34,12 @@ shell = find_program('sh') args: [meson.project_source_root() / 'tests' / 'tooling' / 'test_check_unit_test_isolation.py'], ) + test( + 'catch2-failure-report-tooling', + python, + args: [meson.project_source_root() / 'tests' / 'tooling' / 'test_catch2_failure_report.py'], + ) + logger_filter_fixture = executable( 'logger-filter-fixture', 'tooling/logger_filter_fixture.cpp', diff --git a/tests/tooling/test_catch2_failure_report.py b/tests/tooling/test_catch2_failure_report.py new file mode 100755 index 000000000..83059fc10 --- /dev/null +++ b/tests/tooling/test_catch2_failure_report.py @@ -0,0 +1,278 @@ +#!/usr/bin/env python3 +"""Behaviour of scripts/catch2-failure-report.sh, the CI failure report (ADR-0877). + +The report must show every failed test's Catch2 output, however early the test ran and however much passing +output Meson wrote after it, with the runtime log lines removed; skip a passing or skipped (exit 77) test; cap +its size; and every workflow's failure report must use it rather than a tail of the whole log. +""" +from __future__ import annotations + +import os +import re +import shutil +import subprocess +import tempfile +import unittest +from pathlib import Path + +REPO_ROOT = Path(__file__).resolve().parents[2] +SCRIPT = REPO_ROOT / "scripts" / "catch2-failure-report.sh" +WORKFLOWS = REPO_ROOT / ".github" / "workflows" +LOG_LINE = "2026-11-24 10:00:00.123456 +0000 <{level}> sync: a runtime line {index}" +CATCH2_FAILURE = """\ +------------------------------------------------------------------------------- +Scenario: presence settles after two devices flip + Given: two devices of one user + When: both report online then offline + Then: one presence change is federated +------------------------------------------------------------------------------- +/src/tests/integration/test_presence_flow.cpp:120 +............................................................................... + +/src/tests/integration/test_presence_flow.cpp:141: FAILED: + REQUIRE( sent.size() == 1 ) +with expansion: + 2 == 1 + +=============================================================================== +test cases: 418 | 417 passed | 1 failed +assertions: 9000 | 8999 passed | 1 failed +""" + + +def banner(number: int, total: int) -> str: + title = f" {number}/{total} " + first = (78 - len(title)) // 2 + return "=" * first + title + "=" * (78 - first - len(title)) + + +def section(number: int, total: int, name: str, result: str, output: str) -> str: + stdout = "-" * 35 + " output " + "-" * 35 + return ( + f"{banner(number, total)}\n" + f"test: {name}\n" + "start time: 10:00:00\n" + "duration: 12.34s\n" + f"result: {result}\n" + f"command: MALLOC_PERTURB_=1 /build/tests/{name}\n" + f"{stdout}\n{output}" + f"{'=' * 78}\n\n" + ) + + +def runtime_lines(count: int) -> str: + levels = ("INFO", "WARNING", "ERROR", "DEBUG", "CRITICAL") + return "".join(LOG_LINE.format(level=levels[i % len(levels)], index=i) + "\n" for i in range(count)) + + +@unittest.skipIf(shutil.which("sh") is None or shutil.which("awk") is None, "needs sh and awk") +class TheFailureReport(unittest.TestCase): + def setUp(self) -> None: + self.directory = tempfile.TemporaryDirectory() + self.testlog = Path(self.directory.name) / "testlog.txt" + + def tearDown(self) -> None: + self.directory.cleanup() + + def run_report(self, *arguments: str, env: dict[str, str] | None = None) -> subprocess.CompletedProcess[str]: + return subprocess.run( + ["sh", str(SCRIPT), *arguments], + capture_output=True, + text=True, + timeout=60, + check=False, + env={**os.environ, **(env or {})}, + ) + + def test_given_an_early_failure_followed_by_many_passing_tests_then_its_catch2_case_is_shown(self) -> None: + # GIVEN integration shard 1 fails first, with its failure among runtime log lines, and 60 smoke tests + # pass after it with hundreds of lines each, as in the asan-ubsan run whose failure no report showed. + failing = runtime_lines(500) + CATCH2_FAILURE + runtime_lines(50) + passing = "".join( + section(n, 61, f"smoke-{n}", "exit status 0", f"line {n}\n" * 400) for n in range(2, 62) + ) + self.testlog.write_text( + "Log of Meson test suite run\n\n" + + section(1, 61, "integration-tests-shard-1-of-4", "exit status 1", failing) + + passing + + "\nSummary of Failures:\n\n 1/61 integration-tests-shard-1-of-4 FAIL\n\nOk: 60\nFail: 1\n", + encoding="utf-8", + ) + + # WHEN the report is printed + completed = self.run_report(str(self.testlog)) + + # THEN it shows the whole Catch2 case of the failed test and nothing of the runtime log or passing tests + self.assertEqual(completed.returncode, 0, completed.stderr) + report = completed.stdout + self.assertIn("FAILED integration-tests-shard-1-of-4 (exit status 1, 12.34s)", report) + for expected in ( + "Scenario: presence settles after two devices flip", + "/src/tests/integration/test_presence_flow.cpp:120", + "/src/tests/integration/test_presence_flow.cpp:141: FAILED:", + " REQUIRE( sent.size() == 1 )", + "with expansion:", + " 2 == 1", + "test cases: 418 | 417 passed | 1 failed", + ): + self.assertIn(expected, report) + self.assertNotIn("a runtime line", report) + self.assertNotIn("smoke-", report) + self.assertIn("1 failed test(s)", report) + + def test_given_a_skipped_test_and_a_crashed_test_then_only_the_crash_is_reported(self) -> None: + # GIVEN a test Meson skipped (exit 77) and one killed by a signal + self.testlog.write_text( + section(1, 2, "postgresql-flow", "exit status 77", "SKIPPED: no PostgreSQL\n") + + section(2, 2, "unit-tests", "killed by signal 6 SIGABRT", "==123==ERROR: AddressSanitizer\n"), + encoding="utf-8", + ) + + # WHEN the report is printed + report = self.run_report(str(self.testlog)).stdout + + # THEN the crash and its sanitizer output are shown and the skip is not + self.assertIn("FAILED unit-tests (killed by signal 6 SIGABRT", report) + self.assertIn("==123==ERROR: AddressSanitizer", report) + self.assertNotIn("postgresql-flow", report) + + def test_given_a_long_failed_output_then_its_head_and_tail_are_kept_within_the_caps(self) -> None: + # GIVEN a failed test with 1000 lines of its own output, and a second with 100 after it + output = "".join(f"catch2 line {i}\n" for i in range(1000)) + second = "".join(f"second line {i}\n" for i in range(100)) + self.testlog.write_text( + section(1, 2, "first", "exit status 1", output) + section(2, 2, "second", "exit status 1", second), + encoding="utf-8", + ) + + # WHEN the report runs with 10 head lines, 5 tail lines and a 30-line total + report = self.run_report( + str(self.testlog), + env={ + "CATCH2_REPORT_HEAD_LINES": "10", + "CATCH2_REPORT_TAIL_LINES": "5", + "CATCH2_REPORT_TOTAL_LINES": "30", + }, + ).stdout + + # THEN the first test shows its first and last lines with the gap counted, the second, which would + # take the report past its total, is counted but not shown, and the report stays within 30 lines + self.assertIn("catch2 line 8\n", report) + self.assertIn("catch2 line 999\n", report) + self.assertNotIn("catch2 line 500\n", report) + self.assertIn("lines omitted", report) + self.assertNotIn("FAILED second", report) + self.assertIn("2 failed test(s)", report) + self.assertIn("1 of them not shown", report) + self.assertLessEqual(len(report.splitlines()), 30) + + def test_given_many_long_failed_tests_then_the_whole_report_stays_within_its_default_total(self) -> None: + # GIVEN nine failed tests of 1000 lines each, each of which alone fills its 505-line share + output = "".join(f"catch2 line {i}\n" for i in range(1000)) + self.testlog.write_text( + "".join(section(n, 9, f"shard-{n}", "exit status 1", output) for n in range(1, 10)), encoding="utf-8" + ) + + # WHEN the report runs with its default caps + report = self.run_report(str(self.testlog)).stdout + + # THEN the eighth test is cut to fit, the ninth is counted but not shown, and the whole report, + # summary included, is at most 4000 lines + self.assertLessEqual(len(report.splitlines()), 4000) + self.assertIn("FAILED shard-8 ", report) + self.assertNotIn("FAILED shard-9 ", report) + self.assertIn("9 failed test(s)", report) + self.assertIn("1 of them not shown", report) + + def test_given_an_exclude_pattern_then_matching_lines_are_dropped(self) -> None: + # GIVEN a failed test whose output holds NetBSD diagnostic markers + self.testlog.write_text( + section(1, 1, "unit-tests", "exit status 1", "[netbsd-diag] fd 3\nFAILED:\n"), encoding="utf-8" + ) + + # WHEN the report drops them + report = self.run_report("--exclude", r"^\[netbsd-diag\]", str(self.testlog)).stdout + + # THEN only the Catch2 line is left + self.assertIn("FAILED:", report) + self.assertNotIn("netbsd-diag", report) + + def test_given_no_log_or_no_failed_test_then_it_says_so_and_succeeds(self) -> None: + # GIVEN no log, then a log in which every test passed + missing = self.run_report(str(self.testlog)) + self.testlog.write_text(section(1, 1, "unit-tests", "exit status 0", "ok\n"), encoding="utf-8") + passed = self.run_report(str(self.testlog)) + + # THEN each run says why there is nothing to show, and neither fails the step + self.assertEqual((missing.returncode, passed.returncode), (0, 0)) + self.assertIn("No test log at", missing.stdout) + self.assertIn("No failed test in", passed.stdout) + + def test_given_bad_arguments_then_it_refuses(self) -> None: + self.assertEqual(self.run_report().returncode, 2) + self.assertEqual(self.run_report("--exclude").returncode, 2) + self.assertEqual(self.run_report("--bogus", str(self.testlog)).returncode, 2) + + def test_given_a_cap_it_cannot_keep_then_it_refuses_before_reading_the_log(self) -> None: + # GIVEN a log with a failed test + self.testlog.write_text(section(1, 1, "unit-tests", "exit status 1", "FAILED:\n"), encoding="utf-8") + + # WHEN a total below the summary and one cut test, or a cap that is not a whole number, is asked for + for variable, value in ( + ("CATCH2_REPORT_TOTAL_LINES", "1"), + ("CATCH2_REPORT_TOTAL_LINES", "19"), + ("CATCH2_REPORT_TOTAL_LINES", "-5"), + ("CATCH2_REPORT_HEAD_LINES", "abc"), + ("CATCH2_REPORT_TAIL_LINES", "1.5"), + ): + with self.subTest(variable=variable, value=value): + completed = self.run_report(str(self.testlog), env={variable: value}) + # THEN it refuses, printing no report + self.assertEqual(completed.returncode, 2) + self.assertEqual(completed.stdout, "") + + # AND the smallest total it accepts holds, summary included + completed = self.run_report(str(self.testlog), env={"CATCH2_REPORT_TOTAL_LINES": "20"}) + self.assertEqual(completed.returncode, 0, completed.stderr) + self.assertIn("FAILED unit-tests", completed.stdout) + self.assertLessEqual(len(completed.stdout.splitlines()), 20) + + +class TheWorkflows(unittest.TestCase): + def test_every_catch2_failure_report_uses_the_script_and_none_tails_the_whole_log(self) -> None: + # GIVEN every workflow + reports = 0 + for workflow in sorted(WORKFLOWS.glob("*.yml")): + text = workflow.read_text(encoding="utf-8") + # WHEN each Catch2 failure report in it is read + for match in re.finditer(r"Catch2 failure report[^\n]*\n((?:.*\n){0,12})", text): + reports += 1 + # THEN it runs the script and tails nothing, since a tail drops an early test's failure + self.assertIn("scripts/catch2-failure-report.sh", match.group(1), workflow.name) + self.assertNotIn("tail -n", match.group(1), workflow.name) + self.assertGreaterEqual(reports, 12) + + def test_every_job_with_a_failure_report_runs_meson_test(self) -> None: + # A build script runs meson test unless it is given --no-tests; any step may also run it itself. + runs_tests = re.compile(r"scripts/build-(?:linux|bsd)\.sh(?![^\n]*--no-tests)|\bmeson test\b") + # GIVEN every job of every workflow + for workflow in sorted(WORKFLOWS.glob("*.yml")): + text = workflow.read_text(encoding="utf-8") + jobs = re.split(r"\n (?=[\w-]+:\n)", text.split("\njobs:\n", 1)[-1]) + for job in jobs: + # WHEN the job has a Catch2 failure report + if "catch2-failure-report.sh" not in job: + continue + # THEN some step of it runs meson test, which writes the testlog.txt the report reads; without + # one, the report could only say there is no log + with self.subTest(workflow=workflow.name, job=job.split(":", 1)[0]): + self.assertRegex(job, runs_tests) + + def test_both_sanitizer_jobs_report_their_failures(self) -> None: + workflow = (WORKFLOWS / "sanitizers.yml").read_text(encoding="utf-8") + self.assertIn("sh scripts/catch2-failure-report.sh build/meson-logs/testlog.txt", workflow) + self.assertIn("sh scripts/catch2-failure-report.sh build-tsan/meson-logs/testlog.txt", workflow) + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/tooling/test_docs_site.py b/tests/tooling/test_docs_site.py index 8dc5912c3..de23be9a7 100644 --- a/tests/tooling/test_docs_site.py +++ b/tests/tooling/test_docs_site.py @@ -296,31 +296,57 @@ def test_logo_and_favicon_are_inert_svg_files_in_the_site(self) -> None: self.assertTrue(svg.startswith(" None: - # GIVEN the marks published on omg-software.org on 25 October 2026. + def test_site_uses_the_outlined_toggle_brand_marks(self) -> None: + # GIVEN the OMG Software outlined-toggle brand package and its Merovingian project icon (ADR-0878): + # each file's switch-orange shapes, how many there are, and the start of the first outline. + svg = "{http://www.w3.org/2000/svg}" marks = { - "omg-logo.svg": "M32 11 20 4 6 12v16l14 8 14-8v-8H21", - "omg-favicon.svg": "M36 15 24 8 10 16v16l14 8 14-8v-8H25", - "merovingian-logo.svg": "M6 28V12l14 11 14-11v16l-14 8-14-8Z", + # The standalone G knob, for the header logo. + "omg-g-knob-orange.svg": (1, "M1059 369C1140 369 1205 432", None), + # The project's compact knob on a charcoal tile, for the browser tab. + "merovingian-compact.svg": (1, "M64 32A32 32 0 1 1 0 32", "#151515"), + # The project's full toggle, transparent, for the home page. + "merovingian-toggle-mark.svg": (2, "M39 35H89A29 29 0 0 1 89 93H39", None), } - for filename, outline in marks.items(): + for filename, (count, outline, tile) in marks.items(): with self.subTest(asset=filename): # WHEN the local image is loaded. - root = ET.parse(DOCS_DIR / "assets" / filename).getroot() - paths = root.findall("{http://www.w3.org/2000/svg}path") - - # THEN it carries the published outline and orange stroke. - self.assertEqual(len(paths), 1) - self.assertEqual(paths[0].get("d"), outline) - self.assertEqual(paths[0].get("stroke"), "#ff8954") - self.assertNotRegex( - (DOCS_DIR / "assets" / filename).read_text(encoding="utf-8"), - r"(?i)]*\ssrc=\"(?!https://)") + self.assertNotRegex(readme, r"!\[[^\]]*\]\((?!https://)") + + def test_the_theme_uses_the_brand_orange_and_charcoal(self) -> None: + # GIVEN the brand palette: switch orange #FF761F and charcoal #151515 (ADR-0878). + # WHEN the stylesheet's own tokens and the dark scheme are read. + dark = scheme_colours(self.stylesheet, "slate") + + # THEN the theme's orange and ink are the brand's, the dark scheme's page, header and links use them, + # and no colour of the earlier OMG theme is left. + self.assertRegex(self.stylesheet, r"--omg-orange:\s*#ff761f;") + self.assertRegex(self.stylesheet, r"--omg-ink:\s*#151515;") + self.assertEqual(dark["--md-default-bg-color"], "#151515") + self.assertEqual(dark["--md-primary-fg-color"], "#151515") + self.assertEqual(dark["--md-typeset-a-color"], "#ff761f") + self.assertNotRegex(self.stylesheet.lower(), r"#ff8954|#151616") def test_text_and_links_are_readable_in_both_schemes(self) -> None: for scheme in ("slate", "default"):