Repository navigation
Run the documentation examples, not only compile them - #596
Merged
Merged
Conversation
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
deferfreed memory before the return value was read, sodocs/book/10-memory-and-lifetimes.mdexited 216 instead of 0array<T, N>handed back a pointer into its own dead frame, solib/stdlib/audio/scales.flowreturned garbageBoth 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
--runbuilds and executes every complete program.docs/book/01-a-complete-program.mdreturns 2 to show a failure pathIt 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:
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_doc_examples.py --run --check-ledgerpytest tests/unit/test_doc_example_run_stage.pyruff check