Skip to content

enabled_if doesn't work in (test) #6938

@talex5

Description

@talex5

Expected Behavior

We have:

(test
 (name test)
 (package eio_linux)
 (enabled_if (= %{system} "linux"))
 (modules test)
 (libraries alcotest eio_linux))

I expect this stanza to be ignored on macos. However, dune tries to build test.ml anyway. If I delete the stanza, it skips the file, as expected (reported by a macos user and tested on Linux by changing "linux" to "foobar" and confirming that it still tries to build it).

I consulted the dune documention for (test):

  • (test) says "the test stanza is the singular form of tests"
  • (tests) says "The optional fields supported are a subset of the alias and executables fields. In particular, all fields except for public_names are supported from the executables stanza. Alias fields apart from name are allowed."
  • (executables) says "(enabled_if <blang expression>) is the same as the corresponding field of library."
  • (library) says "The condition is specified using the Boolean Language, and the field allows for the %{os_type} variable, which is expanded to the type of OS being targeted by the current build."

However, I believe system is supposed to work. If I try a different variable name, dune says Error: Unknown variable %{baz}, which I infer to mean that it does understand system.

/cc @polytypic

Reproduction

$ ls
dune  dune-project  test.ml

$ cat dune
(test
 (name test)
 (enabled_if (= %{system} "foobar"))
 (modules test))

$ cat dune-project 
(lang dune 3.0)

$ cat test.ml 
BROKEN

$ dune build @all
File "test.ml", line 1, characters 0-6:
1 | BROKEN
    ^^^^^^
Error: Unbound constructor BROKEN

Specifications

  • Version of dune (output of dune --version): 3.6.1
  • Version of ocaml (output of ocamlc --version): 5.0.0
  • Operating system (distribution and version): Debian 11.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions