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

test: exhibit a bug when promoting directories #11213

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
77 changes: 77 additions & 0 deletions test/blackbox-tests/test-cases/promote/deep-subdir.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
Tests for promoting directory targets
-------------------------------------

$ cat > dune-project << EOF
> (lang dune 3.0)
> (using directory-targets 0.1)
> EOF

$ cat > dune << EOF
> (rule
> (deps
> (source_tree deep))
> (targets
> (dir deep_copied))
> (mode promote)
> (action
> (run cp -r deep deep_copied)))
> EOF

Let's create the directory structure we are going to promote (as a copy on
another dir):

$ mkdir -p deep/a/
$ touch deep/a/deep_file
$ touch deep/base_file

Let's try this:

$ dune build deep_copied

This one works. Now, let's add a layer between base_file and deep_file:

$ rm -rf deep
$ mkdir -p deep/a/b/
$ touch deep/a/b/deep_file
$ touch deep/base_file

$ dune build deep_copied --verbose
Shared cache: enabled-except-user-rules
Shared cache location: /home/panglesd/.cache/dune/db
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the non --verbose run be enough? Otherwise you need to figure out paths and things that might change.

Workspace root:
$TESTCASE_ROOT
Dune context:
{ name = "default"
; kind = "default"
; profile = Dev
; merlin = true
; fdo_target_exe = None
; build_dir = In_build_dir "default"
; instrument_with = []
}
Actual targets:
- _build/default/deep_copied
Running[1]: (cd _build/default && /usr/bin/cp -r deep deep_copied)
Promoting "_build/default/deep_copied/a/b/deep_file" to
"deep_copied/a/b/deep_file"
File "dune", lines 1-7, characters 0-121:
1 | (rule
2 | (deps
3 | (source_tree deep))
4 | (targets (dir deep_copied))
5 | (mode promote)
6 | (action
7 | (run cp -r deep deep_copied)))
Error: Cannot promote files to "deep_copied/a/b".
Reason: opendir(deep_copied/a/b): No such file or directory
-> required by _build/default/deep_copied
[1]

It does not work! Note that the `base_file` is required. For instance, move it
to `a/`, or remove it, and it works:

$ mv deep/base_file deep/a/
$ dune build deep_copied

$ rm deep/a/base_file
$ dune build deep_copied
Loading