From 56183f201f546d12270a6d0265aca046dae5e9f6 Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Thu, 10 Nov 2016 08:58:47 -0500 Subject: [PATCH 1/2] make isfile_casesensitive only check case of the basename on Windows, consistent with other platforms --- base/loading.jl | 2 +- test/loading.jl | 30 +++++++++++++++++++----------- 2 files changed, 20 insertions(+), 12 deletions(-) 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" From 9db40bd2910298aeaac62233282a0c51df3e11bc Mon Sep 17 00:00:00 2001 From: "Steven G. Johnson" Date: Thu, 10 Nov 2016 10:34:55 -0500 Subject: [PATCH 2/2] rm tempdir after test --- test/loading.jl | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/test/loading.jl b/test/loading.jl index c53d15532a212..01865b0379b65 100644 --- a/test/loading.jl +++ b/test/loading.jl @@ -15,25 +15,27 @@ thefname = "the fname!//\\&\1*" @test @__DIR__() == dirname(@__FILE__) # Issue #5789 and PR #13542: -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)) +mktempdir() do dir + cd(dir) 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 - end - # Test Unicode normalization; pertinent for OS X - let nfc_name = "\U00F4.jl" - touch(nfc_name) - @test Base.isfile_casesensitive(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 end