From 27d452d73ed33ac368b3cbf6675a2eaca1ff39a9 Mon Sep 17 00:00:00 2001 From: David Varela <00.varela.david@gmail.com> Date: Wed, 9 Jan 2019 12:02:41 -0800 Subject: [PATCH] fix rm: `project.extras` also contain dependency names --- src/Operations.jl | 3 ++- test/pkg.jl | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Operations.jl b/src/Operations.jl index 8301817efc..c18d262fe4 100644 --- a/src/Operations.jl +++ b/src/Operations.jl @@ -1139,7 +1139,8 @@ function rm(ctx::Context, pkgs::Vector{PackageSpec}) @info "No changes" return end - deps_names = collect(keys(ctx.env.project.deps)) + deps_names = append!(collect(keys(ctx.env.project.deps)), + collect(keys(ctx.env.project.extras))) filter!(ctx.env.project.targets) do (target, deps) !isempty(filter!(in(deps_names), deps)) end diff --git a/test/pkg.jl b/test/pkg.jl index c0c5ffd827..4d3204cd42 100644 --- a/test/pkg.jl +++ b/test/pkg.jl @@ -615,6 +615,18 @@ end end end +#issue #876 +@testset "targets should survive add/rm" begin + temp_pkg_dir() do project_path; cd_tempdir() do tmpdir + cp(joinpath(@__DIR__, "project", "good", "pkg.toml"), "Project.toml") + targets = deepcopy(Pkg.Types.read_project("Project.toml").targets) + Pkg.activate(".") + Pkg.add("Example") + Pkg.rm("Example") + @test targets == Pkg.Types.read_project("Project.toml").targets + end end +end + @testset "reading corrupted project files" begin dir = joinpath(@__DIR__, "project", "bad") for bad_project in joinpath.(dir, readdir(dir))