Skip to content

Commit f4be958

Browse files
committed
remove setup.jl
1 parent 6b7cfe3 commit f4be958

File tree

2 files changed

+84
-115
lines changed

2 files changed

+84
-115
lines changed

src/ParallelTestRunner.jl

Lines changed: 84 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ using Base.Filesystem: path_separator
1010
import Test
1111
import Random
1212

13-
include("setup.jl")
14-
1513
#Always set the max rss so that if tests add large global variables (which they do) we don't make the GC's life too hard
1614
if Sys.WORD_SIZE == 64
1715
const JULIA_TEST_MAXRSS_MB = 3800
@@ -60,6 +58,81 @@ function with_testset(f, testset)
6058
return nothing
6159
end
6260

61+
if VERSION >= v"1.13.0-DEV.1044"
62+
using Base.ScopedValues
63+
end
64+
65+
## entry point
66+
67+
function runtest(f, name)
68+
function inner()
69+
# generate a temporary module to execute the tests in
70+
mod_name = Symbol("Test", rand(1:100), "Main_", replace(name, '/' => '_'))
71+
mod = @eval(Main, module $mod_name end)
72+
@eval(mod, import ParallelTestRunner: Test, Random)
73+
@eval(mod, using .Test, .Random)
74+
75+
let id = myid()
76+
wait(@spawnat 1 print_testworker_started(name, id))
77+
end
78+
79+
ex = quote
80+
GC.gc(true)
81+
Random.seed!(1)
82+
83+
res = @timed @testset $name begin
84+
Main.include($f)
85+
end
86+
res..., 0, 0, 0
87+
end
88+
data = Core.eval(mod, ex)
89+
#data[1] is the testset
90+
91+
# process results
92+
rss = Sys.maxrss()
93+
if VERSION >= v"1.11.0-DEV.1529"
94+
tc = Test.get_test_counts(data[1])
95+
passes, fails, error, broken, c_passes, c_fails, c_errors, c_broken =
96+
tc.passes, tc.fails, tc.errors, tc.broken, tc.cumulative_passes,
97+
tc.cumulative_fails, tc.cumulative_errors, tc.cumulative_broken
98+
else
99+
passes, fails, errors, broken, c_passes, c_fails, c_errors, c_broken =
100+
Test.get_test_counts(data[1])
101+
end
102+
if data[1].anynonpass == false
103+
data = (
104+
(passes + c_passes, broken + c_broken),
105+
data[2],
106+
data[3],
107+
data[4],
108+
data[5],
109+
data[6],
110+
data[7],
111+
data[8],
112+
)
113+
end
114+
res = vcat(collect(data), rss)
115+
116+
GC.gc(true)
117+
return res
118+
end
119+
120+
res = @static if VERSION >= v"1.13.0-DEV.1044"
121+
@with Test.TESTSET_PRINT_ENABLE => false begin
122+
inner()
123+
end
124+
else
125+
old_print_setting = Test.TESTSET_PRINT_ENABLE[]
126+
Test.TESTSET_PRINT_ENABLE[] = false
127+
try
128+
inner()
129+
finally
130+
Test.TESTSET_PRINT_ENABLE[] = old_print_setting
131+
end
132+
end
133+
return res
134+
end
135+
63136
function runtests(ARGS, testfilter = _ -> true)
64137
do_help, _ = extract_flag!(ARGS, "--help")
65138
if do_help
@@ -169,7 +242,14 @@ function runtests(ARGS, testfilter = _ -> true)
169242

170243
return withenv("JULIA_NUM_THREADS" => 1, "OPENBLAS_NUM_THREADS" => 1) do
171244
procs = addprocs(X; exename = exename, exeflags = test_exeflags, kwargs...)
172-
@everywhere procs include($(joinpath(@__DIR__, "setup.jl")))
245+
Distributed.remotecall_eval(
246+
Main, procs, quote
247+
import ParallelTestRunner
248+
# TODO: Should we import Test for the user here?
249+
import ParallelTestRunner: Test
250+
using .Test
251+
end
252+
)
173253
if ispath(joinpath(WORKDIR, "setup.jl"))
174254
@everywhere procs include($(joinpath(WORKDIR, "setup.jl")))
175255
end
@@ -311,7 +391,7 @@ function runtests(ARGS, testfilter = _ -> true)
311391
# run the test
312392
running_tests[test] = now()
313393
try
314-
resp = remotecall_fetch(__runtests, wrkr, test_runners[test], test)
394+
resp = remotecall_fetch(runtest, wrkr, test_runners[test], test)
315395
catch e
316396
isa(e, InterruptException) && return
317397
resp = Any[e]

src/setup.jl

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)