Skip to content

Commit 106e867

Browse files
authored
testdefs: make sure that if a test set changes the active project, they change it back when they're done (#51029)
We already check the following for mutation by a test set: 1. DEPOT_PATH 2. LOAD_PATH 3. ENV So this PR just adds the active project to the list of things we check. Changing the active project during a test set can definitely have negative effects on subsequent test sets that are run on the same worker, so we want to make sure if a test set changes the active project, that they change it back when they're done.
1 parent e708c5e commit 106e867

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/testdefs.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ function runtests(name, path, isolate=true; seed=nothing)
2525
original_depot_path = copy(Base.DEPOT_PATH)
2626
original_load_path = copy(Base.LOAD_PATH)
2727
original_env = copy(ENV)
28+
original_project = Base.active_project()
2829

2930
Base.include(m, "$path.jl")
3031

@@ -63,6 +64,17 @@ function runtests(name, path, isolate=true; seed=nothing)
6364
error(msg)
6465
end
6566
end
67+
if Base.active_project() != original_project
68+
msg = "The `$(name)` test set changed the active project and did not restore the original value"
69+
@error(
70+
msg,
71+
original_project,
72+
Base.active_project(),
73+
testset_name = name,
74+
testset_path = path,
75+
)
76+
error(msg)
77+
end
6678
end
6779
rss = Sys.maxrss()
6880
#res_and_time_data[1] is the testset

0 commit comments

Comments
 (0)