qcheck icon indicating copy to clipboard operation
qcheck copied to clipboard

missing usage with dune

Open mimoo opened this issue 3 years ago • 5 comments

listing qcheck within my dune file's libraries didn't work, I ended up realizing that I need to instead list qcheck-core. I suggest adding this to the README. Also, do I need to opam install qcheck if I'm not importing it and just importing qcheck-core?

mimoo avatar Jan 18 '23 02:01 mimoo

If you're just using qcheck-core, then opam install qcheck-core is enough. qcheck is a compatibility package that installs the core and some other things, it's not necessary otherwise.

c-cube avatar Jan 18 '23 05:01 c-cube

First off: yes, the documentation could certainly be improved (PRs welcome!)

I cannot recreate the problem you experienced. Below follows my attempt at a minimal repro which works fine. As @c-cube mentions, this is using the qcheck compatibility package, so it needs to be adapted to use qcheck-core instead.

dune-project:

(lang dune 3.0)

dune:

(test
 (name test)
 (modules test)
 (libraries qcheck)
)

test.ml:

open QCheck

let t = Test.make ~name:"float test" float (fun f -> floor f <= f)

let _ = QCheck_runner.run_tests ~verbose:true [t]

jmid avatar Jan 18 '23 07:01 jmid

I guess that setting (implicit_transitive_deps false) in the dune-project file might be what triggers the bug and make it require qcheck-core ?

Gbury avatar Jan 18 '23 08:01 Gbury

Indeed! I can confirm that after adding that line to dune-project I get the following error message:

$ dune build test.exe
File "test.ml", line 1, characters 5-11:
1 | open QCheck
         ^^^^^^
Error: Unbound module QCheck

This is confusing to a new-comer and documentation could help here, e.g., by pointing them to use qcheck-core instead.

jmid avatar Jan 18 '23 09:01 jmid

yes we use implicit_transitive_deps false (which really should be default for all projects :D)

mimoo avatar Jan 18 '23 18:01 mimoo