Behaviour for executing external commands.
The default runner is Trebejo.Util.run_cmd/3 (via Arrea.Command).
Tests can swap in Trebejo.Mox.Runner to stub specific calls without
touching real binaries.
Implementing
defmodule MyApp.MockRunner do
@behaviour Trebejo.Runner
@impl true
def run(_cmd_name, _args, _opts) do
{:ok, "mocked output\n", 0}
end
endThen set Trebejo.run_with(MyApp.MockRunner) in your test setup.
Contract
run/3 returns:
{:ok, stdout, exit_code}on completion{:error, reason}on failure (:timeout,:enoent, ...)
The runner must be safe to call from any process; it owns the port lifecycle.
Summary
Callbacks
Functions
Run a command using the active runner.
The active runner defaults to Trebejo.Util.Runner (a thin adapter
that delegates to Trebejo.Util.run_cmd/3). Tests can swap in
Trebejo.Mox.Runner by calling set_runner/1 in their setup.
@spec runner() :: module()
@spec set_runner(module()) :: :ok
Swap the active runner. Use only in tests.