| 1 |
Test behavior when a package creates nested symlinks (symlink pointing to symlink). |
| 2 |
|
| 3 |
$ export DUNE_CACHE=enabled |
| 4 |
$ export DUNE_CACHE_ROOT=$PWD/_cache |
| 5 |
|
| 6 |
$ make_lockdir |
| 7 |
|
| 8 |
Create a package with nested symlinks: link2 -> link1 -> real.txt |
| 9 |
|
| 10 |
$ make_lockpkg foo <<EOF |
| 11 |
> (version 0.0.1) |
| 12 |
> (build |
| 13 |
> (system "\ |
| 14 |
> true BUILDING_FOO_PACKAGE \ |
| 15 |
> && mkdir -p %{lib}/%{pkg-self:name} \ |
| 16 |
> && printf 'real content\n' > %{lib}/%{pkg-self:name}/real.txt \ |
| 17 |
> && ln -s real.txt %{lib}/%{pkg-self:name}/link1.txt \ |
| 18 |
> && ln -s link1.txt %{lib}/%{pkg-self:name}/link2.txt \ |
| 19 |
> && touch %{lib}/%{pkg-self:name}/META")) |
| 20 |
> EOF |
| 21 |
|
| 22 |
$ cat > dune-project <<EOF |
| 23 |
> (lang dune 3.22) |
| 24 |
> (package |
| 25 |
> (name x) |
| 26 |
> (allow_empty) |
| 27 |
> (depends foo)) |
| 28 |
> EOF |
| 29 |
|
| 30 |
Build the package: |
| 31 |
|
| 32 |
$ build_pkg foo |
| 33 |
|
| 34 |
Verify the build ran: |
| 35 |
|
| 36 |
$ count_trace BUILDING_FOO_PACKAGE |
| 37 |
1 |
| 38 |
|
| 39 |
Check that the files exist: |
| 40 |
|
| 41 |
$ ls $(get_build_pkg_dir foo)/target/lib/foo | sort |
| 42 |
META |
| 43 |
link1.txt |
| 44 |
link2.txt |
| 45 |
real.txt |
| 46 |
|
| 47 |
All symlinks should be resolved to regular files (hardlinks): |
| 48 |
|
| 49 |
$ dune_cmd stat kind $(get_build_pkg_dir foo)/target/lib/foo/real.txt |
| 50 |
regular file |
| 51 |
$ dune_cmd stat kind $(get_build_pkg_dir foo)/target/lib/foo/link1.txt |
| 52 |
regular file |
| 53 |
$ dune_cmd stat kind $(get_build_pkg_dir foo)/target/lib/foo/link2.txt |
| 54 |
regular file |
| 55 |
|
| 56 |
All should have the same content: |
| 57 |
|
| 58 |
$ cat $(get_build_pkg_dir foo)/target/lib/foo/link1.txt |
| 59 |
real content |
| 60 |
$ cat $(get_build_pkg_dir foo)/target/lib/foo/link2.txt |
| 61 |
real content |
| 62 |
|
| 63 |
Check hardlink counts - all three should be hardlinked to the same inode: |
| 64 |
|
| 65 |
$ dune_cmd stat hardlinks $(get_build_pkg_dir foo)/target/lib/foo/real.txt |
| 66 |
4 |
| 67 |
|
| 68 |
Clean and rebuild to verify cache restore: |
| 69 |
|
| 70 |
$ rm -rf _build |
| 71 |
$ build_pkg foo |
| 72 |
|
| 73 |
The build command should not be rerun since it will be restored from cache: |
| 74 |
|
| 75 |
$ count_trace BUILDING_FOO_PACKAGE |
| 76 |
0 |