Skip to content

Commit

Permalink
fix "locking" dependencies when building / testing current project
Browse files Browse the repository at this point in the history
(cherry picked from commit b48c53f, PR #1058)
  • Loading branch information
KristofferC authored and fredrikekre committed Apr 15, 2019
1 parent 15151be commit 8416d3c
Show file tree
Hide file tree
Showing 7 changed files with 122 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Operations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -850,10 +850,9 @@ function with_dependencies_loadable_at_toplevel(f, mainctx::Context, pkg::Packag
# Only put `pkg` and its deps (recursively) in the temp project
empty!(localctx.env.project["deps"])
localctx.env.project["deps"][pkg.name] = string(pkg.uuid)
seen_uuids = Set{UUID}()
# Only put `pkg` and its deps (recursively) in the temp project
collect_deps!(seen_uuids, pkg)
end
seen_uuids = Set{UUID}()
collect_deps!(seen_uuids, pkg)

pkgs = PackageSpec[]
if target !== nothing
Expand Down
9 changes: 9 additions & 0 deletions test/pkg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,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")

Expand Down
2 changes: 2 additions & 0 deletions test/test_packages/BuildProjectFixedDeps/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
deps/artifact
deps/build.log
92 changes: 92 additions & 0 deletions test/test_packages/BuildProjectFixedDeps/Manifest.toml
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 7 additions & 0 deletions test/test_packages/BuildProjectFixedDeps/Project.toml
Original file line number Diff line number Diff line change
@@ -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"
5 changes: 5 additions & 0 deletions test/test_packages/BuildProjectFixedDeps/deps/build.jl
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module BuildProjectFixedDeps

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

end # module

0 comments on commit 8416d3c

Please sign in to comment.