Skip to content

Commit

Permalink
use abspath to be more accurate when matching depots
Browse files Browse the repository at this point in the history
  • Loading branch information
fatteneder committed Aug 10, 2024
1 parent 5041cd3 commit fc8a17e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 25 deletions.
15 changes: 5 additions & 10 deletions base/loading.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3122,28 +3122,23 @@ mutable struct CacheHeaderIncludes
const modpath::Vector{String} # seemingly not needed in Base, but used by Revise
end

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

# Strip extraneous pathseps through normalization.
if isdirpath(depot)
depot = dirname(depot)
end

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

if startswith(path, string(depot, Filesystem.pathsep())) || path == depot
path = replace(path, depot => "@depot"; count=1)
break
return path
end
end
return path
return the_path
end

function restore_depot_path(path::AbstractString, depot::AbstractString)
Expand Down
15 changes: 0 additions & 15 deletions test/relocatedepot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,6 @@ 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 fc8a17e

Please sign in to comment.