How to properly exclude directories from cram tests?

The documentation for cram mentions

(cram (applies_to * \ foo bar) (deps ../foo.exe))

We use the Predicate Language to apply this stanza to all tests in this directory, except for foo.t and bar.t.

But for some reason I only get the expected behavior of excluding foo.t and bar.t if I instead write

(cram 
  (enable_if false)
  (applies_to foo bar) ...)

Furthermore, I don’t understand why the enable_if clause is needed here.

Am I doing this wrong or is this an issue that should be reported?

(I tested this with dune 3.6.2)

1 Like

Also, how would I only exclude these tests when the --release flag is passed?

dune runtest --release

Are you sure that with (enable_if false) your tests are being executed?

@Kakadu Okay I see this is wrong, but the point is that

(cram 
  (applies_to * \ foo bar) ...)

runs the tests foo.t and bar.t anyways.

It looks like this spell is adding dependencies to everything except foo.t and bar.t. For me it is kind of expected.
If you need to dynamically disable some optional tests, you could indeed try enabled_if + variable expansion.

1 Like

@Kakadu I see, the following seems to disable the tests when --release is set

(cram
  (applies_to :whole_subtree)
  (deps ...))

(cram
  (enabled_if (<> %{profile} release))
  (applies_to foo bar))
1 Like