The issues with the current design
Testing packages in opam isn't really a separate step of action and this can cause issues for some packages.
For instance, for some packages (key packages mainly), their tests do not get defined in opam-repository because they require packages that require the package being tested (cyclic dependency). e.g. base, odoc, …
Some packages also do not define their tests for other reasons but opam cannot distinguish between "has test" and "does not have test" and thus users using opam install --with-test <pkg> won't know if <pkg> has really been tested.
The proposal
To help with those issues my proposal would be to add a new test subcommand such as opam test <pkg> would:
- Install the dependencies and test dependencies
- If
<pkg> is already installed and {with-test} is used inside the build step:
- then rebuild
<pkg> without reinstalling it
- else: do not rebuild it
- If
<pkg> is not installed, install it with with-test = true
- Wait for everything to be installed (including
post dependencies)
- Run the
run-test phase (wasn't used in any previous step)
- If no tests has been ran, opam would print some kind of a note to notify the user of that.
The new run-test step is a change of behaviour from previous versions of opam where the run-test phase was ran after the build phase and before the install phase. Now with this proposal, this phase is never ran through opam install but only through the new opam test command.
The issues with the current design
Testing packages in opam isn't really a separate step of action and this can cause issues for some packages.
For instance, for some packages (key packages mainly), their tests do not get defined in opam-repository because they require packages that require the package being tested (cyclic dependency). e.g.
base,odoc, …Some packages also do not define their tests for other reasons but opam cannot distinguish between "has test" and "does not have test" and thus users using
opam install --with-test <pkg>won't know if<pkg>has really been tested.The proposal
To help with those issues my proposal would be to add a new
testsubcommand such asopam test <pkg>would:<pkg>is already installed and{with-test}is used inside thebuildstep:<pkg>without reinstalling it<pkg>is not installed, install it withwith-test = truepostdependencies)run-testphase (wasn't used in any previous step)The new
run-teststep is a change of behaviour from previous versions of opam where therun-testphase was ran after thebuildphase and before theinstallphase. Now with this proposal, this phase is never ran throughopam installbut only through the newopam testcommand.