-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix joinpath on Windows and improve joinpath on linux #33477
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -31,15 +31,33 @@ | |||||
@test isdirpath(S("..")) | ||||||
end | ||||||
@testset "joinpath" begin | ||||||
@test joinpath(S("")) == "" | ||||||
@test joinpath(S("foo")) == "foo" | ||||||
@test joinpath(S("foo"), S("bar")) == "foo$(sep)bar" | ||||||
@test joinpath(S("foo"), S("bar"), S("baz")) == "foo$(sep)bar$(sep)baz" | ||||||
@test joinpath(S("foo"), S(""), S("baz")) == "foo$(sep)baz" | ||||||
@test joinpath(S("foo"), S(""), S("")) == "foo$(sep)" | ||||||
@test joinpath(S("foo"), S(""), S(""), S("bar")) == "foo$(sep)bar" | ||||||
|
||||||
@test joinpath(S("foo"), S(homedir())) == homedir() | ||||||
@test joinpath(S(abspath("foo")), S(homedir())) == homedir() | ||||||
|
||||||
if Sys.iswindows() | ||||||
@test joinpath(S("foo"),S("bar:baz")) == "bar:baz" | ||||||
@test joinpath(S("C:"),S("foo"),S("D:"),S("bar")) == "D:bar" | ||||||
@test joinpath(S("C:"),S("foo"),S("D:bar"),S("baz")) == "D:bar$(sep)baz" | ||||||
|
||||||
# relative folders and case-insensitive drive letters | ||||||
@test joinpath(S("C:\\a\\b"), S("c:c\\e")) == "c:\\a\\b\\c\\e" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the earlier or later capitalization of the drive name be kept? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The preference is to keep the later capitalization. This follows the general rule to prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does Python do here? I would think that in the case where There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Python keeps the later capitalization. But it doesn't really matter, since it is case-insentive. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's interesting. I was thinking that this might affect the definition of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, honestly I haven't had a close look at There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
And change this test. |
||||||
|
||||||
# UNC paths | ||||||
@test joinpath(S("\\\\server"), S("share")) == "\\\\server\\share" | ||||||
@test joinpath(S("\\\\server"), S("share"), S("a")) == "\\\\server\\share\\a" | ||||||
@test joinpath(S("\\\\server\\"), S("share"), S("a")) == "\\\\server\\share\\a" | ||||||
@test joinpath(S("\\\\server"), S("share"), S("a"), S("b")) == "\\\\server\\share\\a\\b" | ||||||
@test joinpath(S("\\\\server\\share"),S("a")) == "\\\\server\\share\\a" | ||||||
@test joinpath(S("\\\\server\\share\\"), S("a")) == "\\\\server\\share\\a" | ||||||
|
||||||
elseif Sys.isunix() | ||||||
@test joinpath(S("foo"),S("bar:baz")) == "foo$(sep)bar:baz" | ||||||
@test joinpath(S("C:"),S("foo"),S("D:"),S("bar")) == "C:$(sep)foo$(sep)D:$(sep)bar" | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just delete this line, I think.