Sorry for double posting, but seems fewer people will see it on GitHub, so writing also here.
For example, if you have some binaries in the test/samples
directory, and need to pass that path to the test, and having a code like
let mytest filename =
(fun () -> Alcotest.(check string) "some" "string1" "string2")
let testset path =
List.map ~f:(fun l ->
l, `Slow, mytest l)
(Sys.readdir path)
let get_tests_dir =
let doc = "path to the tests directory" in
Cmdliner.Arg.(required & opt (some string) None & info ["p"] ~doc ~docv:"PATH")
let () =
Alcotest.run_with_args "my shiny tests" get_tests_dir [
"testset1", testset;
]
But that wouldn’t work, because Alcotest passes the argument to each checker function separately in the test list
. Is it possible to work around this somehow? So every file in the test/samples
would be a separate test like “filename, `Slow, mytest filename”.
I am going to pass that path in the dune file:
(alias
(name runtest)
(action (run ./tests.exe "test/samples")))
Is it possible somehow?