Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cram: demonstrate bug with %{bin:public_binary} and absolute DUNE_BUILD_DIR #6326

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ Unreleased

- Build progress status now shows number of failed jobs (#6242, @Alizter)

- Allow absolute build directories to find public executables. For example,
those specified with `(deps %{bin:...})` (#6326, @anmonteiro)

3.5.0 (2022-10-19)
------------------

Expand Down
3 changes: 1 addition & 2 deletions src/dune_rules/context.ml
Original file line number Diff line number Diff line change
Expand Up @@ -514,9 +514,8 @@ let create ~(kind : Kind.t) ~path ~env ~env_nodes ~name ~merlin ~targets
else env
in
let env =
let cwd = Sys.getcwd () in
let extend_var var ?(path_sep = Bin.path_sep) v =
let v = Filename.concat cwd (Path.Build.to_string v) in
rgrinberg marked this conversation as resolved.
Show resolved Hide resolved
let v = Path.to_absolute_filename (Path.build v) in
match Env.get env var with
| None -> (var, v)
| Some prev -> (var, sprintf "%s%c%s" v path_sep prev)
Expand Down
30 changes: 30 additions & 0 deletions test/blackbox-tests/test-cases/cram/public-name.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Cram and public binaries with an absolute build directory

$ cat >dune-project <<EOF
> (lang dune 2.8)
> (cram enable)
> (name public-name-exe-test)
> EOF
$ touch public-name-exe-test.opam

$ mkdir helper
$ cat >helper/dune <<EOF
> (executable (public_name helper))
> EOF
$ cat >helper/helper.ml <<EOF
> print_endline "Helper launched successfully";;
> EOF

$ mkdir tests
$ cat >tests/run.t <<EOF
> $ helper
> Helper launched successfully
> EOF
$ echo "(cram (deps %{bin:helper}))" > tests/dune

Running `dune runtest` with a relative build directory works

$ DUNE_BUILD_DIR=./_other_build dune runtest

$ export NEW_BUILD_DIR="$PWD/_other_build"
$ DUNE_BUILD_DIR="$NEW_BUILD_DIR" dune runtest --auto-promote