Skip to content

Commit 4aab8df

Browse files
authored
ambiguous testgroup: restore original ENV at the end of the testgroup (#358)
* `ambiguous` testgroup: restore original `ENV` at the end of the testgroup * Add a trailing newline --------- Co-authored-by: Dilum Aluthge <[email protected]>
1 parent 4f4d8ed commit 4aab8df

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/ambiguous.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# This file is a part of Julia. License is MIT: https://julialang.org/license
22

3+
###
4+
# We'll restore the original env at the end of this testgroup.
5+
original_depot_path = copy(Base.DEPOT_PATH)
6+
original_load_path = copy(Base.LOAD_PATH)
7+
original_env = copy(ENV)
8+
###
9+
310
import Pkg
411

512
# Because julia CI doesn't run stdlib tests via `Pkg.test` test deps must be manually installed if missing
@@ -67,3 +74,18 @@ end
6774
# @test isempty(expect)
6875
# @test good
6976
# end
77+
78+
###
79+
# Now we restore the original env, as promised
80+
empty!(Base.DEPOT_PATH)
81+
empty!(Base.LOAD_PATH)
82+
append!(Base.DEPOT_PATH, original_depot_path)
83+
append!(Base.LOAD_PATH, original_load_path)
84+
85+
for k in setdiff(collect(keys(ENV)), collect(keys(original_env)))
86+
delete!(ENV, k)
87+
end
88+
for (k, v) in pairs(original_env)
89+
ENV[k] = v
90+
end
91+
###

0 commit comments

Comments
 (0)