package b0

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

B0 expectation tests.

An expectation test runs a program or sequence of programs in a given environment with given inputs and checks designated outputs against expected outcomes.

B0 expectation tests use your VCS to integrate and correct tests.

See the TODO.

type t

The type for expectation test runners. It represents a context to run a set of expctation tests.

module Outcome : sig ... end

Expectation test outcomes.

val make : ?vcs:B00_vcs.t -> ?prefix:B0_std.Fpath.t -> B0_cmdlet.Env.t -> base:B0_std.Fpath.t -> (t, string) Stdlib.result

make env ~base is an expectation test runner in environment env.

  • vcs is the VCS to use by default looked up with B00_vcs.t in B0_cmdlet.Env.scope_dir
  • prefix prefix is a prefix relative to which relative paths are interpreted and absolute path suffixes highlighed defaults (maybe relativiized in the future) to B0_cmdlet.Env.scope_dir.
  • base is a base directory in which the expectations are located relative to prefix.

Note. It's important to have a well defined base in which expectations are VCS controlled so so that users can get easily get summaries and diffs via their VCS without the noise of surrounding changes.

val prefix : t -> B0_std.Fpath.t

prefix exp is the prefix of exp. See make.

val base : t -> B0_std.Fpath.t

base exp is the absolute base path of exp. See make.

val base_files : t -> recurse:bool -> (B0_std.Fpath.t list, string) Stdlib.result

base_files exp ~recurse are the files in base exp and sub directories if recurse is true.

val dur : t -> B0_std.Mtime.span

dur exp is the monotonic duration since make.

Primitives

val file_outcome : t -> B0_std.Fpath.t -> (Outcome.t, string) Stdlib.result

file_outcome exp f is the expectation test outcome for file f in exp.

Showing results

val log_outcome : t -> B0_std.Fpath.t -> Outcome.t -> unit

log_outcome f o logs the outcome o of file f. At some point we likely want to add f to o. This should be done as soon as possible.

val log_results : t -> Outcome.t list -> B0_std.Os.Exit.t

log_results t os logs the result os. dir is the path used to print VCS command for the summary or diff.

Derived expectations

Note these do log outcomes.

val stdout : t -> ?env:B0_std.Os.Env.assignments -> ?cwd:B0_std.Fpath.t -> stdout:B0_std.Fpath.t -> B0_std.Cmd.t -> (Outcome.t, string) Stdlib.result