[ANN] opam build & opam test: the opam plugins that simplifies your dev setup

Hi everyone!

I’m pleased to announce the first release of opam-build and opam-test.
Those two plugins are highly experimental for the moment but aims at a simpler workflow for developers to get started building and testing their projects.

opam-build

builds any project easily with just one command:

opam build

The command will setup a local switch and install all the required dependencies, then build the project (as described in the opam files). So no matter your build system, calling opam build should be enough.

opam-test

opam-test does the same thing as opam-build but runs the tests on top of it. Just call:

opam test

to get started.

opam-test also circumvents issues with cyclic test dependencies in opam (where the tests require a package that needs the library it is trying to test). Such cyclic dependency is present in packages such as odoc or base. See [Proposal] Add a new `opam test` subcommand and change the behaviour of the `run-test` field · Issue #4594 · ocaml/opam · GitHub

If your package is in such a case, opam-test allows you to use the post variable to make that work. For instance:

In project A:

run-test: ["dune" "build "-p" name "-j" jobs] {post}
depends: [
  "B" {with-test & post}
]

In project B:

depends: [
  "A"
]

Without the {post} variable, opam alone would not be able to run the tests as the tests are run before the installation of the package and this would lead to a cyclic dependency. opam-test allows you to split the installation from the tests and thus makes that work.

Installation

To install, simply call

opam update
opam install opam-build opam-test

If the package do not exist, they might not have been merged in opam-repository yet (watch for 2 packages from kit-ty-kate/opam-build at 0.1.0 by kit-ty-kate · Pull Request #20085 · ocaml/opam-repository · GitHub). In the meantime, instead you can install it directly from the source repository:

opam pin add git+https://github.com/kit-ty-kate/opam-build

Again, these plugins are highly experimental and are looking for use-cases. If you think this can be useful, feel free to send some feedbacks here or on the bugtracker: Issues · kit-ty-kate/opam-build · GitHub

22 Likes