Skip to content

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

Description

@kit-ty-kate

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions