flan/test/programs/dev-repl.flan
Joseph Ferano ff2bd1da12 A socket file must not outlive the process that bound it
The merged daemon now unlinks its socket on the ways out it does not
control as well as the one it does: an atexit for exit(3), which is what a
runtime trap takes, and by hand in die_now and in main's fallback, which
are _exit and skip the chain on purpose.

The client says so too. A refusal on a path that exists is a leftover, not
a daemon declining, and the raw 'Connection refused' has now misdirected
two investigations.

Separately, and it is separate: dev-repl.flan gets dev-robust.flan's
24000-tick budget. Twenty seconds of program under a two-minute test is a
second flake waiting its turn, and it is not the one fixed above -- that
one fails honestly, saying the program exited.
2026-09-14 08:11:35 +07:00

34 lines
1.5 KiB
Plaintext

;;;; A program that just runs, for evaluating expressions against.
;;;;
;;;; Unlike dev-loop.flan it does not count reloads and stop: C-x C-e is a
;;;; thunk the agent runs at a frame boundary, so a program under test has to
;;;; keep reaching them. (agent/wait 5) is both the poll and the pacing — 5ms
;;;; of nothing, which is what a frame is when there is no frame.
(import agent "vendor:agent")
;;; A condition, so that a body typed in later can error and stop the program
;;; where an editor can see it. It is here rather than in the evaluated form
;;; because the break loop matches on a class the *host* was compiled with.
(defstruct Missing [id i32])
(defvar ticks i64)
(defn step [] i64
(set ticks (+ ticks 1))
ticks)
(defn main [] i32
(agent/start "/tmp/flan-dev-repl-fallback.sock")
;; 24000 and not the 4000 the other fixtures use, because this one is the
;; whole of test_emacs: one daemon carries every check from `flan-connect' to
;; the break loop, and 4000 ticks of 5ms is a two-minute test with a
;; twenty-second program in it. Run the suite on a machine with several
;; compilers on it and the program can reach its last tick while the client
;; is still working — which fails honestly ("the program exited; restart flan
;; dev") but fails for a reason that has nothing to do with what was being
;; checked. dev-robust.flan is 24000 for the same reason and got there first.
;; The watchdogs, at 600s, are what actually bounds the run.
(dotimes [i 24000]
(agent/wait 5)
(set ticks (step)))
0)