Skip to content

Commit 0e68eb2

Browse files
authored
test: enabled_if restriction within executable stanza (#14848)
This commit adds a cram test from the reproducer in #14789 to demonstrate the restricted set of allowed_vars in enabled_if used within the exectuable stanza.
2 parents 1e40496 + 3e596e0 commit 0e68eb2

6 files changed

Lines changed: 60 additions & 0 deletions

File tree

test/blackbox-tests/test-cases/enabled_if/enabled_if-exec-read.t/config/disabled

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let () = print_endline "should be disabled!"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
(executable
2+
(name main)
3+
;; The config file is in a subdirectory to avoid the spurious cycles in
4+
;; enabled_if. See the enabled_if/eif-library-cycle.t test for instance.
5+
(enabled_if (= %{read:./config/enable_executable} "true")))
6+
7+
(executable
8+
(name disabled)
9+
(enabled_if (= %{read:./config/disabled} "true")))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
let () = print_endline "hello"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
Test that `enabled_if` fields work as expected for executables with read pform.
2+
3+
Check that enabled_if doesn't work before dune lang 2.3
4+
5+
$ make_dune_project 2.0
6+
$ dune exec ./main.exe
7+
File "dune", line 5, characters 1-59:
8+
5 | (enabled_if (= %{read:./config/enable_executable} "true")))
9+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10+
Error: 'enabled_if' is only available since version 2.3 of the dune language.
11+
Please update your dune-project file to have (lang dune 2.3).
12+
[1]
13+
14+
Check that only common vars are allowed in enabled_if within the executable
15+
stanza in older dune lang versions:
16+
17+
$ make_dune_project 3.0
18+
$ dune exec ./main.exe
19+
File "dune", line 5, characters 16-50:
20+
5 | (enabled_if (= %{read:./config/enable_executable} "true")))
21+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22+
Error: Only architecture, system, model, os_type, ccomp_type, profile,
23+
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
24+
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
25+
[1]
26+
27+
Check that the executable is correctly enabled:
28+
29+
$ make_dune_project 3.24
30+
$ dune exec ./main.exe
31+
File "dune", line 5, characters 16-50:
32+
5 | (enabled_if (= %{read:./config/enable_executable} "true")))
33+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
34+
Error: Only architecture, system, model, os_type, ccomp_type, profile,
35+
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
36+
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
37+
[1]
38+
39+
Check that the executable is correctly disabled:
40+
41+
$ dune exec ./disabled.exe
42+
File "dune", line 5, characters 16-50:
43+
5 | (enabled_if (= %{read:./config/enable_executable} "true")))
44+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
45+
Error: Only architecture, system, model, os_type, ccomp_type, profile,
46+
ocaml_version, context_name, arch_sixtyfour and env variables are allowed in
47+
this 'enabled_if' field. Please upgrade your dune language to at least 3.15.
48+
[1]

0 commit comments

Comments
 (0)