diff --git a/base/loading.jl b/base/loading.jl index 057aa793aa5ed..43b2b7e23923b 100644 --- a/base/loading.jl +++ b/base/loading.jl @@ -11,7 +11,7 @@ elseif is_windows() # GetLongPathName Win32 function returns the case-preserved filename on NTFS. function isfile_casesensitive(path) isfile(path) || return false # Fail fast - Filesystem.longpath(path) == path + basename(Filesystem.longpath(path)) == basename(path) end elseif is_apple() # HFS+ filesystem is case-preserving. The getattrlist API returns diff --git a/test/loading.jl b/test/loading.jl index f876b21def25a..c53d15532a212 100644 --- a/test/loading.jl +++ b/test/loading.jl @@ -15,18 +15,26 @@ thefname = "the fname!//\\&\1*" @test @__DIR__() == dirname(@__FILE__) # Issue #5789 and PR #13542: -let true_filename = "cAsEtEsT.jl", lowered_filename="casetest.jl" - touch(true_filename) - @test Base.isfile_casesensitive(true_filename) - @test !Base.isfile_casesensitive(lowered_filename) - rm(true_filename) -end +cd(mktempdir()) do + let true_filename = "cAsEtEsT.jl", lowered_filename="casetest.jl" + touch(true_filename) + @test Base.isfile_casesensitive(true_filename) + @test !Base.isfile_casesensitive(lowered_filename) + + # check that case-sensitivity only applies to basename of a path: + if isfile(lowered_filename) # case-insensitive filesystem + mkdir("cAsEtEsT") + touch(joinpath("cAsEtEsT", true_filename)) + @test Base.isfile_casesensitive(joinpath("casetest", true_filename)) + @test !Base.isfile_casesensitive(joinpath("casetest", lowered_filename)) + end + end -# Test Unicode normalization; pertinent for OS X -let nfc_name = "\U00F4.jl" - touch(nfc_name) - @test Base.isfile_casesensitive(nfc_name) - rm(nfc_name) + # Test Unicode normalization; pertinent for OS X + let nfc_name = "\U00F4.jl" + touch(nfc_name) + @test Base.isfile_casesensitive(nfc_name) + end end let paddedname = "Ztest_sourcepath.jl"