| 1 |
Test symlinks using absolute paths that point inside the target directory. |
| 2 |
Since we use realpath, these resolve correctly and work with caching. |
| 3 |
|
| 4 |
$ export DUNE_CACHE=enabled |
| 5 |
$ export DUNE_CACHE_ROOT=$PWD/_cache |
| 6 |
|
| 7 |
$ make_lockdir |
| 8 |
|
| 9 |
$ make_lockpkg foo <<EOF |
| 10 |
> (version 0.0.1) |
| 11 |
> (build |
| 12 |
> (system "\ |
| 13 |
> true BUILDING_FOO_PACKAGE \ |
| 14 |
> && mkdir -p %{lib}/%{pkg-self:name} \ |
| 15 |
> && printf 'real content\n' > %{lib}/%{pkg-self:name}/real.txt \ |
| 16 |
> && ln -s \$(realpath %{lib}/%{pkg-self:name}/real.txt) %{lib}/%{pkg-self:name}/link.txt \ |
| 17 |
> && touch %{lib}/%{pkg-self:name}/META")) |
| 18 |
> EOF |
| 19 |
|
| 20 |
$ cat > dune-project <<EOF |
| 21 |
> (lang dune 3.22) |
| 22 |
> (package |
| 23 |
> (name x) |
| 24 |
> (allow_empty) |
| 25 |
> (depends foo)) |
| 26 |
> EOF |
| 27 |
|
| 28 |
$ build_pkg foo |
| 29 |
|
| 30 |
Verify the build ran: |
| 31 |
|
| 32 |
$ count_trace BUILDING_FOO_PACKAGE |
| 33 |
1 |
| 34 |
|
| 35 |
The symlink is resolved to a regular file: |
| 36 |
|
| 37 |
$ dune_cmd stat kind $(get_build_pkg_dir foo)/target/lib/foo/link.txt |
| 38 |
regular file |
| 39 |
|
| 40 |
Both files are hardlinked: |
| 41 |
|
| 42 |
$ dune_cmd stat hardlinks $(get_build_pkg_dir foo)/target/lib/foo/real.txt |
| 43 |
3 |
| 44 |
$ dune_cmd stat hardlinks $(get_build_pkg_dir foo)/target/lib/foo/link.txt |
| 45 |
3 |
| 46 |
|
| 47 |
Clean and rebuild to verify cache restore: |
| 48 |
|
| 49 |
$ rm -rf _build |
| 50 |
$ build_pkg foo |
| 51 |
|
| 52 |
$ count_trace BUILDING_FOO_PACKAGE |
| 53 |
0 |