Skip to content

Commit c8cd07b

Browse files
00vareladavidKristofferC
authored andcommitted
Increase a testset isolation (#505)
1 parent ca7a692 commit c8cd07b

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

stdlib/Pkg/test/repl.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ end
2929
end
3030

3131
temp_pkg_dir() do project_path
32-
cd(project_path) do
32+
with_pkg_env(project_path; change_dir=true) do;
3333
withenv("USER" => "Test User") do
3434
pkg"generate HelloWorld"
3535
LibGit2.close((LibGit2.init(".")))

stdlib/Pkg/test/utils.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,16 @@ function with_temp_env(f, env_name::AbstractString="Dummy")
6969
Pkg.activate()
7070
end
7171
end
72+
73+
function with_pkg_env(fn::Function, path::AbstractString="."; change_dir=false)
74+
Pkg.activate(path)
75+
try
76+
if change_dir
77+
cd(fn, path)
78+
else
79+
fn()
80+
end
81+
finally
82+
Pkg.activate()
83+
end
84+
end

0 commit comments

Comments
 (0)