Skip to content

Commit

Permalink
Add proctypes tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsamaroo committed Apr 1, 2020
1 parent 3775400 commit b6b5044
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/fakeproc.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@everywhere begin

using Dagger

struct FakeProc <: Dagger.Processor end

Dagger.iscompatible(proc::FakeProc, opts, x::Integer) = true
Dagger.iscompatible(proc::FakeProc, opts, x::String) = true
Dagger.move(ctx, from_proc::OSProc, to_proc::FakeProc, x::Integer) = x
Dagger.move(ctx, from_proc::FakeProc, to_proc::OSProc, x::Integer) = x
Dagger.move(ctx, from_proc::FakeProc, to_proc::OSProc, x::String) = parse(Int,x)
Dagger.execute!(proc::FakeProc, func, arg::Integer) = func(arg)
Dagger.execute!(proc::FakeProc, func, args...) = "42" * func(string.(args)...)

push!(Dagger.PROCESSOR_CALLBACKS, proc -> begin
push!(proc.children, FakeProc())
end)

end
2 changes: 2 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ addprocs(2)
using Test
using Dagger

include("fakeproc.jl")

include("domain.jl")
include("array.jl")
include("scheduler.jl")
Expand Down
13 changes: 13 additions & 0 deletions test/scheduler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,17 @@ end
@test collect(Context(), a) == 1
end
end

@testset "Thunk options: proctypes" begin
@test Dagger.iscompatible(FakeProc(), nothing, 1) == true
@test Dagger.iscompatible(FakeProc(), nothing, "1") == true
@test Dagger.iscompatible(FakeProc(), nothing, 1.0) == false

as = [delayed(identity)(i) for i in 1:10]
opts = Dagger.Sch.ThunkOptions(;proctypes=[FakeProc])
b = delayed(*; options=opts)(as...)

@test collect(b) == 4212345678910
end

end

0 comments on commit b6b5044

Please sign in to comment.