diff --git a/lib/foglet_bbs/doors/runner.ex b/lib/foglet_bbs/doors/runner.ex index dc232396..43f4638f 100644 --- a/lib/foglet_bbs/doors/runner.ex +++ b/lib/foglet_bbs/doors/runner.ex @@ -412,7 +412,10 @@ defmodule Foglet.Doors.Runner do door_id: state.manifest.id, session: state.session, terminal_size: state.terminal_size, - send_output: fn data -> emit(state, data) end + send_output: fn data -> + _state = emit(state, data) + :ok + end } end diff --git a/test/foglet_bbs/doors/runner_test.exs b/test/foglet_bbs/doors/runner_test.exs index 42060b25..626f8130 100644 --- a/test/foglet_bbs/doors/runner_test.exs +++ b/test/foglet_bbs/doors/runner_test.exs @@ -31,7 +31,40 @@ defmodule Foglet.Doors.RunnerTest do def init(_context), do: raise("boom") end + defmodule SendOutputDoor do + @behaviour Foglet.Doors.Door + + @impl true + def init(%{send_output: send_output}) do + :ok = send_output.("callback output\n") + {:ok, %{}, "init returned output\n"} + end + end + describe "native Elixir door runtime" do + test "native launch send_output keeps the documented :ok callback contract" do + {:ok, manifest} = + manifest(%{ + id: "native-send-output", + display_name: "Native Send Output", + runtime: :native_elixir, + module: __MODULE__.SendOutputDoor, + timeout_ms: 5_000 + }) + + {:ok, pid} = + DoorSupervisor.start_runner(manifest: manifest, output: output_to(self()), owner: self()) + + assert_door_output_contains("callback output") + assert_door_output_contains("init returned output") + assert_receive {:door_started, ^pid, "native-send-output"} + + ref = Process.monitor(pid) + Runner.stop(pid) + assert_receive {:door_exited, ^pid, "native-send-output", :normal, nil} + assert_receive {:DOWN, ^ref, :process, ^pid, :normal} + end + test "starts under the door supervisor, emits output, propagates resize, and exits normally" do {:ok, manifest} = manifest(%{