Skip to content

Commit 006d914

Browse files
committed
Update and complete tests
Signed-off-by: Ulysse Gérard <thevoodoos@gmail.com>
1 parent 760d604 commit 006d914

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

test/blackbox-tests/test-cases/enabled_if-exec/dune

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(dirs :standard \ forbidden_var install)
1+
(dirs :standard \ forbidden_var install var_context_name)
22

33
(executable
44
(name main)

test/blackbox-tests/test-cases/enabled_if-exec/run.t

+35-9
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@ Tests for enabled_if in install stanza using forbidden variable.
2828
File "dune", line 6, characters 18-31:
2929
6 | (enabled_if (= %{project_root} ""))
3030
^^^^^^^^^^^^^
31-
Error: Only architecture, system, model, os_type, ccomp_type, profile and
32-
ocaml_version variables are allowed in this 'enabled_if' field. If you think
33-
that project_root should also be allowed, please file an issue about it.
31+
Error: Only architecture, system, model, os_type, ccomp_type, profile,
32+
ocaml_version and context_name variables are allowed in this 'enabled_if'
33+
field. If you think that project_root should also be allowed, please file an
34+
issue about it.
3435
[1]
3536

3637
The next ones use forbidden variables
@@ -43,9 +44,10 @@ For dune 2.3 -> 2.5 it is a warning
4344
File "dune", line 3, characters 19-32:
4445
3 | (enabled_if (<> %{project_root} "")))
4546
^^^^^^^^^^^^^
46-
Warning: Only architecture, system, model, os_type, ccomp_type, profile and
47-
ocaml_version variables are allowed in this 'enabled_if' field. If you think
48-
that project_root should also be allowed, please file an issue about it.
47+
Warning: Only architecture, system, model, os_type, ccomp_type, profile,
48+
ocaml_version and context_name variables are allowed in this 'enabled_if'
49+
field. If you think that project_root should also be allowed, please file an
50+
issue about it.
4951
Entering directory 'forbidden_var'
5052
bar
5153

@@ -58,7 +60,31 @@ For dune >= 2.6 it is an error
5860
File "dune", line 3, characters 19-32:
5961
3 | (enabled_if (<> %{project_root} "")))
6062
^^^^^^^^^^^^^
61-
Error: Only architecture, system, model, os_type, ccomp_type, profile and
62-
ocaml_version variables are allowed in this 'enabled_if' field. If you think
63-
that project_root should also be allowed, please file an issue about it.
63+
Error: Only architecture, system, model, os_type, ccomp_type, profile,
64+
ocaml_version and context_name variables are allowed in this 'enabled_if'
65+
field. If you think that project_root should also be allowed, please file an
66+
issue about it.
6467
[1]
68+
69+
70+
For dune < 2.7 context_name is not allowed
71+
$ cat > var_context_name/dune-project <<EOF
72+
> (lang dune 2.6)
73+
> EOF
74+
$ dune exec ./foo.exe --root var_context_name
75+
Entering directory 'var_context_name'
76+
File "dune", line 3, characters 18-31:
77+
3 | (enabled_if (= %{context_name} "default")))
78+
^^^^^^^^^^^^^
79+
Error: This variable is only available since version 2.7 of the dune
80+
language. Please update your dune-project file to have (lang dune 2.7).
81+
[1]
82+
83+
For dune >= 2.7 context_name allowed
84+
$ cat > var_context_name/dune-project <<EOF
85+
> (lang dune 2.7)
86+
> EOF
87+
$ dune exec ./foo.exe --root var_context_name
88+
Entering directory 'var_context_name'
89+
Entering directory 'var_context_name'
90+
bar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
(executable
2+
(name foo)
3+
(enabled_if (= %{context_name} "default")))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
print_string "bar"

0 commit comments

Comments
 (0)