I’m developing an executable and want to cram-test it. But I don’t know a way to add a strict dependency from tests to my executable. MVP. The call dune build @install && dune test helps but I want a dependency…
➜ dune-exec-cram-demo git:(master) ✗ cat test.t/run.t 4.12.1+flambda
$ dune build
$ echo $PATH
$ which asdf
[1]
$ asdf
asdf: not found
[127]
$ qwe
qwe: not found
[127]
➜ dune-exec-cram-demo git:(master) ✗ cat test.t/dune 4.12.1+flambda
(cram
(deps
%{workspace_root}/src/asdf
%{workspace_root}/src/asdf.exe
%{bin:asdf}
%{bin:qwe}
%{workspace_root}/qwe.exe))
(library
(name lib1)
(modules lib1))
In dune-release we use the following to depend on our binary that is installed (has a public_name) and one that is not installed (just a helper for cleaning test output):
(env
(_
(binaries
(../helpers/make_dune_release_deterministic.exe as
make_dune_release_deterministic))))
(cram
(deps %{bin:dune-release} %{bin:make_dune_release_deterministic}))
So weirdly I don’t get the same result as you, and for me it works…
I don’t think the dune files inside the test.t should do anything according to Writing and Running Tests — dune documentation
It also works for me without test.t/dune and test.t/dune-project, but with
I needed to specify that executables are used in cram tests in dune file where I define executables, not in dune files for tests. Wondering why dune didn’t show any warning about that…