Skip to content

Run the documentation examples, not only compile them - #596

Merged
godofecht merged 1 commit into
mainfrom
doc-examples-run
Aug 19, 2026
Merged

godofecht merged 1 commit into
mainfrom
doc-examples-run

Conversation

@godofecht

@godofecht godofecht commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Why

Compiling proves an example is well-formed. It does not prove it works. Two bugs found this week compiled cleanly and were wrong at runtime:

Both were found by running the examples by hand. This makes that a gate instead of something I happened to try.

What counts as a failure

--run builds and executes every complete program.

Outcome Verdict Why
crash (SIGSEGV, SIGABRT, SIGBUS, SIGFPE, SIGILL) failure never intended
no exit within 10s failure never intended
ordinary non-zero exit pass docs/book/01-a-complete-program.md returns 2 to show a failure path
link error not reported the syntax-only stage never looked for those symbols, so it is not a regression in the example

It lands green

352 programs run, 0 crashes and 0 hangs. This holds the line rather than opening a backlog. Unverified stays at 221, identical to the compile-only run.

Verified against injected failures rather than only against the current tree:

segv     unverified   run    crashed with SIGSEGV
hang     unverified   run    did not finish within 2s
clean    verified     -
exit 2   verified     -

CI

Its own job rather than part of the compile gate, because it takes about two minutes and answers a different question. Same path filters, so a docs-only change still triggers it.

Verification

Check Result
check_doc_examples.py --run --check-ledger no new unverified, 221
pytest tests/unit/test_doc_example_run_stage.py 5 passed
ruff check clean

Compiling proves an example is well-formed. It does not prove it works.
Two bugs found this week compiled cleanly and were wrong at runtime:

  #594  a defer freed memory before the return value was read, so
        docs/book/10-memory-and-lifetimes.md exited 216 instead of 0
  #573  a function returning array<T, N> handed back a pointer into its own
        dead frame, so lib/stdlib/audio/scales.flow returned garbage

Both were found by running these examples by hand. This makes that a gate.

`--run` builds and executes every complete program. A crash or a hang is a
failure; an ordinary non-zero exit is not, because a doc example may return
one on purpose (docs/book/01-a-complete-program.md returns 2 to show a
failure path). Linking failures are not reported either: the syntax-only
stage never looked for those symbols, so they are not a regression in the
example.

352 programs run, 0 crashes and 0 hangs, so this lands green and holds the
line rather than opening a backlog. It costs about two minutes, so it is its
own CI job instead of joining the compile gate.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht merged commit 3ba8464 into main Aug 19, 2026
20 checks passed
@godofecht
godofecht deleted the doc-examples-run branch August 19, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant