package alcotest

Build not yet checked
  1. Overview
  2. Docs
Alcotest is a lightweight and colourful test framework

Install

dune-project
 Dependency

Authors

Maintainers

Sources

alcotest-1.10.1.tbz
sha256=62c095deda5cdd66c30684f7b1f25b5775d1d3d3ded927c7b893b4a6834ddb47
sha512=6f779fa96faf96b5b462ddc428aeaaa73a6be96771dbbad6a05b7bb00dae246648891c211e26174729c1f40128410ad96f2512101ae8b7d61f968ee61534b3d0

doc/src/alcotest.engine/platform.ml.html

Source file platform.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
open! Import

module type S = sig
  val time : unit -> float
  (** [time ()] returns the current timestamp, used to measure the duration of a
      testrun. *)

  val getcwd : unit -> string
  (** [getcwd ()] returns the current working directory. *)

  type 'a promise
  (** The type of monadic actions handled by {!with_redirect}. *)

  val stdout_isatty : unit -> bool
  (** Return [true] if standard output refers to a terminal or console window,
      [false] otherwise. *)

  val stdout_columns : unit -> int option
  (** [stdout_columns ()] is the current width of [stdout] in columns, or [None]
      if no width can be determined (e.g. [stdout] is not a TTY). *)

  val setup_std_outputs :
    ?style_renderer:Fmt.style_renderer ->
    ?utf_8:bool ->
    Formatters.stdout ->
    Formatters.stderr ->
    unit
  (** [setup_std_outputs ~style_renderer ~utf_8 stdout stderr] is called at
      startup of alcotest and sets up the standard streams for colored output.
  *)

  val log_trap_supported : bool
  (** Whether or not the test runner should trap test logs. The following
      functions are used iff this is set to [true]. *)

  val prepare_log_trap : root:string -> suite:string -> uuid:string -> string
  (** [prepare_log_trap ~root ~suite ~uuid] is called before test suite
      execution. It creates a directory for the logs of the run of [suite] with
      ID [uuid] under [root/run/suite], makes [root/latest] point to it if
      possible, and returns it. *)

  type file_descriptor

  val file_exists : string -> bool
  val open_write_only : string -> file_descriptor
  val close : file_descriptor -> unit

  val with_redirect : file_descriptor -> (unit -> 'a promise) -> 'a promise
  (** [with_redirect fd f] is called for each test. On Unix, it deals with
      redirection of standard streams to the [fd]. *)

  val home_directory : unit -> (string, [ `Msg of string ]) result
  (** [home_directory ()] is the current user's HOME directory, if it exists. *)

  val timestamp : float -> string
  (** [timestamp t] is [t], in seconds since the epoch, as a UTC ISO 8601 date
      and time such as [2026-11-02T10:00:00Z]. *)

  val write_file : string -> string -> unit
  (** [write_file path contents] replaces the file at [path] with [contents],
      creating its directory if needed. On a platform without a file system, it
      does nothing.

      @raise Sys_error if the file cannot be written. *)
end

module type MAKER = functor (M : Monad.S) -> S with type 'a promise := 'a M.t