Skip to content

Commit

Permalink
windows accepts '\\' and '/' as path separators
Browse files Browse the repository at this point in the history
  • Loading branch information
fatteneder committed Aug 9, 2024
1 parent 668d2b8 commit 5041cd3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
7 changes: 7 additions & 0 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3123,6 +3123,9 @@ mutable struct CacheHeaderIncludes
end

function replace_depot_path(path::AbstractString)
@static if Sys.iswindows()
path = replace(path, Filesystem.path_separator_re=>Filesystem.pathsep())
end
for depot in DEPOT_PATH
!isdir(depot) && continue

Expand All @@ -3131,6 +3134,10 @@ function replace_depot_path(path::AbstractString)
depot = dirname(depot)
end

@static if Sys.iswindows()
depot = replace(depot, Filesystem.path_separator_re=>Filesystem.pathsep())
end

if startswith(path, string(depot, Filesystem.pathsep())) || path == depot
path = replace(path, depot => "@depot"; count=1)
break
Expand Down
15 changes: 15 additions & 0 deletions test/relocatedepot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ if !test_relocated_depot
@test Base.replace_depot_path(jlrc) != "@depot-rc2"
@test Base.replace_depot_path(jlrc) == jlrc
end
if Sys.iswindows()
# windows accepts '\\' and '/' as path separators
mktempdir() do dir
jlrc = string(dir, "/", "julia-rc2")
jl = string(dir, "/", "julia")
mkdir(jl)
push!(DEPOT_PATH, jl)
@test Base.replace_depot_path(jl) == "@depot"
@test Base.replace_depot_path(string(jl,"/")) == string("@depot","\\")
@test Base.replace_depot_path(string(jl,"\\")) == string("@depot","\\")
@test Base.replace_depot_path(jlrc) != "@depot-rc2"
@test Base.replace_depot_path(jlrc) ==
replace(jlrc, Base.Filesystem.path_separator_re=>"\\")
end
end
end

end
Expand Down

0 comments on commit 5041cd3

Please sign in to comment.