From b48c53fb81244d0d3297614e94eea6914a4ca4f9 Mon Sep 17 00:00:00 2001 From: Kristoffer Carlsson Date: Wed, 13 Feb 2019 15:27:36 +0100 Subject: [PATCH] fix "locking" dependencies when building / testing current project --- src/backwards_compatible_isolation.jl | 5 +- test/pkg.jl | 9 ++ .../BuildProjectFixedDeps/.gitignore | 2 + .../BuildProjectFixedDeps/Manifest.toml | 92 +++++++++++++++++++ .../BuildProjectFixedDeps/Project.toml | 7 ++ .../BuildProjectFixedDeps/deps/build.jl | 5 + .../src/BuildProjectFixedDeps.jl | 5 + 7 files changed, 123 insertions(+), 2 deletions(-) create mode 100644 test/test_packages/BuildProjectFixedDeps/.gitignore create mode 100644 test/test_packages/BuildProjectFixedDeps/Manifest.toml create mode 100644 test/test_packages/BuildProjectFixedDeps/Project.toml create mode 100644 test/test_packages/BuildProjectFixedDeps/deps/build.jl create mode 100644 test/test_packages/BuildProjectFixedDeps/src/BuildProjectFixedDeps.jl diff --git a/src/backwards_compatible_isolation.jl b/src/backwards_compatible_isolation.jl index 18575f2a80..7092641fb6 100644 --- a/src/backwards_compatible_isolation.jl +++ b/src/backwards_compatible_isolation.jl @@ -484,9 +484,10 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag empty!(localctx.env.project.deps) localctx.env.project.deps[pkg.name] = pkg.uuid seen_uuids = Set{UUID}() - # Only put `pkg` and its deps (recursively) in the temp project - collect_deps!(seen_uuids, pkg) end + # Only put `pkg` and its deps (recursively) in the temp project + seen_uuids = Set{UUID}() + collect_deps!(seen_uuids, pkg) pkgs = PackageSpec[] if target !== nothing diff --git a/test/pkg.jl b/test/pkg.jl index c5d3df394b..bc26192ed5 100644 --- a/test/pkg.jl +++ b/test/pkg.jl @@ -688,6 +688,15 @@ end end end end +@testset "building project should fix version of deps" begin + temp_pkg_dir() do project_path + dep_pkg = joinpath(@__DIR__, "test_packages", "BuildProjectFixedDeps") + Pkg.activate(dep_pkg) + Pkg.build() + @test isfile(joinpath(dep_pkg, "deps", "artifact")) + end +end + include("repl.jl") include("api.jl") include("registry.jl") diff --git a/test/test_packages/BuildProjectFixedDeps/.gitignore b/test/test_packages/BuildProjectFixedDeps/.gitignore new file mode 100644 index 0000000000..387750f19f --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/.gitignore @@ -0,0 +1,2 @@ +deps/artifact +deps/build.log \ No newline at end of file diff --git a/test/test_packages/BuildProjectFixedDeps/Manifest.toml b/test/test_packages/BuildProjectFixedDeps/Manifest.toml new file mode 100644 index 0000000000..4a1babbc46 --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/Manifest.toml @@ -0,0 +1,92 @@ +# This file is machine-generated - editing it directly is not advised + +[[Base64]] +uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f" + +[[BenchmarkTools]] +deps = ["JSON", "Printf", "Statistics", "Test"] +git-tree-sha1 = "5d1dd8577643ba9014574cd40d9c028cd5e4b85a" +uuid = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +version = "0.4.2" + +[[Dates]] +deps = ["Printf"] +uuid = "ade2ca70-3891-5945-98fb-dc099432e06a" + +[[Distributed]] +deps = ["Random", "Serialization", "Sockets"] +uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b" + +[[InteractiveUtils]] +deps = ["Markdown"] +uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240" + +[[JSON]] +deps = ["Dates", "Distributed", "Mmap", "Sockets", "Test", "Unicode"] +git-tree-sha1 = "fec8e4d433072731466d37ed0061b3ba7f70eeb9" +uuid = "682c06a0-de6a-54ab-a142-c8b1cf79cde6" +version = "0.19.0" + +[[LibGit2]] +uuid = "76f85450-5226-5b5a-8eaa-529ad045b433" + +[[Libdl]] +uuid = "8f399da3-3557-5675-b5ff-fb832c97cbdb" + +[[LinearAlgebra]] +deps = ["Libdl"] +uuid = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" + +[[Logging]] +uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" + +[[Markdown]] +deps = ["Base64"] +uuid = "d6f4376e-aef5-505a-96c1-9c027394607a" + +[[Mmap]] +uuid = "a63ad114-7e13-5084-954f-fe012c677804" + +[[Pkg]] +deps = ["Dates", "LibGit2", "Markdown", "Printf", "REPL", "Random", "SHA", "UUIDs"] +uuid = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" + +[[Printf]] +deps = ["Unicode"] +uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7" + +[[REPL]] +deps = ["InteractiveUtils", "Markdown", "Sockets"] +uuid = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" + +[[Random]] +deps = ["Serialization"] +uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" + +[[SHA]] +uuid = "ea8e919c-243c-51af-8825-aaa63cd721ce" + +[[Serialization]] +uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b" + +[[Sockets]] +uuid = "6462fe0b-24de-5631-8697-dd941f90decc" + +[[SparseArrays]] +deps = ["LinearAlgebra", "Random"] +uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" + +[[Statistics]] +deps = ["LinearAlgebra", "SparseArrays"] +uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" + +[[Test]] +deps = ["Distributed", "InteractiveUtils", "Logging", "Random"] +uuid = "8dfed614-e22c-5e08-85e1-65c5234f0b40" + +[[UUIDs]] +deps = ["Random", "SHA"] +uuid = "cf7118a7-6976-5b1a-9a39-7adc72f591a4" + +[[Unicode]] +uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5" diff --git a/test/test_packages/BuildProjectFixedDeps/Project.toml b/test/test_packages/BuildProjectFixedDeps/Project.toml new file mode 100644 index 0000000000..93f9a83e41 --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/Project.toml @@ -0,0 +1,7 @@ +name = "BuildProjectFixedDeps" +uuid = "a9d53770-2f9b-11e9-234d-75f2cd7ebf28" +version = "0.1.0" + +[deps] +BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" +Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f" diff --git a/test/test_packages/BuildProjectFixedDeps/deps/build.jl b/test/test_packages/BuildProjectFixedDeps/deps/build.jl new file mode 100644 index 0000000000..d3120707ef --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/deps/build.jl @@ -0,0 +1,5 @@ +import Pkg +build_artifact = joinpath(@__DIR__, "artifact") +isfile(build_artifact) && rm(build_artifact) +@assert Pkg.installed()["JSON"] == v"0.19.0" +touch(build_artifact) \ No newline at end of file diff --git a/test/test_packages/BuildProjectFixedDeps/src/BuildProjectFixedDeps.jl b/test/test_packages/BuildProjectFixedDeps/src/BuildProjectFixedDeps.jl new file mode 100644 index 0000000000..17987d4cbf --- /dev/null +++ b/test/test_packages/BuildProjectFixedDeps/src/BuildProjectFixedDeps.jl @@ -0,0 +1,5 @@ +module BuildProjectFixedDeps + +greet() = print("Hello World!") + +end # module