@@ -37,15 +37,27 @@ using JSON
37
37
# Fetch again the repo to make sure cache works
38
38
@test @test_logs (:info , r" ^Cached repository found in" ) download_source (gs; verbose = true , downloads_dir = dir) == sgs
39
39
# Fetch the temp directory as a `DirectorySource`
40
- ds = DirectorySource (" ./bundled " )
41
- patchdir = abspath (joinpath (dir, ds . path, " patches " ))
40
+ ds_follow = DirectorySource (" ./bundled_follow " ; follow_symlinks = true )
41
+ patchdir = abspath (joinpath (dir, ds_follow . path, " patches_follow " ))
42
42
mkpath (patchdir)
43
43
write (abspath (joinpath (patchdir, " fix-windows-headers.patch" )), " This is a patch file" )
44
44
# Create a symlink. We'll want to check that `setup` follows symlinks
45
45
link = joinpath (patchdir, " link.patch" )
46
46
symlink (" fix-windows-headers.patch" , link)
47
47
@test islink (link)
48
- sds = @test_logs (:info , r" ^Directory .* found" ) download_source (ds; verbose = true )
48
+ sds_follow = @test_logs (:info , r" ^Directory .* found" ) download_source (ds_follow; verbose = true )
49
+ # Try to fetch a non-existing directory
50
+ @test_throws ErrorException download_source (DirectorySource (joinpath (dir, " does_not_exist" )); verbose = true )
51
+ # Another directory source, which doesn't follow symlinks
52
+ ds_nofollow = DirectorySource (" ./bundled_nofollow" )
53
+ patchdir = abspath (joinpath (dir, ds_nofollow. path, " patches_nofollow" ))
54
+ mkpath (patchdir)
55
+ write (abspath (joinpath (patchdir, " fix-windows-headers.patch" )), " This is a patch file" )
56
+ # Create a symlink. We'll want to check that `setup` follows symlinks
57
+ link = joinpath (patchdir, " link.patch" )
58
+ symlink (" fix-windows-headers.patch" , link)
59
+ @test islink (link)
60
+ sds_nofollow = @test_logs (:info , r" ^Directory .* found" ) download_source (ds_nofollow; verbose = true )
49
61
# Try to fetch a non-existing directory
50
62
@test_throws ErrorException download_source (DirectorySource (joinpath (dir, " does_not_exist" )); verbose = true )
51
63
@@ -60,21 +72,29 @@ using JSON
60
72
target = joinpath (srcdir, gs. unpack_target)
61
73
@test_logs (:info , " Cloning ARCHDefs.git to ARCHDefs..." ) setup (sgs, target, true )
62
74
@test isdir (target)
63
- target = abspath (joinpath (srcdir, " patches" ))
64
- @test_logs (:info , " Copying content of bundled in srcdir..." ) setup (sds, srcdir, true )
75
+ # Setup directory source with links to follow
76
+ target = abspath (joinpath (srcdir, " patches_follow" ))
77
+ @test_logs (:info , " Copying content of bundled_follow in srcdir..." ) setup (sds_follow, srcdir, true )
65
78
@test isdir (target)
66
79
# Make sure that the symlinks are followed
67
80
@test isfile (joinpath (target, " link.patch" ))
68
81
@test ! islink (joinpath (target, " link.patch" ))
82
+ # Setup directory source with links to not follow
83
+ target = abspath (joinpath (srcdir, " patches_nofollow" ))
84
+ @test_logs (:info , " Copying content of bundled_nofollow in srcdir..." ) setup (sds_nofollow, srcdir, true )
85
+ @test isdir (target)
86
+ # Make sure that the symlinks are not followed
87
+ @test isfile (joinpath (target, " link.patch" ))
88
+ @test islink (joinpath (target, " link.patch" ))
69
89
70
90
# Make sure in srcdir there are all files and directories we expect
71
- @test Set (readdir (srcdir)) == Set ([" ARCHDefs" , " ARCHDefs-2.0.3x" , fs. filename, " patches " ])
91
+ @test Set (readdir (srcdir)) == Set ([" ARCHDefs" , " ARCHDefs-2.0.3x" , fs. filename, " patches_follow " , " patches_nofollow " ])
72
92
73
93
# Setup the sources with `setup_workspace`
74
94
workspace = joinpath (dir, " workspace" )
75
95
mkpath (workspace)
76
- prefix = @test_logs (:info , r" ^Copying" ) (:info , r" ^Copying" ) (:info , r" ^Cloning" ) setup_workspace (workspace, [sfs, sds , sgs]; verbose= true )
77
- @test Set (readdir (joinpath (prefix. path, " srcdir" ))) == Set ([" ARCHDefs" , " file-source.tar.gz" , " patches " ])
96
+ prefix = @test_logs (:info , r" ^Copying" ) (:info , r" ^Copying" ) (:info , r" ^Copying " ) ( :info , r" ^ Cloning" ) setup_workspace (workspace, [sfs, sds_follow, sds_nofollow , sgs]; verbose= true )
97
+ @test Set (readdir (joinpath (prefix. path, " srcdir" ))) == Set ([" ARCHDefs" , " file-source.tar.gz" , " patches_follow " , " patches_nofollow " ])
78
98
end
79
99
end
80
100
end
@@ -95,7 +115,7 @@ using JSON
95
115
@test jgs == Dict (" type" => " git" , " url" => gs. url, " hash" => gs. hash, " unpack_target" => gs. unpack_target)
96
116
@test sourcify (jgs) == gs
97
117
jds = JSON. lower (ds)
98
- @test jds == Dict (" type" => " directory" , " path" => ds. path, " target" => " " )
118
+ @test jds == Dict (" type" => " directory" , " path" => ds. path, " target" => " " , " follow_symlinks " => false )
99
119
@test sourcify (jds) == ds
100
120
101
121
@test_throws ErrorException sourcify (Dict (" type" => " error" ))
0 commit comments