Normalizes raw engine output into a stable, engine-independent structure.
Normalization is what makes Beancount usable as an oracle: two different engines (the CLI today, a native engine tomorrow) can be compared on their normalized output rather than on incidental, backend-specific text such as temporary file paths.
The normalized map has the shape:
%{
status: :ok | :error,
errors: [%{line: non_neg_integer() | nil, message: String.t()}]
}
Summary
Functions
Normalize captured stdout/stderr for a given exit status.
Types
@type error() :: %{line: non_neg_integer() | nil, message: String.t()}
@type t() :: %{status: Beancount.Result.status(), errors: [error()]}
Functions
@spec normalize(non_neg_integer() | nil, binary(), binary(), binary() | nil) :: t()
Normalize captured stdout/stderr for a given exit status.
source_path, when provided, is stripped from error lines so that the
normalized output does not depend on temporary file locations and stays
deterministic.
Examples
iex> Beancount.Normalizer.normalize(0, "", "")
%{status: :ok, errors: []}
iex> Beancount.Normalizer.normalize(1, "", "/tmp/x.bean:3: Invalid")
%{status: :error, errors: [%{line: 3, message: "Invalid"}]}