Skip to content

Commit 9755ae2

Browse files
fahchenclaude
andcommitted
test(listener): drop log capture in malformed-listener test
The earlier `capture_log/1` assertion was flaky under async tests: the returned log buffer is a process-wide snapshot, so unrelated Postgrex disconnect lines from other concurrent tests would land inside the capture window and trip the `refute log =~ ~r/\[error\]/` check. The behavioural guarantee under test ("a malformed listener never destabilises the enactment") is already covered by the surviving assertions: the enactment must reach a stable workitem-enabled state and no listener callback may fire. Drop the log assertion (and the `import ExUnit.CaptureLog`) accordingly. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent 0bf562f commit 9755ae2

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

lib/coloured_flow/dsl/spec.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ A module that uses `ColouredFlow.DSL` exposes:
5959
MyWorkflow.__cpn__(:version) :: String.t() | nil
6060
MyWorkflow.__cpn__(:initial_markings) :: [%ColouredFlow.Enactment.Marking{}]
6161

62-
# Storage / runner conveniences (only useful when `:storage` is configured)
62+
# Storage conveniences (only useful when `:storage` is configured)
6363
MyWorkflow.setup_flow!() :: term() # inserts each call
6464
MyWorkflow.insert_enactment!(flow) :: term()
6565
MyWorkflow.insert_enactment!(flow, [%Marking{}]) :: term()
66+
67+
# Runner convenience (no `:storage` required)
6668
MyWorkflow.start_enactment(eid, opts) :: DynamicSupervisor.on_start_child()
6769

6870
# ColouredFlow.Runner.Enactment.Listener callbacks

lib/coloured_flow/runner/enactment/listener.ex

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ defmodule ColouredFlow.Runner.Enactment.Listener do
2121
Task.Supervisor name, …) into otherwise-static callback code.
2222
- `nil` — no listener bound, lifecycle dispatch is a no-op.
2323
24+
Any other value (a PID, string, mis-shaped tuple, …) is silently ignored by
25+
`safe_invoke/3`; the runner promises a misbehaving listener never destabilises
26+
the enactment.
27+
2428
All callbacks are optional; the runner only invokes those a listener exports at
2529
the right arity. Callbacks run inline in the enactment GenServer process, so
2630
listeners must return quickly. Side effects that may block belong inside a

test/coloured_flow/runner/enactment/listener_dispatch_test.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ defmodule ColouredFlow.Runner.Enactment.ListenerDispatchTest do
107107
id: enactment.id
108108
)
109109

110+
# Enactment must reach a stable state (workitem produced) without
111+
# crashing despite the bogus listener value.
110112
[wi] = get_enactment_workitems(pid)
111113
assert wi.state == :enabled
112-
refute_received {:on_enactment_start, _, _}
114+
refute_received {:on_enactment_start, _ctx, _extras}
113115
end
114116
end
115117

0 commit comments

Comments
 (0)