From 51e0a516809e1f594b5dcd84898736b4b23b71a5 Mon Sep 17 00:00:00 2001 From: Rudi Grinberg Date: Wed, 21 Jul 2021 00:32:58 -0700 Subject: [PATCH] Add test for strange behavior from #4786 Signed-off-by: Rudi Grinberg --- .../test-cases/optional-executable.t/run.t | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/test/blackbox-tests/test-cases/optional-executable.t/run.t b/test/blackbox-tests/test-cases/optional-executable.t/run.t index 15dacb084ba6..cd6a27c47cbc 100644 --- a/test/blackbox-tests/test-cases/optional-executable.t/run.t +++ b/test/blackbox-tests/test-cases/optional-executable.t/run.t @@ -52,3 +52,38 @@ The following command should fail because the executable is not optional: ^^^^^^^^^^^^^^ Error: Library "does-not-exist" not found. [1] + +A strange behavior discovered in #4786. Dune would ignore an executable if any +of its dependencies were optional. + + $ mkdir optional-binary + $ cd optional-binary + $ cat >dune-project < (lang dune 3.0) + > (package (name myfoo)) + > EOF + + $ mkdir exe + $ cat >exe/bar.ml < print_endline "hello world" + > EOF + $ cat >exe/dune < (executable (public_name dunetestbar) (name bar) (libraries foo)) + > EOF + + $ mkdir lib + $ cat >lib/dune < (library (name foo) (libraries xxx-does-not-exist) (optional) (modules ())) + > EOF + + $ cat >dune < (rule + > (alias run-x) + > (action (echo %{exe:bar.exe}))) + > EOF + + $ dune build @run-x + Error: No rule found for bar.exe + -> required by %{exe:bar.exe} at dune:3 + -> required by alias run-x in dune:1 + [1]