Semantics of `package` qualifier for dune aliases

I’m having a lot of trouble understanding precisely what the dune stanzas alias and rule do, particularly when qualified with a (package <name>) directive. In a project with several packages (several <package>.opam files), I tried:

(alias
  (name dummy)
  (package lin)
)

(rule
  (alias dummy)
  (action (run echo Hello world!))
)

to see whether the action would “inherit” the restriction to package lin. I didn’t expect the result:

$ dune build @dummy
$ dune build --only-packages lin @dummy
$ dune build -p lin @dummy

I can’t seem to trigger the action anymore…

In addition, I have a question. In multicoretests we have a bunch of tests defined by a bunch of

(rule
  (alias runtest)
  (action ...)

We would like to restrict those tests to the package multicoretests (more details in this PR). Do we have to put a (package multicoretests) in every one of our test rules, or is there a less verbose way to do it?

If I do a build clean before each of my commands above, then the action is executed in all cases.

I find it a bit strange… how am I supposed to write targets that are run every time? Typically, I expect runtest to behave like that.

In general Dune tries as hard as possible to only re-run rules when the dependencies change. The @runtest alias is no exception. If you have a non-reproducible rule or for some other reason you want to re-trigger a rule each and every single time you can add (universe) to the list of dependencies.

Cheers,
Nicolas

1 Like

Got it! Thank you.

So the only one of my question that remains is:

In addition, I have a question. In multicoretests we have a bunch of tests defined by a bunch of

(rule
  (alias runtest)
  (action ...)

We would like to restrict those tests to the package multicoretests (more details in this PR). Do we have to put a (package multicoretests) in every one of our test rule s, or is there a less verbose way to do it?