From 36e66814323e8c28969f40414ad2ef28058c2c90 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Fri, 3 Aug 2018 22:45:15 +0200 Subject: [PATCH] Also collect manifest entries from target deps when testing / building. (#572) --- stdlib/Pkg/src/Operations.jl | 34 +++++++++++-------- stdlib/Pkg/test/pkg.jl | 12 +++++++ stdlib/Pkg/test/test_packages/x1/Project.toml | 5 +++ stdlib/Pkg/test/test_packages/x1/src/x1.jl | 5 +++ stdlib/Pkg/test/test_packages/x2/Project.toml | 6 ++++ stdlib/Pkg/test/test_packages/x2/src/x2.jl | 5 +++ stdlib/Pkg/test/test_packages/x3/Project.toml | 9 +++++ stdlib/Pkg/test/test_packages/x3/src/x3.jl | 5 +++ .../test/test_packages/x3/test/runtests.jl | 7 ++++ 9 files changed, 74 insertions(+), 14 deletions(-) create mode 100644 stdlib/Pkg/test/test_packages/x1/Project.toml create mode 100644 stdlib/Pkg/test/test_packages/x1/src/x1.jl create mode 100644 stdlib/Pkg/test/test_packages/x2/Project.toml create mode 100644 stdlib/Pkg/test/test_packages/x2/src/x2.jl create mode 100644 stdlib/Pkg/test/test_packages/x3/Project.toml create mode 100644 stdlib/Pkg/test/test_packages/x3/src/x3.jl create mode 100644 stdlib/Pkg/test/test_packages/x3/test/runtests.jl diff --git a/stdlib/Pkg/src/Operations.jl b/stdlib/Pkg/src/Operations.jl index 858019b6ae02e0..fd04ff86cff1c2 100644 --- a/stdlib/Pkg/src/Operations.jl +++ b/stdlib/Pkg/src/Operations.jl @@ -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 @@ -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[] @@ -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 diff --git a/stdlib/Pkg/test/pkg.jl b/stdlib/Pkg/test/pkg.jl index 6538a4bba0d88b..459672847f9ce6 100644 --- a/stdlib/Pkg/test/pkg.jl +++ b/stdlib/Pkg/test/pkg.jl @@ -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") diff --git a/stdlib/Pkg/test/test_packages/x1/Project.toml b/stdlib/Pkg/test/test_packages/x1/Project.toml new file mode 100644 index 00000000000000..1026a589fde5c9 --- /dev/null +++ b/stdlib/Pkg/test/test_packages/x1/Project.toml @@ -0,0 +1,5 @@ +name = "x1" +uuid = "52033f98-96b1-11e8-17f9-4d5b643961d8" +version = "0.1.0" + +[deps] diff --git a/stdlib/Pkg/test/test_packages/x1/src/x1.jl b/stdlib/Pkg/test/test_packages/x1/src/x1.jl new file mode 100644 index 00000000000000..bd929422af3f46 --- /dev/null +++ b/stdlib/Pkg/test/test_packages/x1/src/x1.jl @@ -0,0 +1,5 @@ +module x1 + +greet() = print("Hello World!") + +end # module diff --git a/stdlib/Pkg/test/test_packages/x2/Project.toml b/stdlib/Pkg/test/test_packages/x2/Project.toml new file mode 100644 index 00000000000000..ada91ef334f7c0 --- /dev/null +++ b/stdlib/Pkg/test/test_packages/x2/Project.toml @@ -0,0 +1,6 @@ +name = "x2" +uuid = "52baf49e-96b1-11e8-23dd-2d073a3a6758" +version = "0.1.0" + +[deps] +x1 = "52033f98-96b1-11e8-17f9-4d5b643961d8" diff --git a/stdlib/Pkg/test/test_packages/x2/src/x2.jl b/stdlib/Pkg/test/test_packages/x2/src/x2.jl new file mode 100644 index 00000000000000..8afcc2e0134773 --- /dev/null +++ b/stdlib/Pkg/test/test_packages/x2/src/x2.jl @@ -0,0 +1,5 @@ +module x2 + +greet() = print("Hello World!") + +end # module diff --git a/stdlib/Pkg/test/test_packages/x3/Project.toml b/stdlib/Pkg/test/test_packages/x3/Project.toml new file mode 100644 index 00000000000000..8cd99a21c79226 --- /dev/null +++ b/stdlib/Pkg/test/test_packages/x3/Project.toml @@ -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"] diff --git a/stdlib/Pkg/test/test_packages/x3/src/x3.jl b/stdlib/Pkg/test/test_packages/x3/src/x3.jl new file mode 100644 index 00000000000000..a9b26ef703c753 --- /dev/null +++ b/stdlib/Pkg/test/test_packages/x3/src/x3.jl @@ -0,0 +1,5 @@ +module x3 + +greet() = print("Hello World!") + +end # module diff --git a/stdlib/Pkg/test/test_packages/x3/test/runtests.jl b/stdlib/Pkg/test/test_packages/x3/test/runtests.jl new file mode 100644 index 00000000000000..85b0336d373e18 --- /dev/null +++ b/stdlib/Pkg/test/test_packages/x3/test/runtests.jl @@ -0,0 +1,7 @@ +module X3Tests + +using x2 + +println("hello") + +end # module