Module

poke/capture

src/poke/capture.pooka

Give a callback a small notebook for its standard output. The original group leader is restored on success and exceptions, and nested captures keep separate notebooks. Join child processes before leaving the scope. This captures standard IO, not global standard_error or logger output; replacing shared devices would interfere with tests running beside this one.

API reference

class

Captured

src/poke/capture.pooka:12
class Captured(value: a, text: String)
field

value

src/poke/capture.pooka:12
value: a
INFERREDa
field

text

src/poke/capture.pooka:12
text: String
INFERREDString
constructor

new

src/poke/capture.pooka:12
INFERREDfn(a, String) -> poke/capture.Captured(a)
function

output

src/poke/capture.pooka:25
output(run: fn() -> a) -> Captured(a)
INFERREDfn(fn() -> a) -> poke/capture.Captured(a)

Capture standard output, returning the callback's value unchanged. Exceptions are re-raised after restoring the caller's device and stopping the collector.

Pooka
let found = capture.output(fn() { io.println("hello") })
should.equal(found.text, "hello\n")
function

attempt

src/poke/capture.pooka:32
attempt(run: fn() -> a) -> Captured(Result(a, Failure))
INFERREDfn(fn() -> a) -> poke/capture.Captured(Result(a, poke/failure.Failure))

Keep the output and a structured failure together when a callback fails. The callback runs in the current process, so ordinary fixtures still apply.