Skip to content

Commit 73b71c5

Browse files
authored
Fix tests
1 parent 390734d commit 73b71c5

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

test/loading.jl

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,6 +702,15 @@ mktempdir() do dir
702702
@test success(cmd)
703703
end
704704

705+
function _with_empty_load_path(f::Function)
706+
old_load_path = copy(Base.LOAD_PATH)
707+
try
708+
empty!(Base.LOAD_PATH)
709+
f()
710+
finally
711+
append!(Base.LOAD_PATH, old_load_path)
712+
end
713+
end
705714
old_act_proj = Base.ACTIVE_PROJECT[]
706715
function _with_activate(f::Function, project_file::Union{AbstractString, Nothing})
707716
try
@@ -727,6 +736,8 @@ end
727736
@testset "active_manifest() - no argument passed" begin
728737
for (proj, expected_man) in test_cases
729738
@test _activate_and_get_active_manifest_noarg(proj) == expected_man
739+
# Base.active_manifest() should never return a file that doesn't exist:
740+
@test isfile_activate_and_get_active_manifest_noarg(proj))
730741
end
731742
mktempdir() do dir
732743
proj = joinpath(dir, "Project.toml")
@@ -742,6 +753,8 @@ end
742753
manif = joinpath(dir, "Manifest.toml")
743754
touch(manif)
744755
@test _activate_and_get_active_manifest_noarg(proj) == manif
756+
# Base.active_manifest() should never return a file that doesn't exist:
757+
@test isfile(_activate_and_get_active_manifest_noarg(proj))
745758

746759
# If the manifest file exists but the project file does not, active_manifest() should return `nothing`:
747760
rm(proj)
@@ -753,6 +766,8 @@ end
753766
Base.ACTIVE_PROJECT[] = old_act_proj
754767
for (proj, expected_man) in test_cases
755768
@test Base.active_manifest(proj) == expected_man
769+
# Base.active_manifest() should never return a file that doesn't exist:
770+
@test isfile(Base.active_manifest(proj))
756771
end
757772
mktempdir() do dir
758773
proj = joinpath(dir, "Project.toml")
@@ -768,6 +783,8 @@ end
768783
manif = joinpath(dir, "Manifest.toml")
769784
touch(manif)
770785
@test Base.active_manifest(proj) == manif
786+
# Base.active_manifest() should never return a file that doesn't exist:
787+
@test isfile(Base.active_manifest(proj))
771788

772789
# If the manifest file exists but the project file does not, active_manifest(proj) should return `nothing`:
773790
rm(proj)
@@ -776,10 +793,10 @@ end
776793
end
777794

778795
@testset "ACTIVE_PROJECT[] is `nothing` => active_manifest() is nothing" begin
779-
_with_activate(nothing) do
796+
_with_activate(nothing) do; _with_empty_load_path() do
780797
@test Base.active_manifest() === nothing
781798
@test Base.active_manifest(nothing) === nothing
782-
end
799+
end; end
783800
end
784801

785802
@testset "Project file does not exist => active_manifest() is nothing" begin

0 commit comments

Comments
 (0)