Skip to content

Commit 5041cd3

Browse files
committed
windows accepts '\\' and '/' as path separators
1 parent 668d2b8 commit 5041cd3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

base/loading.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3123,6 +3123,9 @@ mutable struct CacheHeaderIncludes
31233123
end
31243124

31253125
function replace_depot_path(path::AbstractString)
3126+
@static if Sys.iswindows()
3127+
path = replace(path, Filesystem.path_separator_re=>Filesystem.pathsep())
3128+
end
31263129
for depot in DEPOT_PATH
31273130
!isdir(depot) && continue
31283131

@@ -3131,6 +3134,10 @@ function replace_depot_path(path::AbstractString)
31313134
depot = dirname(depot)
31323135
end
31333136

3137+
@static if Sys.iswindows()
3138+
depot = replace(depot, Filesystem.path_separator_re=>Filesystem.pathsep())
3139+
end
3140+
31343141
if startswith(path, string(depot, Filesystem.pathsep())) || path == depot
31353142
path = replace(path, depot => "@depot"; count=1)
31363143
break

test/relocatedepot.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,21 @@ if !test_relocated_depot
7070
@test Base.replace_depot_path(jlrc) != "@depot-rc2"
7171
@test Base.replace_depot_path(jlrc) == jlrc
7272
end
73+
if Sys.iswindows()
74+
# windows accepts '\\' and '/' as path separators
75+
mktempdir() do dir
76+
jlrc = string(dir, "/", "julia-rc2")
77+
jl = string(dir, "/", "julia")
78+
mkdir(jl)
79+
push!(DEPOT_PATH, jl)
80+
@test Base.replace_depot_path(jl) == "@depot"
81+
@test Base.replace_depot_path(string(jl,"/")) == string("@depot","\\")
82+
@test Base.replace_depot_path(string(jl,"\\")) == string("@depot","\\")
83+
@test Base.replace_depot_path(jlrc) != "@depot-rc2"
84+
@test Base.replace_depot_path(jlrc) ==
85+
replace(jlrc, Base.Filesystem.path_separator_re=>"\\")
86+
end
87+
end
7388
end
7489

7590
end

0 commit comments

Comments
 (0)