Skip to content

Commit 104a5b5

Browse files
christiangnrdvchuravy
authored andcommitted
Add backend argument for examples_testset
1 parent d5cce39 commit 104a5b5

File tree

3 files changed

+12
-9
lines changed

3 files changed

+12
-9
lines changed

examples/utils.jl

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# EXCLUDE FROM TESTING
2-
if Base.find_package("CUDA") !== nothing
3-
using CUDA
4-
using CUDA.CUDAKernels
5-
const backend = CUDABackend()
6-
CUDA.allowscalar(false)
7-
else
8-
const backend = CPU()
2+
if !(@isdefined backend)
3+
if Base.find_package("CUDA") !== nothing
4+
using CUDA
5+
using CUDA.CUDAKernels
6+
const backend = CUDABackend()
7+
CUDA.allowscalar(false)
8+
else
9+
const backend = CPU()
10+
end
911
end
1012

1113
const f_type = KernelAbstractions.supports_float64(backend) ? Float64 : Float32

test/examples.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function find_sources(path::String, sources = String[])
99
return sources
1010
end
1111

12-
function examples_testsuite(backend_str)
12+
function examples_testsuite(backend, backend_str)
1313
@testset "examples" begin
1414
examples_dir = joinpath(@__DIR__, "..", "examples")
1515
examples = find_sources(examples_dir)
@@ -21,6 +21,7 @@ function examples_testsuite(backend_str)
2121
@testset "$(basename(example))" for example in examples
2222
@eval module $(gensym())
2323
backend_str = $backend_str
24+
const backend = ($backend)()
2425
include($example)
2526
end
2627
@test true

test/testsuite.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ function testsuite(backend, backend_str, backend_mod, AT, DAT; skip_tests = Set{
8484
end
8585

8686
@conditional_testset "Examples" skip_tests begin
87-
examples_testsuite(backend_str)
87+
examples_testsuite(backend, backend_str)
8888
end
8989

9090
return

0 commit comments

Comments
 (0)