forked from ocaml/dune
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes ocaml#6938 The semantics of `(enabled_if)` in `(test)` can be confusing: `(test)` can be seen as the combination of `(executable)` and a `(rule (alias runtest))`; but `(enabled_if)` actually only controls the "running" part, not the "building" one. This adds a new `(skip_build)` field in `(test)`. When present, the semantics of `(enabled_if)` extend to building the test executable. In other words, if the `(enabled_if)` field of such a stanza evaluates to `false`, it is as if the stanza was not present. Signed-off-by: Etienne Millon <me@emillon.org>
- Loading branch information
Showing
5 changed files
with
61 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
$ cat > dune-project << EOF | ||
> (lang dune 3.8) | ||
> EOF | ||
|
||
The enabled_if field evaluates to true then BUILD=true is passed. | ||
|
||
$ cat > dune << EOF | ||
> (test | ||
> (name t) | ||
> (enabled_if %{env:BUILD=false}) | ||
> (skip_build)) | ||
> EOF | ||
|
||
$ cat > t.ml << EOF | ||
> broken | ||
> EOF | ||
|
||
Version check: this only works on 3.9+. | ||
|
||
$ dune build | ||
File "dune", line 4, characters 1-13: | ||
4 | (skip_build)) | ||
^^^^^^^^^^^^ | ||
Error: 'skip_build' is only available since version 3.9 of the dune language. | ||
Please update your dune-project file to have (lang dune 3.9). | ||
[1] | ||
|
||
$ cat > dune-project << EOF | ||
> (lang dune 3.9) | ||
> EOF | ||
|
||
The build is attempted only when the enabled_if clause evaluates to true. | ||
|
||
$ dune build | ||
$ BUILD=true dune build | ||
File "t.ml", line 1, characters 0-6: | ||
1 | broken | ||
^^^^^^ | ||
Error: Unbound value broken | ||
[1] |