Module Craml

Library to handle cram tests format.

type output = [
| `Output of string
| `Ellipsis
]

The type for output lines.

type line = [
| output
| `Command of string list
| `Comment of string
| `Part of string
| `Non_det of [ `Output | `Command ]
| `Exit of int
]

The type for all lines.

val pp_command : string list Fmt.t

pp_command display a multi-line command.

val pp_line : ?⁠hide:bool ‑> line Fmt.t

pp_line is the pretty-printer for lines. If hide is true, commands starting by @@ are not displayed. By default, hide is not set (all the lines are printed).

type test = {
part : string option;
non_deterministic : [ `Command | `Output | `False ];
command : string list;
output : output list;
lines : line list;
exit_code : int;
}

The type for tests.

type item =
| Test of test
| Line of line

The type for test items

type t = item list

The type for cram files.

val pp : ?⁠hide:bool ‑> t Fmt.t
val to_string : ?⁠hide:bool ‑> t ‑> string
val parse_file : string ‑> t
val parse_lexbuf : Lexing.lexbuf ‑> t
val run : string ‑> f:(string ‑> t ‑> string) ‑> unit

run n f runs the expect callback f over the file named n. f is called with the raw contents of n and its structured contents; it returns the new file contents. If the result of f is different from the initial contents, then $n.corrected is created with the new contents.

val part : string ‑> t ‑> t option

part i t is the i-th part in t.

val pp_exit_code : int Fmt.t

Display exit code.

val equal_output : output list ‑> output list ‑> bool

equal x y compares x and y; are used as wildcards for zero, one or multiple matching lines.

val to_html : t ‑> string