@@ -37,15 +37,27 @@ using JSON
3737 # Fetch again the repo to make sure cache works
3838 @test @test_logs (:info , r" ^Cached repository found in" ) download_source (gs; verbose = true , downloads_dir = dir) == sgs
3939 # 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 " ))
4242 mkpath (patchdir)
4343 write (abspath (joinpath (patchdir, " fix-windows-headers.patch" )), " This is a patch file" )
4444 # Create a symlink. We'll want to check that `setup` follows symlinks
4545 link = joinpath (patchdir, " link.patch" )
4646 symlink (" fix-windows-headers.patch" , link)
4747 @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 )
4961 # Try to fetch a non-existing directory
5062 @test_throws ErrorException download_source (DirectorySource (joinpath (dir, " does_not_exist" )); verbose = true )
5163
@@ -60,21 +72,29 @@ using JSON
6072 target = joinpath (srcdir, gs. unpack_target)
6173 @test_logs (:info , " Cloning ARCHDefs.git to ARCHDefs..." ) setup (sgs, target, true )
6274 @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 )
6578 @test isdir (target)
6679 # Make sure that the symlinks are followed
6780 @test isfile (joinpath (target, " link.patch" ))
6881 @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" ))
6989
7090 # 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 " ])
7292
7393 # Setup the sources with `setup_workspace`
7494 workspace = joinpath (dir, " workspace" )
7595 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 " ])
7898 end
7999 end
80100 end
@@ -95,7 +115,7 @@ using JSON
95115 @test jgs == Dict (" type" => " git" , " url" => gs. url, " hash" => gs. hash, " unpack_target" => gs. unpack_target)
96116 @test sourcify (jgs) == gs
97117 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 )
99119 @test sourcify (jds) == ds
100120
101121 @test_throws ErrorException sourcify (Dict (" type" => " error" ))
0 commit comments