Skip to content

Commit de56455

Browse files
committed
adopt to refactor
1 parent c7182fb commit de56455

File tree

1 file changed

+35
-58
lines changed

1 file changed

+35
-58
lines changed

test/runtests.jl

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ custom_record_init = quote
3131
const targets = []
3232
using OpenCL, IOCapture
3333

34-
function ParallelTestRunner.runtest(::Type{OpenCLTestRecord}, f, name, init_code, color, (; platform_filter))
34+
function ParallelTestRunner.execute(::Type{OpenCLTestRecord}, mod, f, name, color, (; platform_filter))
3535
if isempty(targets)
3636
for platform in cl.platforms(),
3737
device in cl.devices(platform)
@@ -53,71 +53,48 @@ custom_record_init = quote
5353
end
5454
end
5555

56-
function inner()
57-
# generate a temporary module to execute the tests in
58-
mod = Core.eval(Main, Expr(:module, true, gensym(name), Expr(:block)))
59-
@eval(mod, import ParallelTestRunner: Test, Random)
60-
@eval(mod, using .Test, .Random)
61-
62-
Core.eval(mod, init_code)
63-
64-
# some tests require native execution capabilities
65-
requires_il = name in ["atomics", "execution", "intrinsics", "kernelabstractions"] ||
66-
startswith(name, "gpuarrays/")
67-
68-
data = @eval mod begin
69-
GC.gc(true)
70-
Random.seed!(1)
71-
OpenCL.allowscalar(false)
72-
73-
mktemp() do path, io
74-
stats = redirect_stdio(stdout=io, stderr=io) do
75-
@timed try
76-
@testset $(Expr(:$, :name)) begin
77-
@testset "\$(device.name)" for (; platform, device) in $(Expr(:$, :targets))
78-
cl.platform!(platform)
79-
cl.device!(device)
80-
81-
if !$(Expr(:$, :requires_il)) || "cl_khr_il_program" in device.extensions
82-
$(Expr(:$, :f))
83-
end
56+
# some tests require native execution capabilities
57+
requires_il = name in ["atomics", "execution", "intrinsics", "kernelabstractions"] ||
58+
startswith(name, "gpuarrays/")
59+
60+
data = @eval mod begin
61+
GC.gc(true)
62+
Random.seed!(1)
63+
OpenCL.allowscalar(false)
64+
65+
mktemp() do path, io
66+
stats = redirect_stdio(stdout=io, stderr=io) do
67+
@timed try
68+
@testset $(Expr(:$, :name)) begin
69+
@testset "\$(device.name)" for (; platform, device) in $(Expr(:$, :targets))
70+
cl.platform!(platform)
71+
cl.device!(device)
72+
73+
if !$(Expr(:$, :requires_il)) || "cl_khr_il_program" in device.extensions
74+
$(Expr(:$, :f))
8475
end
8576
end
86-
catch err
87-
isa(err, Test.TestSetException) || rethrow()
88-
89-
# return the error to package it into a TestRecord
90-
err
9177
end
92-
end
93-
close(io)
94-
output = read(path, String)
95-
(; testset=stats.value, output, stats.time, stats.bytes, stats.gctime)
78+
catch err
79+
isa(err, Test.TestSetException) || rethrow()
9680

81+
# return the error to package it into a TestRecord
82+
err
83+
end
9784
end
98-
end
99-
100-
# process results
101-
rss = Sys.maxrss()
102-
record = OpenCLTestRecord(data..., rss)
85+
close(io)
86+
output = read(path, String)
87+
(; testset=stats.value, output, stats.time, stats.bytes, stats.gctime)
10388

104-
GC.gc(true)
105-
return record
106-
end
107-
108-
@static if VERSION >= v"1.13.0-DEV.1044"
109-
@with Test.TESTSET_PRINT_ENABLE => false begin
110-
inner()
111-
end
112-
else
113-
old_print_setting = Test.TESTSET_PRINT_ENABLE[]
114-
Test.TESTSET_PRINT_ENABLE[] = false
115-
try
116-
inner()
117-
finally
118-
Test.TESTSET_PRINT_ENABLE[] = old_print_setting
11989
end
12090
end
91+
92+
# process results
93+
rss = Sys.maxrss()
94+
record = OpenCLTestRecord(data..., rss)
95+
96+
GC.gc(true)
97+
return record
12198
end
12299
end # quote
123100
eval(custom_record_init)

0 commit comments

Comments
 (0)