Skip to content

Commit 558389a

Browse files
davidanthoffclaude
andcommitted
Add test for package dev'ed in its own test/Manifest.toml
Covers the reproducer from #120: a package whose test/Manifest.toml dev's the package itself (what `julia --project=test -e 'using Pkg; Pkg.develop(path=".")'` produces) could not be activated on Julia 1.4-1.10 before the merge-project guard was ported. The new `test/sources/SelfDevTestManifest` fixture is copied to a temporary directory and both manifests are generated at test time, so the manifest format always matches the running Julia version. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent e0bfc91 commit 558389a

5 files changed

Lines changed: 52 additions & 0 deletions

File tree

test/activate_set.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,43 @@
9090
end
9191
end
9292

93+
if VERSION >= v"1.4-"
94+
# https://github.com/JuliaTesting/TestEnv.jl/pull/120
95+
# A package whose `test/Manifest.toml` dev's the package itself, i.e. what
96+
# `julia --project=test -e 'using Pkg; Pkg.develop(path=".")'` produces.
97+
@testset "activate package dev'ed in its own test/Manifest" begin
98+
mktempdir() do p
99+
pkg_path = joinpath(p, "SelfDevTestManifest")
100+
cp(joinpath(@__DIR__, "sources", "SelfDevTestManifest"), pkg_path)
101+
102+
orig_project_toml_path = Base.active_project()
103+
orig_load_path = copy(LOAD_PATH)
104+
push!(LOAD_PATH, mktempdir()) # put something weird in LOAD_PATH for testing
105+
try
106+
# Generate the test/Manifest.toml that dev's the package itself
107+
Pkg.activate(joinpath(pkg_path, "test"))
108+
Pkg.develop(PackageSpec(path=pkg_path))
109+
110+
# ... and the package's own manifest
111+
Pkg.activate(pkg_path)
112+
Pkg.resolve()
113+
114+
TestEnv.activate()
115+
new_project_toml_path = Base.active_project()
116+
@test new_project_toml_path != orig_project_toml_path
117+
118+
@eval using SelfDevTestManifest
119+
@test Base.invokelatest(isdefined, @__MODULE__, :SelfDevTestManifest)
120+
@test (@eval SelfDevTestManifest.foo()) == 42
121+
finally
122+
Pkg.activate(orig_project_toml_path)
123+
pop!(LOAD_PATH)
124+
@test orig_load_path == LOAD_PATH
125+
end
126+
end
127+
end
128+
end
129+
93130
if VERSION >= v"1.11"
94131
@testset "activate with [sources]" begin
95132
orig_project_toml_path = Base.active_project()
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name = "SelfDevTestManifest"
2+
uuid = "1cda0850-20f2-4a85-a119-95c26fe5cbc8"
3+
version = "0.0.0"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module SelfDevTestManifest
2+
3+
foo() = 42
4+
5+
end
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[deps]
2+
SelfDevTestManifest = "1cda0850-20f2-4a85-a119-95c26fe5cbc8"
3+
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
using SelfDevTestManifest
2+
using Test
3+
4+
@test SelfDevTestManifest.foo() == 42

0 commit comments

Comments
 (0)