Skip to content

Commit 0e405b3

Browse files
peter1000mbauman
peter1000
authored andcommitted
Include hidden folder in cp tests
based on a comment by @tkelman JuliaLang#11024 (comment) I would like to add some tests for hidden folders
1 parent 85923ab commit 0e405b3

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

test/file.jl

+28-13
Original file line numberDiff line numberDiff line change
@@ -442,8 +442,12 @@ rm(cfile)
442442
@non_windowsxp_only begin
443443
function setup_dirs(tmpdir)
444444
srcdir = joinpath(tmpdir, "src")
445+
hidden_srcdir = joinpath(tmpdir, ".hidden_srcdir")
446+
hidden_srcsubdir = joinpath(hidden_srcdir, ".hidden_srcsubdir")
445447
srcdir_cp = joinpath(tmpdir, "srcdir_cp")
446448
mkdir(srcdir)
449+
mkdir(hidden_srcdir)
450+
mkdir(hidden_srcsubdir)
447451
abs_dirlink = joinpath(tmpdir, "abs_dirlink")
448452
symlink(abspath(srcdir), abs_dirlink)
449453
cd(tmpdir)
@@ -452,16 +456,22 @@ rm(cfile)
452456
cd(pwd_)
453457

454458
cfile = joinpath(srcdir, "c.txt")
459+
file_txt = "This is some text with unicode - 这是一个文件"
455460
open(cfile, "w") do cf
456-
write(cf, "This is c.txt with unicode - 这是一个文件")
461+
write(cf, file_txt)
462+
end
463+
hidden_cfile = joinpath(hidden_srcsubdir, "c.txt")
464+
open(hidden_cfile, "w") do cf
465+
write(cf, file_txt)
457466
end
458467

459468
abs_dirlink_cp = joinpath(tmpdir, "abs_dirlink_cp")
469+
hidden_srcsubdir_cp = joinpath(tmpdir, ".hidden_srcsubdir_cp")
460470
path_rel_dirlink = joinpath(tmpdir, rel_dirlink)
461471
path_rel_dirlink_cp = joinpath(tmpdir, "rel_dirlink_cp")
462472

463-
test_src_paths = [srcdir, abs_dirlink, path_rel_dirlink]
464-
test_cp_paths = [srcdir_cp, abs_dirlink_cp, path_rel_dirlink_cp]
473+
test_src_paths = [srcdir, hidden_srcsubdir, abs_dirlink, path_rel_dirlink]
474+
test_cp_paths = [srcdir_cp, hidden_srcsubdir_cp, abs_dirlink_cp, path_rel_dirlink_cp]
465475
return test_src_paths, test_cp_paths
466476
end
467477

@@ -545,11 +555,16 @@ end
545555
@unix_only begin
546556
function setup_files(tmpdir)
547557
srcfile = joinpath(tmpdir, "srcfile.txt")
558+
hidden_srcfile = joinpath(tmpdir, ".hidden_srcfile.txt")
548559
srcfile_cp = joinpath(tmpdir, "srcfile_cp.txt")
560+
hidden_srcfile_cp = joinpath(tmpdir, ".hidden_srcfile_cp.txt")
561+
file_txt = "This is some text with unicode - 这是一个文件"
549562
open(srcfile, "w") do f
550-
write(f, "This is srcfile.txt with unicode - 这是一个文件")
563+
write(f, file_txt)
564+
end
565+
open(hidden_srcfile, "w") do f
566+
write(f, file_txt)
551567
end
552-
srcfile_content = readall(srcfile)
553568
abs_filelink = joinpath(tmpdir, "abs_filelink")
554569
symlink(abspath(srcfile), abs_filelink)
555570
cd(tmpdir)
@@ -561,28 +576,28 @@ end
561576
path_rel_filelink = joinpath(tmpdir, rel_filelink)
562577
path_rel_filelink_cp = joinpath(tmpdir, "rel_filelink_cp")
563578

564-
test_src_paths = [srcfile, abs_filelink, path_rel_filelink]
565-
test_cp_paths = [srcfile_cp, abs_filelink_cp, path_rel_filelink_cp]
566-
return test_src_paths, test_cp_paths, srcfile_content
579+
test_src_paths = [srcfile, hidden_srcfile, abs_filelink, path_rel_filelink]
580+
test_cp_paths = [srcfile_cp, hidden_srcfile_cp, abs_filelink_cp, path_rel_filelink_cp]
581+
return test_src_paths, test_cp_paths, file_txt
567582
end
568583

569-
function cp_follow_symlinks_false_check(s, d, srcfile_content; remove_destination=false)
584+
function cp_follow_symlinks_false_check(s, d, file_txt; remove_destination=false)
570585
cp(s, d; remove_destination=remove_destination, follow_symlinks=false)
571586
@test isfile(s) == isfile(d)
572587
@test islink(s) == islink(d)
573588
islink(s) && @test readlink(s) == readlink(d)
574589
islink(s) && @test isabspath(readlink(s)) == isabspath(readlink(d))
575590
# all should contain the same
576-
@test readall(s) == readall(d) == srcfile_content
591+
@test readall(s) == readall(d) == file_txt
577592
end
578593

579594
## Test require `remove_destination=true` (remove destination first) for existing
580595
# files and existing links to files
581596
mktempdir() do tmpdir
582597
# Setup new copies for the test
583-
test_src_paths, test_cp_paths, srcfile_content = setup_files(tmpdir)
598+
test_src_paths, test_cp_paths, file_txt = setup_files(tmpdir)
584599
for (s, d) in zip(test_src_paths, test_cp_paths)
585-
cp_follow_symlinks_false_check(s, d, srcfile_content)
600+
cp_follow_symlinks_false_check(s, d, file_txt)
586601
end
587602
# Test require `remove_destination=true`
588603
for s in test_src_paths
@@ -593,7 +608,7 @@ end
593608
end
594609
# Test remove the existing path first and copy: follow_symlinks=false
595610
for (s, d) in zip(test_src_paths, test_cp_paths)
596-
cp_follow_symlinks_false_check(s, d, srcfile_content; remove_destination=true)
611+
cp_follow_symlinks_false_check(s, d, file_txt; remove_destination=true)
597612
end
598613
# Test remove the existing path first and copy an other file
599614
otherfile = joinpath(tmpdir, "otherfile.txt")

0 commit comments

Comments
 (0)