Testing new dot opam file

I’ve been trying to figure out how to test a new/updated opam file for a package (camlp5). Following the instructions at https://opam.ocaml.org/doc/Packaging.html#Testing doesn’t seem to work.

When I do opam install . it tells me it’s installing camlp5.7.12 even though the git repo I’m sitting in is for version 8.00~alpha01. And I know (or am pretty sure) that it’s not using the modified opam file in the repo, b/c I added a “depexts” that is unsatisfied by the OS (two perl packages that I specifically removed before trying to install).

Is there a way to test the opam file before I actually publish?

ETA: oddly, if I control-C during the build (running with “-v -v -v -v” so I can tell when) I get the expected error-report:

><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build camlp5 7.12
└─ 
╶─ No changes have been performed

The packages you requested declare the following system dependencies. Please make sure they are installed before retrying:
    libipc-system-simple-perl libstring-shellquote-perl

but if I do not control-C (let it run) it builds and installs (the packages are not required for the build, but rather for running the testsuite).

I haven’t used OPAM in a long time, but I recall having to run opam pin add . --kind=path

1 Like
  1. it -does- use the right repo
  2. it -does- seem to run the test (though I don’t see any output while it’s doing so)
  3. if I control-C during the build, it -does- complain that the external deps weren’t found
  4. and if I do opam install . for a package that isn’t part of opam, it -does- use the opam file in the repo, and -does- fail (yes, it -does- fail) when the external deps aren’t found.

So it’s a little mysterious.

Unrelated to this issue: Dune users might want to avoid --kind=path until the solution to https://github.com/ocaml/opam/issues/4195 is released (to be included as part of 2.1.0). I did this for a while and ended up losing 80G disk space to duplicated _build directories :upside_down_face:

If one wants to test the effect of releasing at the current commit, --kind=git might be better.

I believe you need opam install --with-test to get the tests to run as part of the installation process. Additionally passing -vv should show the test output as well.

Nope, same behaviour as before. If this is a bug, I’ll start debugging. But first would like to get confirmation that it’s supposed to actually work.

Opam runs tests using commands supplied in the .opam file. The current .opam file for Camlp5 doesn’t define a {with-test} rune, so I suspect that’s another problem.

See https://github.com/mirage/mirage/blob/master/mirage.opam#L16 as an example.

  1. the “tests” to which I allude are those run by opam itself, based on the “depext” stanza of the opam file.
  2. I added a depext stanza to the camlp5 opam file, checked it in, etc, and then tried opam install .
  3. when I did the same thing to a package that wasn’t in the opam-repository (a new one I’ve been writing), the depext test was run, failed, and I got the expected error-message.

I never used the opam install . workflow.

Did you try with opam pin add . ? That’s quite established and should work.

I tried it again just now (making sure to remove the two Perl packages that I’m looking for an error from), and opam pin add camlp5 . successfully installs. Yep. So no error, even though those two Perl packages are missing.

What is your opam version?
Since 2.1.0~alpha, external dependency management is integrated in opam.

But first would like to get confirmation that it’s supposed to actually work.

The opam install . workflow is a good one for testing, it is a shortcut for opam pin add . && opam install <pkg>.

On the testing before publish mechanism, as adviced in the manual: there is no specific check done by opam, it is only to check that the package installs well so you can check it goes as expected.
See also this issue about testing before publishing.

OK, I see what happened. As I said, I have two packages (camlp5 and pa_ppx). The first is published on opam, the second is not (yet). The first installs, the second does not. When the second fails, it complains about these two OS packages not being present (that are in depexts). I just now carefully read the failure output, and see that in fact, the failure was of my Makefile (that checks for these OS packages being present) and NOT of opam’s check. So Opam was merely making that report, viz.

<><> Error report <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
┌─ The following actions failed
│ λ build pa_ppx ~dev
└─ 
╶─ No changes have been performed

The packages you requested declare the following system dependencies. Please make sure they are installed before retrying:
    libipc-system-simple-perl libstring-shellquote-perl

and specifically the part at the end, as noise. It means nothing, because nothing was checked by opam before emitting this text.

Sigh.

Opam displays this message when there is a failure in a package actions (build, install), only if the package declares external dependencies. It is present as a hint, it doesn’t necessary mean that the failure origin is the missing external dependency.
It’s only since 2.1.0~alpha that opam embed the internal management of external dependencies. What is you opam version?

I’m using `2.0.6’. Now that I know it’s not supported, it’s all good. Thank you for the clarification.