Skip to content

Commit 6199ef1

Browse files
committed
Alcotest.run: ensure and_exit and record_backtrace can be overriden for the test sub-command too
`default_cmd` handles this correctly, but `test_cmd` always set `and_exit` and `record_backtrace` to `true`. Due to `Config.User.(cli_config || config)` this meant that `and_exit` couldn't be set to `false` by the caller. The main program may want to set `and_exit` to false if it has some wrappers using `Fun.protect` for example, with `and_exit` set to true these wouldn't run. For backwards compatibility with old versions of alcotest one workaround is to use `at_exit` instead of `Fun.protect` to register cleanup handlers. Fixes #438 Signed-off-by: Edwin Török <edwin@tarides.com>
1 parent b26e58f commit 6199ef1

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/alcotest-engine/cli.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,12 +125,14 @@ module Make (P : Platform.MAKER) (M : Monad.S) :
125125
let test_cmd config args library_name tests =
126126
let ci = Config.User.ci config
127127
and stdout = Config.User.stdout config
128+
and and_exit = Config.User.and_exit config
129+
and record_backtrace = Config.User.record_backtrace config
128130
and stderr = Config.User.stderr config in
129131
let doc = "Run a subset of the tests." in
130132
let term =
131133
let+ () = set_color stdout stderr
132134
and+ cli_config =
133-
Config.User.term ~stdout ~stderr ~and_exit:true ~record_backtrace:true
135+
Config.User.term ~stdout ~stderr ~and_exit ~record_backtrace
134136
~ci
135137
and+ args = args in
136138
let config = Config.User.(cli_config || config) in

0 commit comments

Comments
 (0)