@@ -41,8 +41,6 @@ function setup_test_registries(dir = pwd())
4141 )
4242 write (
4343 joinpath (regpath, " Example" , " Deps.toml" ), """
44- ["0.5"]
45- julia = "0.6-1.0"
4644 """
4745 )
4846 write (
343341 end
344342 end
345343
344+ @testset " deprecated package" begin
345+ temp_pkg_dir () do depot
346+ # Set up test registries with an extra deprecated package
347+ regdir = mktempdir ()
348+ setup_test_registries (regdir)
349+
350+ # Add a deprecated package to the first registry
351+ regpath = joinpath (regdir, " RegistryFoo1" )
352+ mkpath (joinpath (regpath, " DeprecatedExample" ))
353+
354+ # Add the deprecated package to Registry.toml
355+ registry_toml = read (joinpath (regpath, " Registry.toml" ), String)
356+ registry_toml = replace (
357+ registry_toml,
358+ " [packages]" =>
359+ " [packages]\n 11111111-1111-1111-1111-111111111111 = { name = \" DeprecatedExample\" , path = \" DeprecatedExample\" }"
360+ )
361+ write (joinpath (regpath, " Registry.toml" ), registry_toml)
362+
363+ # Create deprecated package with [deprecated] table
364+ write (
365+ joinpath (regpath, " DeprecatedExample" , " Package.toml" ), """
366+ name = "DeprecatedExample"
367+ uuid = "11111111-1111-1111-1111-111111111111"
368+ repo = "https://github.com/test/DeprecatedExample.jl.git"
369+
370+ [deprecated]
371+ reason = "This package is no longer maintained"
372+ alternative = "Example"
373+ """
374+ )
375+
376+ write (
377+ joinpath (regpath, " DeprecatedExample" , " Versions.toml" ), """
378+ ["1.0.0"]
379+ git-tree-sha1 = "1234567890abcdef1234567890abcdef12345678"
380+ """
381+ )
382+
383+ git_init_and_commit (regpath)
384+
385+ # Add the test registry
386+ Pkg. Registry. add (url = regpath)
387+
388+ # Test that the package is marked as deprecated
389+ registries = Pkg. Registry. reachable_registries ()
390+ reg_idx = findfirst (r -> r. name == " RegistryFoo" , registries)
391+ @test reg_idx != = nothing
392+
393+ reg = registries[reg_idx]
394+ pkg_uuid = UUID (" 11111111-1111-1111-1111-111111111111" )
395+ @test haskey (reg, pkg_uuid)
396+
397+ pkg_entry = reg[pkg_uuid]
398+ pkg_info = Pkg. Registry. registry_info (pkg_entry)
399+
400+ # Test that deprecated info is loaded correctly
401+ @test Pkg. Registry. isdeprecated (pkg_info)
402+ @test pkg_info. deprecated != = nothing
403+ @test pkg_info. deprecated[" reason" ] == " This package is no longer maintained"
404+ @test pkg_info. deprecated[" alternative" ] == " Example"
405+
406+ # Test that non-deprecated package is not marked as deprecated
407+ example1_uuid = UUID (" c5f1542f-b8aa-45da-ab42-05303d706c66" )
408+ example1_entry = reg[example1_uuid]
409+ example1_info = Pkg. Registry. registry_info (example1_entry)
410+ @test ! Pkg. Registry. isdeprecated (example1_info)
411+ @test example1_info. deprecated === nothing
412+ end
413+ end
414+
346415 @testset " yanking" begin
347416 uuid = Base. UUID (" 7876af07-990d-54b4-ab0e-23690620f79a" ) # Example
348417 # Tests that [email protected] does not get installed
0 commit comments