From 79246a42ea7787870aaaf5e00dad576e9f83b99d Mon Sep 17 00:00:00 2001 From: Florian Atteneder Date: Sun, 11 Aug 2024 12:58:33 +0200 Subject: [PATCH] refactor some tests --- test/relocatedepot.jl | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/test/relocatedepot.jl b/test/relocatedepot.jl index cb6468e7bd147..653128e70e44f 100644 --- a/test/relocatedepot.jl +++ b/test/relocatedepot.jl @@ -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) @@ -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