Skip to content

Commit 1062aec

Browse files
committed
Add test for strange behavior from #4786
Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
1 parent a1ea3dd commit 1062aec

File tree

1 file changed

+35
-0
lines changed
  • test/blackbox-tests/test-cases/optional-executable.t

1 file changed

+35
-0
lines changed

test/blackbox-tests/test-cases/optional-executable.t/run.t

+35
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,38 @@ The following command should fail because the executable is not optional:
5252
^^^^^^^^^^^^^^
5353
Error: Library "does-not-exist" not found.
5454
[1]
55+
56+
A strange behavior discovered in #4786. Dune would ignore an executable if any
57+
of its dependencies were optional.
58+
59+
$ mkdir optional-binary
60+
$ cd optional-binary
61+
$ cat >dune-project <<EOF
62+
> (lang dune 3.0)
63+
> (package (name myfoo))
64+
> EOF
65+
66+
$ mkdir exe
67+
$ cat >exe/bar.ml <<EOF
68+
> print_endline "hello world"
69+
> EOF
70+
$ cat >exe/dune <<EOF
71+
> (executable (public_name dunetestbar) (name bar) (libraries foo))
72+
> EOF
73+
74+
$ mkdir lib
75+
$ cat >lib/dune <<EOF
76+
> (library (name foo) (libraries xxx-does-not-exist) (optional) (modules ()))
77+
> EOF
78+
79+
$ cat >dune <<EOF
80+
> (rule
81+
> (alias run-x)
82+
> (action (echo %{exe:bar.exe})))
83+
> EOF
84+
85+
$ dune build @run-x
86+
Error: No rule found for bar.exe
87+
-> required by %{exe:bar.exe} at dune:3
88+
-> required by alias run-x in dune:1
89+
[1]

0 commit comments

Comments
 (0)