File tree 7 files changed +41
-5
lines changed
7 files changed +41
-5
lines changed Original file line number Diff line number Diff line change 1
1
### unreleased
2
2
3
+ - Fix division by zero when size of the terminal is incorrectly
4
+ reported as zero. (fix #356 , #381 , @MisterDA )
5
+
6
+ - Enable terminal size reporting on macOS and Windows. Also report the
7
+ terminal size even when the test is run buffered by Dune.
8
+ (#381 , @MisterDA )
9
+
10
+ - Allow overriding the number of columns with ` ALCOTEST_COLUMNS ` env
11
+ var. (#322 , #381 , @MisterDA )
12
+
3
13
### 1.7.0 (2023-02-24)
4
14
5
15
- Allow skipping a test case from inside the test case (#368 , @apeschar )
Original file line number Diff line number Diff line change @@ -77,6 +77,11 @@ ENVIRONMENT
77
77
ALCOTEST_COLOR
78
78
See option --color.
79
79
80
+ ALCOTEST_COLUMNS
81
+ Number of columns after which Alcotest truncates or splits written
82
+ lines. Default is to auto-detect using the terminal's dimensions,
83
+ or fallback to 80 columns.
84
+
80
85
ALCOTEST_COMPACT
81
86
See option --compact.
82
87
Original file line number Diff line number Diff line change @@ -69,8 +69,22 @@ module Make (P : Platform.MAKER) (M : Monad.S) :
69
69
in
70
70
Cmdliner.Cmd.Env. info " ALCOTEST_SOURCE_CODE_POSITION" ~doc
71
71
72
+ let alcotest_columns =
73
+ let doc =
74
+ " Number of columns after which Alcotest truncates or splits written \
75
+ lines. Default is to auto-detect using the terminal's dimensions, or \
76
+ fallback to 80 columns."
77
+ in
78
+ Cmdliner.Cmd.Env. info " ALCOTEST_COLUMNS" ~doc
79
+
72
80
let envs =
73
- [ ci_env; github_action_env; ocamlci_env; alcotest_source_code_position ]
81
+ [
82
+ ci_env;
83
+ github_action_env;
84
+ ocamlci_env;
85
+ alcotest_source_code_position;
86
+ alcotest_columns;
87
+ ]
74
88
75
89
let set_color =
76
90
let env = Cmd.Env. info " ALCOTEST_COLOR" in
Original file line number Diff line number Diff line change 86
86
module Option = struct
87
87
let is_some = function Some _ -> true | None -> false
88
88
let map f = function Some x -> Some (f x) | None -> None
89
+ let bind o f = match o with Some o -> f o | None -> None
89
90
90
91
let get_exn = function
91
92
| Some x -> x
Original file line number Diff line number Diff line change 42
42
43
43
module Option : sig
44
44
val map : ('a -> 'b ) -> 'a option -> 'b option
45
+ val bind : 'a option -> ('a -> 'b option ) -> 'b option
45
46
val is_some : _ option -> bool
46
47
val get_exn : 'a option -> 'a
47
48
val value : default :'a -> 'a option -> 'a
Original file line number Diff line number Diff line change @@ -74,9 +74,12 @@ module Unix_platform (M : Alcotest_engine.Monad.S) = struct
74
74
let stdout_isatty () = Unix. (isatty stdout)
75
75
76
76
let stdout_columns () =
77
- match Terminal. get_dimensions () with
78
- | Some { columns; _ } when columns > 0 -> Some columns
79
- | _ -> None
77
+ match Option. bind (Sys. getenv_opt " ALCOTEST_COLUMNS" ) int_of_string_opt with
78
+ | Some columns when columns > 0 -> Some columns
79
+ | _ -> (
80
+ match Terminal. get_dimensions () with
81
+ | Some { columns; _ } when columns > 0 -> Some columns
82
+ | _ -> None )
80
83
81
84
external before_test :
82
85
output :out_channel -> stdout :out_channel -> stderr :out_channel -> unit
Original file line number Diff line number Diff line change 4
4
; Don't run tests as if Alcotest was run in CI
5
5
(CI false)
6
6
; Don't guess source code position for compat with < 4.12.
7
- (ALCOTEST_SOURCE_CODE_POSITION false))))
7
+ (ALCOTEST_SOURCE_CODE_POSITION false)
8
+ ; Set to 80 columns for output reproducibility
9
+ (ALCOTEST_COLUMNS 80))))
8
10
9
11
(executable
10
12
(name gen_dune_rules)
You can’t perform that action at this time.
0 commit comments