@@ -43,6 +43,7 @@ testsets = [
4343 test_mkdir,
4444 test_cp,
4545 test_mv,
46+ test_sync,
4647 test_symlink,
4748 test_touch,
4849 test_tmpname,
@@ -103,6 +104,7 @@ module TestPaths
103104 test_mkdir,
104105 test_cp,
105106 test_mv,
107+ test_sync,
106108 test_symlink,
107109 test_touch,
108110 test_tmpname,
@@ -608,6 +610,39 @@ module TestPaths
608610 end
609611 end
610612
613+ function test_sync (ps:: PathSet )
614+ @testset " sync" begin
615+ # Base cp case
616+ sync (ps. foo, ps. qux / " foo" )
617+ @test exists (ps. qux / " foo" / " baz.txt" )
618+
619+ # Test that the copied baz file has a newer modified time
620+ baz_t = modified (ps. qux / " foo" / " baz.txt" )
621+ @test modified (ps. baz) < baz_t
622+
623+ # Don't cp unchanged files when a new file is added
624+ # NOTE: sleep before we make a new file, so it's clear tha the
625+ # modified time has changed.
626+ sleep (1 )
627+ write (ps. foo / " test.txt" , " New File" )
628+ sync (ps. foo, ps. qux / " foo" )
629+ @test exists (ps. qux / " foo" / " test.txt" )
630+ @test read (ps. qux / " foo" / " test.txt" , String) == " New File"
631+ @test modified (ps. qux / " foo" / " baz.txt" ) == baz_t
632+ @test modified (ps. qux / " foo" / " test.txt" ) > baz_t
633+
634+ # Test not deleting a file on sync
635+ rm (ps. foo / " test.txt" )
636+ sync (ps. foo, ps. qux / " foo" )
637+ @test exists (ps. qux / " foo" / " test.txt" )
638+
639+ # Test passing delete flag
640+ sync (ps. foo, ps. qux / " foo" ; delete= true )
641+ @test ! exists (ps. qux / " foo" / " test.txt" )
642+ rm (ps. qux / " foo" ; recursive= true )
643+ end
644+ end
645+
611646 function test_symlink (ps:: PathSet )
612647 if ps. link
613648 @testset " symlink" begin
0 commit comments