Skip to content

Commit

Permalink
add a test for weak deps
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Dec 12, 2022
1 parent 60d43cc commit 1bbc788
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 7 deletions.
19 changes: 19 additions & 0 deletions test/project_files/Example19.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name = "Example"
uuid = "d7508571-2240-4c50-b21c-240e414cc6d2"
version = "1.1.0"

[deps]
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[weakdeps]
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
julia = "1.1"
UUIDs = "1.8"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
57 changes: 50 additions & 7 deletions test/regedit.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ const TEST_SIGNATURE = LibGit2.Signature(
TEST_GITCONFIG["user.email"],
)

function create_empty_registry(registry_path, registry_name, registry_uuid)
mkpath(registry_path)
registry_file = joinpath(registry_path, "Registry.toml")
registry_data = RegistryTools.RegistryData(registry_name, registry_uuid)
RegistryTools.write_registry(registry_file, registry_data)
end

@testset "RegistryTools" begin

@testset "Utilities" begin
Expand Down Expand Up @@ -240,13 +247,6 @@ end
end
end

function create_empty_registry(registry_path, registry_name, registry_uuid)
mkpath(registry_path)
registry_file = joinpath(registry_path, "Registry.toml")
registry_data = RegistryTools.RegistryData(registry_name, registry_uuid)
RegistryTools.write_registry(registry_file, registry_data)
end

@testset "find_package_in_registry" begin
import RegistryTools: find_package_in_registry
mktempdir(@__DIR__) do temp_dir
Expand Down Expand Up @@ -772,6 +772,49 @@ end
end
end

if RegistryTools.PKG_HAS_WEAK
@testset "weakdeps" begin
import RegistryTools: ReturnStatus, check_and_update_registry_files
import Pkg.Types: read_project

temp_dir = mktempdir(; cleanup=false)
mktempdir(@__DIR__) do temp_dir
registry_path = joinpath(temp_dir, "registry")
projects_path = joinpath(@__DIR__, "project_files")
registry_deps_paths = String[]
tree_hash = repeat("0", 40)
# Start with an empty registry.
create_empty_registry(registry_path, "TestRegistry",
"d4e2f5cd-0f48-4704-9988-f1754e755b45")
project_file = joinpath(projects_path, "Example19.toml")
pkg = read_project(project_file)
status = ReturnStatus()
package_repo = "http://example.com/Example1.git"
check_and_update_registry_files(pkg, package_repo, tree_hash,
registry_path,
registry_deps_paths, status)
path = RegistryTools.package_relpath("Example")
@test read(joinpath(registry_path, path, "Compat.toml"), String) ==
"""
[1]
UUIDs = "1.8.0-1"
julia = "1.1.0-1"
"""
@test read(joinpath(registry_path, path, "WeakCompat.toml"), String) ==
"""
[1]
UUIDs = "1.8.0-1"
"""
@test read(joinpath(registry_path, path, "Deps.toml"), String) ==
read(joinpath(registry_path, path, "WeakDeps.toml"), String) ==
"""
[1]
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
"""
end
end
end

@testset "The `RegistryTools.package_relpath` function" begin
@test RegistryTools.package_relpath("Example") == "E/Example"
end
Expand Down

0 comments on commit 1bbc788

Please sign in to comment.