Skip to content

Ariadne: (quit code), assert and ari test - #896

Merged
transfix merged 6 commits into
masterfrom
feat/ari-quit-assert-test
Oct 31, 2026
Merged

transfix merged 6 commits into
masterfrom
feat/ari-quit-assert-test

Conversation

@transfix

Copy link
Copy Markdown
Owner

Part of #894 (the first three asks). Functions for loaded documents comes in a separate PR.

What a document gets

(quit [code]): every stock host binds it through AppRuntime::register_quit(), which also binds on: quit.

  • code is an integer from 0 to 255 (default 0). Anything else raises TypeError or ValueError in the calling program, and nothing closes.
  • The first close request's code is the one kept (exit_code()).
  • ari run, snapshot and check exit with it, and so do arigl's window and --terminal modes.
  • snapshot stops on the frame the document quit.
  • check runs init:, so init: (quit 3) makes ari check exit 3.

(assert cond [message [data]]): a builtin. When cond is false it raises AssertionError, a new class under Exception, not RuntimeError, with the message assertion failed or assertion failed: <message>.

  • try catches it.
  • Uncaught, it reports the form that failed: AssertionError: assertion failed: one and one (at (assert (= (+ 1 1) 3) "one and one")).

tests:: a top-level map of test name to program, ignored by every host except ari test.

ari test [--tap] [--timeout S] [--frames N] [host flags] doc.ari...

  • Each document runs headless with a fresh app. Frames are laid out by FTXUI as snapshot does, but nothing is drawn, and there is no input.
  • It ends at the first of these:
    • (quit code);
    • every tests: case has run (one at a time, in order, on the action lane, after init: and the first frame);
    • --frames N;
    • --timeout (default 30 s).
  • A document fails when:
    • its load fails or warns;
    • a program raises an error nothing catches, or is killed (an action, a resident or a bad expression);
    • a test fails (the remaining tests still run);
    • it quits non-zero, or before its tests have all ended;
    • it times out.
  • The network rules are snapshot's. Requests are waited for, and after --frames with the network on it settles as snapshot does.
  • Output:
    ok   tests/semver.ari (3 tests, 0.02 s)
    FAIL tests/search.ari (4 tests, 0.11 s)
         test 'bad' failed: AssertionError: assertion failed: one and one (at (assert (= (+ 1 1) 3) "one and one"))
         test 'raises' failed: RuntimeError: boom (at (error "boom"))
    ari test: 2 documents, 1 failed
    
    With --tap it prints TAP 13 instead (ok N - doc # detail, then the failures as # lines).
  • Exit status: 0 when everything passed, 1 when anything failed, 2 on a usage error.

Runtime changes

  • Runtime::run_program(script, done) runs a program on the action lane and reports how it ended ("", failed: ..., did not complete: ...) to the callback, not as a warning.
  • An action's failure warning now ends with [<its program, one line, 80 chars>]. A resident's warning names its lane: ari: on_tick: resident [...] failed: ....
  • --timeout is a general host flag (host_cli). src/ari/ari_run.h holds the helpers for running ari that ari_net_test had.

Tests

  • state_exec_exceptions_test: assert on all four engines, the class chain, try, the data argument, arity, and the traceback form.
  • ariadne_loader_test: the tests: block, its order and its malformed shapes.
  • ariadne_host_test:
    • quit codes, where the first one stands;
    • quit from init:, and with no code;
    • bad codes;
    • on: quit;
    • run_program outcomes, including a parked program and a syntax error;
    • an action failure that names its program;
    • the free-head check on test programs;
    • --timeout parsing.
  • ari_test_command_test runs the built ari end to end:
    • quit codes for check and snapshot;
    • passing documents and the summary line;
    • every way to fail;
    • --frames and timeouts;
    • TAP and usage errors;
    • the network on and off against a localhost server.

Locally: the ariadne_* and state_exec_* suites all pass; ctest -R "^(Ari|AriadneQuit|AriadneRunProgram|AriadneTests|AriadneHostCli|BuiltinClasses)" passes 554/554.

Docs: docs/ARIADNE.md §13 (new) and §2.4, §5.1, §9.2; docs/STATE_EXEC_DEVELOPER_GUIDE.md; docs/STATE_EXEC_EXCEPTIONS.md; the ari usage text.

Rebase note: #883 also touches src/ari/CMakeLists.txt; keep both test blocks.

- (quit [code]): AppRuntime::register_quit() binds `on: quit` and the verb; the
  first close request's code is exit_code(). ari run/snapshot/check and arigl (window
  and --terminal) exit with it; snapshot stops on the frame the document quit.
- (assert cond [message [data]]): a builtin raising AssertionError (a new class under
  Exception), "assertion failed[: message]"; its traceback ends at the form.
- tests: block (name -> program) captured by the loader; Runtime::run_program runs a
  program on the action lane and reports how it ended to a callback.
- ari test [--tap] [--timeout S] [--frames N] doc.ari...: each document headless until
  it quits, its tests have run, N frames, or the timeout. Fails on a non-zero quit, an
  uncaught error, a failed or warning load, a failed test, or a timeout. One line per
  document with what failed and in which program; TAP with --tap; exit 1 on failure.
  Network flags and settling as snapshot's.
- Action failure warnings name their program; resident ones their lane.
- Docs: ARIADNE.md §13, the exceptions table, the developer guide.
transfix added a commit to cy-pca/cypkg that referenced this pull request Oct 30, 2026
transfix and others added 4 commits October 30, 2026 12:54
Conflicts with the locks spawn context (#865) and --credential-env (#895): the sweep keeps
run_program's report and the spawned children's reap; ari test settles with AppRuntime::settle,
which replaced settle_async_calls; --timeout joins --credential-env among the value flags.
…illing

stepped_solve::impl did f.assign(nv, f[0]): the value is a reference into f, and libc++'s
assign frees the old buffer before filling the new one, so on macOS every entry was read
from freed memory (Fem.SteppedPoissonMatchesTheOneShotSolve, rel diff 6.7e268 in the macOS
recipe lanes). libstdc++ and MSVC copy the value first, so Linux and Windows passed.
Takes #903's fix for the stepped Poisson solve in place of the same fix made here.
@transfix
transfix merged commit 2d8cf8a into master Oct 31, 2026
25 of 27 checks passed
@transfix
transfix deleted the feat/ari-quit-assert-test branch October 31, 2026 02:11
transfix pushed a commit that referenced this pull request Oct 31, 2026
#896 landed on master squashed (2d8cf8a), so this branch's own change is b83e92d's diff
from #896's last head a26d53a. That diff applies to master unchanged: 10 files, the
functions: work alone.
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