Skip to content

Commit e4bbfcf

Browse files
committed
test: Reproducer for refetching packages with file symlinks
This commit adds a test demonstrating the fact that even with the cache packages which contain file symlinks are refetched on fresh builds. The bug was discovered via a project that depends on the `menhir` project. Signed-off-by: Puneeth Chaganti <punchagan@muse-amuse.in>
1 parent ee485ee commit e4bbfcf

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
Documenting that sources with file symlinks are re-fetched every time. The
2+
menhir package is an example of such a package in the opam-repository. See
3+
`./fetch-cache.t` for a normal package test.
4+
5+
No need to set DUNE_CACHE (enabled by default) as the fetch rules are always
6+
considered safe to cache, but we'll set a custom directory for the shared
7+
cache.
8+
9+
$ export DUNE_CACHE_ROOT=$(pwd)/dune-cache
10+
$ unset DUNE_CACHE
11+
12+
Set up a project that depends on a package that is being downloaded. Note that
13+
the package being downloaded has a symlink.
14+
15+
$ make_lockdir
16+
$ echo "Contents" > tar-contents
17+
$ CONTENT_CHECKSUM=$(md5sum tar-contents | cut -f1 -d' ')
18+
$ ln -s tar-contents tar-symlink
19+
$ tar cf test.tar tar-contents tar-symlink
20+
$ echo test.tar > fake-curls
21+
$ SRC_PORT=1
22+
$ SRC_CHECKSUM=$(md5sum test.tar | cut -f1 -d' ')
23+
$ make_lockpkg test <<EOF
24+
> (version 0.0.1)
25+
> (source
26+
> (fetch
27+
> (url http://localhost:$SRC_PORT)
28+
> (checksum md5=$SRC_CHECKSUM)))
29+
> EOF
30+
$ cat > dune-project <<EOF
31+
> (lang dune 3.17)
32+
> (package (name my) (depends test) (allow_empty))
33+
> EOF
34+
35+
The first build should succeed, fetching the source, populating the cache and
36+
disabling the download of the source a second time.
37+
38+
$ build_pkg test
39+
40+
The file that was fetched is in the cache. The symlink would have the same contents, so wouldn't appear separately in the cache.
41+
42+
$ find $DUNE_CACHE_ROOT/db/files -type f -exec md5sum {} \; | grep --quiet $CONTENT_CHECKSUM
43+
44+
Cleaning the project to force rebuilding. If we attempt to build without the
45+
cache, it will fail, as the source is 404 now:
46+
47+
$ dune clean
48+
$ export DUNE_CACHE=disabled
49+
$ build_pkg test
50+
File "dune.lock/test.pkg", line 4, characters 7-25:
51+
4 | (url http://localhost:1)
52+
^^^^^^^^^^^^^^^^^^
53+
Error: Download failed with code 404
54+
55+
[1]
56+
57+
58+
Enabling the cache again also attempts to re-download the source, since it contains a symlink:
59+
60+
$ dune clean
61+
$ export DUNE_CACHE=enabled
62+
$ build_pkg test
63+
File "dune.lock/test.pkg", line 4, characters 7-25:
64+
4 | (url http://localhost:1)
65+
^^^^^^^^^^^^^^^^^^
66+
Error: Download failed with code 404
67+
68+
[1]
69+

0 commit comments

Comments
 (0)