Does pack_install(..., [test(true)]) run_tests?

It seems as if it runs “make check” in packs with foreign C code? Is there a way to invoke the unit tests of a regular “pack” (i.e., no foreign code) upon pack installation?

Not sure if I understand your question; however, I can report that pack_install does in fact run the unit tests included with the pack. You need however to follow the directory structure and file naming conventions for packs as demoed in GitHub - JanWielemaker/environ: Tutorial SWI-Prolog pack .

Specifically, you need to have, inside the pack directory, a sub-directory test with test_*.pl files with unit tests in them.

Since the tests are now in a different place, you must load the test file separately if you want to run_tests manually. For example:

?- use_module(mypack/test/test_mypack).
true.

?- run_tests.
...

That’s the pack, unsure what I am doing wrong (note that it doesn’t use foreign C code).

Hmm, I see. Indeed running the tests comes from CMakeLists.txt and your pack doesn’t have it (since it probably doesn’t need it…)

If you check CMakeLists.txt from the environ repo I linked above, you will see at the bottom what is running the tests.

Yes, indeed, a CMakeLists.txt is needed to run the unit tests even if there’s no foreign C code. Moreover, one needs a statement pack_version(2). in pack.pl.

Two problems came to my attention:

  1. My pack has dependencies, require(rologp). The dependencies are built after the main pack, and especially after the unit tests for the main pack. That fails, because at time of testing the main pack, the dependencies haven’t yet built.
  2. Even if I call pack_install(rologp). before I call pack_install(interval)., the process fails. I need to exit and enter swipl again (linux).

Summary:

$ swipl
?- pack_install(rologp).
?- halt.
$ swipl
?- pack_install(interval).
?- use_module(library(rint)). % part of pack interval
?-

So, it seems as if the newly installed packs are not properly “registered” (activated?) after pack install. And the build of the dependencies is not in the right order.