Skip to content

Commit

Permalink
Also collect manifest entries from target deps when testing / buildin…
Browse files Browse the repository at this point in the history
…g. (#572)
  • Loading branch information
KristofferC committed Aug 4, 2018
1 parent 8a11d20 commit 36e6681
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 14 deletions.
34 changes: 20 additions & 14 deletions stdlib/Pkg/src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,19 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag
need_to_resolve = false
is_project = Types.is_project(localctx.env, pkg)

# Only put `pkg` and its deps + target deps (recursively) in the temp project
collect_deps!(seen, pkg) = begin
pkg.uuid in seen && return
push!(seen, pkg.uuid)
info = manifest_info(localctx.env, pkg.uuid)
info === nothing && return
need_to_resolve |= haskey(info, "path")
localctx.env.project["deps"][pkg.name] = string(pkg.uuid)
for (dpkg, duuid) in get(info, "deps", [])
collect_deps!(seen, PackageSpec(dpkg, UUID(duuid)))
end
end

if is_project # testing the project itself
# the project might have changes made to it so need to resolve
need_to_resolve = true
Expand All @@ -807,23 +820,11 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag
)]
else
# Only put `pkg` and its deps (recursively) in the temp project
collect_deps!(seen, pkg) = begin
pkg.uuid in seen && return
push!(seen, pkg.uuid)
info = manifest_info(localctx.env, pkg.uuid)
need_to_resolve |= haskey(info, "path")
localctx.env.project["deps"][pkg.name] = string(pkg.uuid)
for (dpkg, duuid) in get(info, "deps", [])
collect_deps!(seen, PackageSpec(dpkg, UUID(duuid)))
end
end
# Only put `pkg` and its deps (revursively) in the temp project
empty!(localctx.env.project["deps"])
localctx.env.project["deps"][pkg.name] = string(pkg.uuid)

seen_uuids = Set{UUID}()
collect_deps!(seen_uuids, pkg)# Only put `pkg` and its deps (recursively) in the temp project

# Only put `pkg` and its deps (recursively) in the temp project
collect_deps!(seen_uuids, pkg)
end

pkgs = PackageSpec[]
Expand All @@ -833,6 +834,11 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag
end
if !isempty(target)
collect_target_deps!(localctx, pkgs, pkg, target)
seen_uuids = Set{UUID}()
for dpkg in pkgs
# Also put eventual deps of target deps in new manifest
collect_deps!(seen_uuids, dpkg)
end
end

mktempdir() do tmpdir
Expand Down
12 changes: 12 additions & 0 deletions stdlib/Pkg/test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,18 @@ temp_pkg_dir() do project_path
end
end

@testset "dependency of test dependency (#567)" begin
mktempdir() do tmpdir
temp_pkg_dir() do project_path; cd(tmpdir) do; with_temp_env() do
for x in ["x1", "x2", "x3"]
cp(joinpath(@__DIR__, "test_packages/$x"), joinpath(tmpdir, "$x"))
Pkg.develop(Pkg.PackageSpec(url = joinpath(tmpdir, x)))
end
Pkg.test("x3")
end end end
end
end

include("repl.jl")
include("api.jl")

Expand Down
5 changes: 5 additions & 0 deletions stdlib/Pkg/test/test_packages/x1/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
name = "x1"
uuid = "52033f98-96b1-11e8-17f9-4d5b643961d8"
version = "0.1.0"

[deps]
5 changes: 5 additions & 0 deletions stdlib/Pkg/test/test_packages/x1/src/x1.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module x1

greet() = print("Hello World!")

end # module
6 changes: 6 additions & 0 deletions stdlib/Pkg/test/test_packages/x2/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name = "x2"
uuid = "52baf49e-96b1-11e8-23dd-2d073a3a6758"
version = "0.1.0"

[deps]
x1 = "52033f98-96b1-11e8-17f9-4d5b643961d8"
5 changes: 5 additions & 0 deletions stdlib/Pkg/test/test_packages/x2/src/x2.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module x2

greet() = print("Hello World!")

end # module
9 changes: 9 additions & 0 deletions stdlib/Pkg/test/test_packages/x3/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name = "x3"
uuid = "53501efc-96b1-11e8-0d90-e1a45c33f0f8"
version = "0.1.0"

[extras]
x2 = "52baf49e-96b1-11e8-23dd-2d073a3a6758"

[targets]
test = ["x2"]
5 changes: 5 additions & 0 deletions stdlib/Pkg/test/test_packages/x3/src/x3.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module x3

greet() = print("Hello World!")

end # module
7 changes: 7 additions & 0 deletions stdlib/Pkg/test/test_packages/x3/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module X3Tests

using x2

println("hello")

end # module

0 comments on commit 36e6681

Please sign in to comment.