795795@testset " `Base.project_names` and friends" begin
796796 # Some functions in Pkg assumes that these tuples have the same length
797797 n = length (Base. project_names)
798+ @test length (Base. manifest_names) == n
798799 @test length (Base. preferences_names) == n
799-
800- # there are two manifest names per project name
801- @test length (Base. manifest_names) == 2 n
802800end
803801
804802@testset " Manifest formats" begin
827825 end
828826end
829827
830- @testset " Manifest name preferential loading" begin
831- mktempdir () do tmp
832- proj = joinpath (tmp, " Project.toml" )
833- touch (proj)
834- for man_name in (
835- " Manifest.toml" ,
836- " JuliaManifest.toml" ,
837- " Manifest-v$(VERSION . major) .$(VERSION . minor) .toml" ,
838- " JuliaManifest-v$(VERSION . major) .$(VERSION . minor) .toml"
839- )
840- touch (joinpath (tmp, man_name))
841- man = basename (Base. project_file_manifest_path (proj))
842- @test man == man_name
843- end
844- end
845- mktempdir () do tmp
846- # check that another version isn't preferred
847- proj = joinpath (tmp, " Project.toml" )
848- touch (proj)
849- touch (joinpath (tmp, " Manifest-v1.5.toml" ))
850- @test Base. project_file_manifest_path (proj) == nothing
851- touch (joinpath (tmp, " Manifest.toml" ))
852- man = basename (Base. project_file_manifest_path (proj))
853- @test man == " Manifest.toml"
854- end
855- end
856-
857828@testset " error message loading pkg bad module name" begin
858829 mktempdir () do tmp
859830 old_loadpath = copy (LOAD_PATH )
@@ -1033,16 +1004,6 @@ end
10331004end
10341005
10351006@testset " Extensions" begin
1036- test_ext = """
1037- function test_ext(parent::Module, ext::Symbol)
1038- _ext = Base.get_extension(parent, ext)
1039- _ext isa Module || error("expected extension \$ ext to be loaded")
1040- _pkgdir = pkgdir(_ext)
1041- _pkgdir == pkgdir(parent) != nothing || error("unexpected extension \$ ext pkgdir path: \$ _pkgdir")
1042- _pkgversion = pkgversion(_ext)
1043- _pkgversion == pkgversion(parent) || error("unexpected extension \$ ext version: \$ _pkgversion")
1044- end
1045- """
10461007 depot_path = mktempdir ()
10471008 try
10481009 proj = joinpath (@__DIR__ , " project" , " Extensions" , " HasDepWithExtensions.jl" )
@@ -1053,25 +1014,20 @@ end
10531014 cmd = """
10541015 $load_distr
10551016 begin
1056- $ew $test_ext
10571017 $ew push!(empty!(DEPOT_PATH), $(repr (depot_path)) )
10581018 using HasExtensions
10591019 $ew using HasExtensions
10601020 $ew Base.get_extension(HasExtensions, :Extension) === nothing || error("unexpectedly got an extension")
10611021 $ew HasExtensions.ext_loaded && error("ext_loaded set")
10621022 using HasDepWithExtensions
10631023 $ew using HasDepWithExtensions
1064- $ew test_ext(HasExtensions, :Extension)
10651024 $ew Base.get_extension(HasExtensions, :Extension).extvar == 1 || error("extvar in Extension not set")
10661025 $ew HasExtensions.ext_loaded || error("ext_loaded not set")
10671026 $ew HasExtensions.ext_folder_loaded && error("ext_folder_loaded set")
10681027 $ew HasDepWithExtensions.do_something() || error("do_something errored")
10691028 using ExtDep2
10701029 $ew using ExtDep2
10711030 $ew HasExtensions.ext_folder_loaded || error("ext_folder_loaded not set")
1072- using ExtDep3
1073- $ew using ExtDep3
1074- $ew HasExtensions.ext_dep_loaded || error("ext_dep_loaded not set")
10751031 end
10761032 """
10771033 return ` $(Base. julia_cmd ()) $compile --startup-file=no -e $cmd `
@@ -1114,14 +1070,11 @@ end
11141070
11151071 test_ext_proj = """
11161072 begin
1117- $test_ext
11181073 using HasExtensions
11191074 using ExtDep
1120- test_ext (HasExtensions, :Extension)
1075+ Base.get_extension (HasExtensions, :Extension) isa Module || error("expected extension to load" )
11211076 using ExtDep2
1122- test_ext(HasExtensions, :ExtensionFolder)
1123- using ExtDep3
1124- test_ext(HasExtensions, :ExtensionDep)
1077+ Base.get_extension(HasExtensions, :ExtensionFolder) isa Module || error("expected extension to load")
11251078 end
11261079 """
11271080 for compile in (` --compiled-modules=no` , ` ` )
@@ -1131,40 +1084,23 @@ end
11311084 run (cmd_proj_ext)
11321085 end
11331086
1134- # Extensions for "parent" dependencies
1135- # (i.e. an `ExtAB` where A depends on / loads B, but B provides the extension)
1136-
1137- mktempdir () do depot # Parallel pre-compilation
1138- code = """
1139- Base.disable_parallel_precompile = false
1140- using Parent
1141- Base.get_extension(getfield(Parent, :DepWithParentExt), :ParentExt) isa Module || error("expected extension to load")
1142- Parent.greet()
1143- """
1144- proj = joinpath (@__DIR__ , " project" , " Extensions" , " Parent.jl" )
1145- cmd = ` $(Base. julia_cmd ()) --startup-file=no -e $code `
1146- cmd = addenv (cmd,
1147- " JULIA_LOAD_PATH" => proj,
1148- " JULIA_DEPOT_PATH" => depot * Base. Filesystem. pathsep (),
1149- )
1150- @test occursin (" Hello parent!" , String (read (cmd)))
1151- end
1152- mktempdir () do depot # Serial pre-compilation
1153- code = """
1154- Base.disable_parallel_precompile = true
1155- using Parent
1156- Base.get_extension(getfield(Parent, :DepWithParentExt), :ParentExt) isa Module || error("expected extension to load")
1157- Parent.greet()
1158- """
1159- proj = joinpath (@__DIR__ , " project" , " Extensions" , " Parent.jl" )
1160- cmd = ` $(Base. julia_cmd ()) --startup-file=no -e $code `
1161- cmd = addenv (cmd,
1162- " JULIA_LOAD_PATH" => proj,
1163- " JULIA_DEPOT_PATH" => depot * Base. Filesystem. pathsep (),
1164- )
1165- @test occursin (" Hello parent!" , String (read (cmd)))
1166- end
1167-
1087+ # Sysimage extensions
1088+ # The test below requires that LinearAlgebra is in the sysimage and that it has not been loaded yet.
1089+ # if it gets moved out, this test will need to be updated.
1090+ # We run this test in a new process so we are not vulnerable to a previous test having loaded LinearAlgebra
1091+ sysimg_ext_test_code = """
1092+ uuid_key = Base.PkgId(Base.UUID("37e2e46d-f89d-539d-b4ee-838fcccc9c8e"), "LinearAlgebra")
1093+ Base.in_sysimage(uuid_key) || error("LinearAlgebra not in sysimage")
1094+ haskey(Base.explicit_loaded_modules, uuid_key) && error("LinearAlgebra already loaded")
1095+ using HasExtensions
1096+ Base.get_extension(HasExtensions, :LinearAlgebraExt) === nothing || error("unexpectedly got an extension")
1097+ using LinearAlgebra
1098+ haskey(Base.explicit_loaded_modules, uuid_key) || error("LinearAlgebra not loaded")
1099+ Base.get_extension(HasExtensions, :LinearAlgebraExt) isa Module || error("expected extension to load")
1100+ """
1101+ cmd = ` $(Base. julia_cmd ()) --startup-file=no -e $sysimg_ext_test_code `
1102+ cmd = addenv (cmd, " JULIA_LOAD_PATH" => join ([proj, " @stdlib" ], sep))
1103+ run (cmd)
11681104 finally
11691105 try
11701106 rm (depot_path, force= true , recursive= true )
@@ -1265,28 +1201,3 @@ end
12651201@testset " Upgradable stdlibs" begin
12661202 @test success (` $(Base. julia_cmd ()) --startup-file=no -e 'using DelimitedFiles'` )
12671203end
1268-
1269- @testset " Fallback for stdlib deps if manifest deps aren't found" begin
1270- mktempdir () do depot
1271- # This manifest has a LibGit2 entry that is missing LibGit2_jll, which should be
1272- # handled by falling back to the stdlib Project.toml for dependency truth.
1273- badmanifest_test_dir = joinpath (@__DIR__ , " project" , " deps" , " BadStdlibDeps.jl" )
1274- @test success (addenv (
1275- ` $(Base. julia_cmd ()) --project=$badmanifest_test_dir --startup-file=no -e 'using LibGit2'` ,
1276- " JULIA_DEPOT_PATH" => depot * Base. Filesystem. pathsep (),
1277- ))
1278- end
1279- end
1280-
1281- @testset " extension path computation name collision" begin
1282- old_load_path = copy (LOAD_PATH )
1283- try
1284- empty! (LOAD_PATH )
1285- push! (LOAD_PATH , joinpath (@__DIR__ , " project" , " Extensions" , " ExtNameCollision_A" ))
1286- push! (LOAD_PATH , joinpath (@__DIR__ , " project" , " Extensions" , " ExtNameCollision_B" ))
1287- ext_B = Base. PkgId (Base. uuid5 (Base. identify_package (" ExtNameCollision_B" ). uuid, " REPLExt" ), " REPLExt" )
1288- @test Base. locate_package (ext_B) == joinpath (@__DIR__ , " project" , " Extensions" , " ExtNameCollision_B" , " ext" , " REPLExt.jl" )
1289- finally
1290- copy! (LOAD_PATH , old_load_path)
1291- end
1292- end
0 commit comments