Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document dune usage in README #306

Merged
merged 4 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## NEXT RELEASE

- ...
- Document `dune` usage in README

## 0.23

Expand Down
73 changes: 69 additions & 4 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,22 @@ changed in lots of small ways (in the right direction, I hope) so the code
will not work any more.
<<examples>> is an updated version of the blog post's examples.

== Build
== Build and Install

$ make

You can use opam:
You can install qcheck via opam:

$ opam install qcheck

The `qcheck` package is offered for compatibility.
For a bare-bones installation you can use the `qcheck-core` package:

$ opam install qcheck-core

To build the library from source

$ make


== License

The code is now released under the BSD license.
Expand Down Expand Up @@ -430,3 +438,60 @@ Starting with 0.9, the library is split into several components:

Normally, for contributors,
`opam pin https://github.com/c-cube/qcheck` will pin all these packages.


=== Usage from dune

We can use the buggy test from above using the `qcheck` opam package:

[source,OCaml]
----
(* test.ml *)
let test =
QCheck.Test.make ~count:1000 ~name:"my_buggy_test"
QCheck.(list small_nat)
(fun l -> List.rev l = l)

let _ = QCheck_runner.run_tests_main [test]
----

with the following `dune` file:

[source]
----
(test
(name test)
(modules test)
(libraries qcheck)
)
----

and run it with `dune exec ./test.exe` or `dune runtest`.


To keep things minimal or if you are using `(implicit_transitive_deps false)`
in dune, you may want to use the `qcheck-core` package instead. To do so,
we have to adapt the last line of the example to use `QCheck_base_runner`:

[source,OCaml]
----
(* test.ml *)
let test =
QCheck.Test.make ~count:1000 ~name:"my_buggy_test"
QCheck.(list small_nat)
(fun l -> List.rev l = l)

let _ = QCheck_base_runner.run_tests_main [test]
----

and adjust the `dune` file accordingly to use `qcheck-core` and its
`qcheck-core.runner` sub-package:

[source]
----
(test
(name test)
(modules test)
(libraries qcheck-core qcheck-core.runner)
)
----
Loading