Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/foglet_bbs/doors/runner.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
33 changes: 33 additions & 0 deletions test/foglet_bbs/doors/runner_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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(%{
Expand Down
Loading