Skip to content

Commit

Permalink
refactor some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fatteneder committed Aug 11, 2024
1 parent a752513 commit 79246a4
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions test/relocatedepot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,38 @@ end

if !test_relocated_depot

@testset "insert @depot tag in path" begin
@testset "edge cases when inserting @depot tag in path" begin

# insert @depot only once for first match
test_harness() do
mktempdir() do dir
pushfirst!(DEPOT_PATH, dir)
path = dir*dir
if Sys.iswindows()
# dirs start with a drive letter instead of a path separator
@test Base.replace_depot_path(path) == path
path = dir*Base.Filesystem.pathsep()*dir
@test Base.replace_depot_path(path) == "@depot"*Base.Filesystem.pathsep()*dir
else
path = dir*dir
@test Base.replace_depot_path(path) == "@depot"*dir
end
end

# 55340
empty!(DEPOT_PATH)
mktempdir() do dir
jlrc = joinpath(dir, "julia-rc2")
jl = joinpath(dir, "julia")
mkdir(jl)
push!(DEPOT_PATH, jl)
@test Base.replace_depot_path(jl) == "@depot"
@test Base.replace_depot_path(string(jl,Base.Filesystem.pathsep())) ==
string("@depot",Base.Filesystem.pathsep())
@test Base.replace_depot_path(jlrc) != "@depot-rc2"
@test Base.replace_depot_path(jlrc) == jlrc
end
end

# deal with and without trailing path separators
test_harness() do
mktempdir() do dir
pushfirst!(DEPOT_PATH, dir)
Expand All @@ -57,21 +74,6 @@ if !test_relocated_depot
end
end

# 55340
test_harness(empty_depot_path=true) do
mktempdir() do dir
jlrc = joinpath(dir, "julia-rc2")
jl = joinpath(dir, "julia")
mkdir(jl)
push!(DEPOT_PATH, jl)
@test Base.replace_depot_path(jl) == "@depot"
@test Base.replace_depot_path(string(jl,Base.Filesystem.pathsep())) ==
string("@depot",Base.Filesystem.pathsep())
@test Base.replace_depot_path(jlrc) != "@depot-rc2"
@test Base.replace_depot_path(jlrc) == jlrc
end
end

end

@testset "restore path from @depot tag" begin
Expand Down

0 comments on commit 79246a4

Please sign in to comment.