Skip to content

Commit 545ffd5

Browse files
committed
Also collect manifest entries from target deps when testing / building. (#572)
1 parent a612684 commit 545ffd5

File tree

9 files changed

+74
-14
lines changed

9 files changed

+74
-14
lines changed

stdlib/Pkg/src/Operations.jl

+20-14
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,19 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag
791791
need_to_resolve = false
792792
is_project = Types.is_project(localctx.env, pkg)
793793

794+
# Only put `pkg` and its deps + target deps (recursively) in the temp project
795+
collect_deps!(seen, pkg) = begin
796+
pkg.uuid in seen && return
797+
push!(seen, pkg.uuid)
798+
info = manifest_info(localctx.env, pkg.uuid)
799+
info === nothing && return
800+
need_to_resolve |= haskey(info, "path")
801+
localctx.env.project["deps"][pkg.name] = string(pkg.uuid)
802+
for (dpkg, duuid) in get(info, "deps", [])
803+
collect_deps!(seen, PackageSpec(dpkg, UUID(duuid)))
804+
end
805+
end
806+
794807
if is_project # testing the project itself
795808
# the project might have changes made to it so need to resolve
796809
need_to_resolve = true
@@ -807,23 +820,11 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag
807820
)]
808821
else
809822
# Only put `pkg` and its deps (recursively) in the temp project
810-
collect_deps!(seen, pkg) = begin
811-
pkg.uuid in seen && return
812-
push!(seen, pkg.uuid)
813-
info = manifest_info(localctx.env, pkg.uuid)
814-
need_to_resolve |= haskey(info, "path")
815-
localctx.env.project["deps"][pkg.name] = string(pkg.uuid)
816-
for (dpkg, duuid) in get(info, "deps", [])
817-
collect_deps!(seen, PackageSpec(dpkg, UUID(duuid)))
818-
end
819-
end
820-
# Only put `pkg` and its deps (revursively) in the temp project
821823
empty!(localctx.env.project["deps"])
822824
localctx.env.project["deps"][pkg.name] = string(pkg.uuid)
823-
824825
seen_uuids = Set{UUID}()
825-
collect_deps!(seen_uuids, pkg)# Only put `pkg` and its deps (recursively) in the temp project
826-
826+
# Only put `pkg` and its deps (recursively) in the temp project
827+
collect_deps!(seen_uuids, pkg)
827828
end
828829

829830
pkgs = PackageSpec[]
@@ -833,6 +834,11 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag
833834
end
834835
if !isempty(target)
835836
collect_target_deps!(localctx, pkgs, pkg, target)
837+
seen_uuids = Set{UUID}()
838+
for dpkg in pkgs
839+
# Also put eventual deps of target deps in new manifest
840+
collect_deps!(seen_uuids, dpkg)
841+
end
836842
end
837843

838844
mktempdir() do tmpdir

stdlib/Pkg/test/pkg.jl

+12
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,18 @@ temp_pkg_dir() do project_path
435435
end
436436
end
437437

438+
@testset "dependency of test dependency (#567)" begin
439+
mktempdir() do tmpdir
440+
temp_pkg_dir() do project_path; cd(tmpdir) do; with_temp_env() do
441+
for x in ["x1", "x2", "x3"]
442+
cp(joinpath(@__DIR__, "test_packages/$x"), joinpath(tmpdir, "$x"))
443+
Pkg.develop(Pkg.PackageSpec(url = joinpath(tmpdir, x)))
444+
end
445+
Pkg.test("x3")
446+
end end end
447+
end
448+
end
449+
438450
include("repl.jl")
439451
include("api.jl")
440452

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name = "x1"
2+
uuid = "52033f98-96b1-11e8-17f9-4d5b643961d8"
3+
version = "0.1.0"
4+
5+
[deps]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module x1
2+
3+
greet() = print("Hello World!")
4+
5+
end # module
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
name = "x2"
2+
uuid = "52baf49e-96b1-11e8-23dd-2d073a3a6758"
3+
version = "0.1.0"
4+
5+
[deps]
6+
x1 = "52033f98-96b1-11e8-17f9-4d5b643961d8"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module x2
2+
3+
greet() = print("Hello World!")
4+
5+
end # module
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
name = "x3"
2+
uuid = "53501efc-96b1-11e8-0d90-e1a45c33f0f8"
3+
version = "0.1.0"
4+
5+
[extras]
6+
x2 = "52baf49e-96b1-11e8-23dd-2d073a3a6758"
7+
8+
[targets]
9+
test = ["x2"]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module x3
2+
3+
greet() = print("Hello World!")
4+
5+
end # module
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module X3Tests
2+
3+
using x2
4+
5+
println("hello")
6+
7+
end # module

0 commit comments

Comments
 (0)