Skip to content

Commit 2b22eb9

Browse files
committed
Support new filtering API.
1 parent 02bdb17 commit 2b22eb9

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

test/runtests.jl

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import Test
55

66
@info "System information:\n" * sprint(io->OpenCL.versioninfo(io))
77

8-
## --platform selector
9-
do_platform, platform_filter = ParallelTestRunner.extract_flag!(ARGS, "--platform", nothing)
8+
## custom arguments
9+
args = parse_args(ARGS; custom=["platform"])
1010

1111
# determine tests to run
1212
const testsuite = find_tests(pwd())
@@ -26,10 +26,12 @@ for name in keys(GPUArraysTestSuite.tests)
2626
testsuite[test] = :(GPUArraysTestSuite.tests[$name](CLArray))
2727
end
2828
## filter
29-
if load_preference(OpenCL, "default_memory_backend") == "svm"
30-
# GPUArrays' scalar indexing tests assume that indexing is not supported
31-
delete!(testsuite, "gpuarrays/indexing scalar")
32-
return false
29+
if filter_tests!(testsuite, args)
30+
if load_preference(OpenCL, "default_memory_backend") == "svm"
31+
# GPUArrays' scalar indexing tests assume that indexing is not supported
32+
delete!(testsuite, "gpuarrays/indexing scalar")
33+
return false
34+
end
3335
end
3436

3537
# wrap tests in device loops
@@ -42,22 +44,23 @@ function generate_test(test, expr)
4244
# targets is a global variable that is defined in init_code
4345
return quote
4446
if isempty(targets)
47+
platform_filter = $(args.custom["platform"])
4548
for platform in cl.platforms(),
4649
device in cl.devices(platform)
47-
if $(platform_filter) !== nothing
50+
if platform_filter !== nothing
4851
# filter on the name or vendor
4952
names = lowercase.([platform.name, platform.vendor])
50-
if !any(contains($(platform_filter)), names)
53+
if !any(contains(platform_filter.value), names)
5154
continue
5255
end
5356
end
5457
push!(targets, (; platform, device))
5558
end
5659
if isempty(targets)
57-
if $(platform_filter) === nothing
60+
if platform_filter !== nothing
5861
throw(ArgumentError("No OpenCL platforms found"))
5962
else
60-
throw(ArgumentError("No OpenCL platforms found matching $($(platform_filter))"))
63+
throw(ArgumentError("No OpenCL platforms found matching $(platform_filter.value)"))
6164
end
6265
end
6366
end
@@ -138,4 +141,4 @@ const init_code = quote
138141
end
139142

140143

141-
runtests(OpenCL, ARGS; testsuite, init_code)
144+
runtests(OpenCL, args; testsuite, init_code)

0 commit comments

Comments
 (0)