Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name = "ParallelTestRunner"
uuid = "d3525ed8-44d0-4b2c-a655-542cee43accc"
version = "2.4.1"
authors = ["Valentin Churavy <v.churavy@gmail.com>"]
version = "2.4.0"

[workspace]
projects = ["test"]

[deps]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Expand Down
7 changes: 6 additions & 1 deletion src/ParallelTestRunner.jl
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,18 @@ function runtest(f, name, init_code)
data = @eval mod begin
GC.gc(true)
Random.seed!(1)
project = Base.active_project()

# @testset CustomTestRecord switches the all lower-level testset to our custom testset,
# so we need to have two layers here such that the user-defined testsets are using `DefaultTestSet`.
# This also guarantees our invariant about `WorkerTestSet` containing a single `DefaultTestSet`.
stats = @timed @testset WorkerTestSet "placeholder" begin
@testset DefaultTestSet $name begin
$f
try
$f
finally
Base.set_active_project(project)
end
end
end
(; testset=stats.value, stats.time, stats.bytes, stats.gctime)
Expand Down
5 changes: 5 additions & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
[deps]
ParallelTestRunner = "d3525ed8-44d0-4b2c-a655-542cee43accc"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[sources]
ParallelTestRunner = {path = ".."}
21 changes: 21 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,25 @@ end
@test contains(str, "SUCCESS")
end

@testset "switching projects" begin
testsuite = Dict(
"first" => quote
using Pkg
Pkg.activate(; temp=true)
@test 1 + 1 == 2
end,
"second" => quote
@test 2 * 2 == 4
end
)

io = IOBuffer()
runtests(ParallelTestRunner, ["--verbose", "--jobs=1"]; testsuite, stdout=io, stderr=io)

str = String(take!(io))
@test contains(str, r"first .+ started at")
@test contains(str, r"second .+ started at")
@test contains(str, "SUCCESS")
end

end