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

[Proposal] Add a new opam test subcommand and change the behaviour of the run-test field #4594

Open
kit-ty-kate opened this issue Mar 9, 2021 · 3 comments
Labels
KIND: FEATURE WISH KIND: PLUGIN CANDIDATE Feature requests that might best be implemented as plugins to opam

Comments

@kit-ty-kate
Copy link
Member

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.

@dra27
Copy link
Member

dra27 commented Mar 10, 2021

This feels very like the opam build experiment - moving opam into an area it simply doesn't belong in. A little like the exception type in OCaml before extensible-variants, --with-test and --with-doc are both poor person's package variables (which are on the slate for "opam.2.soon"!). A few thoughts:

  • The second "if pkg is already installed" stage can, I think, already be achieved by splitting the package into foo and foo-tests (potentially with an alteration to a package's test suite to test installed binary artefacts, rather than build ones - although with Dune I think would be transparent). Either way, it feels like packages should be bending to what opam offers, rather than the other way around!
  • I'm not sure you can come up with a mechanical definition of what tests being run would entail - opam doesn't know if a build has done anything meaningful either. For example, I notice batteries defines test dependencies but doesn't actually have [make "test"] {with-test} in its build recipe. However, it's not necessarily a bug - it has a configure command and there's absolutely no way opam could know what the [make "all"] it does have would also run the testsuite if the test dependencies are installed.
  • It could be worth displaying notes/warnings when --with-test is specified but packages have neither test dependencies nor any parts of a build recipe guarded with with-test

@rjbou
Copy link
Collaborator

rjbou commented Mar 16, 2021

This is a good candidate for a plugin, using the x-* fields.

@rjbou
Copy link
Collaborator

rjbou commented Jun 10, 2021

related to #4099 ?

kit-ty-kate added a commit to kit-ty-kate/opam-build that referenced this issue Nov 22, 2021
@rjbou rjbou added the KIND: PLUGIN CANDIDATE Feature requests that might best be implemented as plugins to opam label Jul 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
KIND: FEATURE WISH KIND: PLUGIN CANDIDATE Feature requests that might best be implemented as plugins to opam
Projects
None yet
Development

No branches or pull requests

3 participants