Skip to content

Commit f59dd37

Browse files
committed
tests: Allow running user-specified tests
1 parent a380fe4 commit f59dd37

File tree

2 files changed

+92
-42
lines changed

2 files changed

+92
-42
lines changed

test/Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
[deps]
2+
ArgParse = "c7e460c6-2fb9-53a9-8c5b-16f535851c63"
23
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
34
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
45
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"

test/runtests.jl

Lines changed: 91 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,101 @@
1+
tests = [
2+
("Thunk", "thunk.jl"),
3+
("Scheduler", "scheduler.jl"),
4+
("Processors", "processors.jl"),
5+
("Memory Spaces", "memory-spaces.jl"),
6+
("Logging", "logging.jl"),
7+
("Checkpointing", "checkpoint.jl"),
8+
("Scopes", "scopes.jl"),
9+
("Options", "options.jl"),
10+
("Mutation", "mutation.jl"),
11+
("Task Queues", "task-queues.jl"),
12+
("Datadeps", "datadeps.jl"),
13+
("Domain Utilities", "domain.jl"),
14+
("Array", "array.jl"),
15+
("Linear Algebra", "linalg.jl"),
16+
("Caching", "cache.jl"),
17+
("Disk Caching", "diskcaching.jl"),
18+
("File IO", "file-io.jl"),
19+
#("Fault Tolerance", "fault-tolerance.jl"),
20+
]
21+
all_test_names = map(test -> replace(last(test), ".jl"=>""), tests)
22+
if PROGRAM_FILE != "" && realpath(PROGRAM_FILE) == @__FILE__
23+
push!(LOAD_PATH, joinpath(@__DIR__, ".."))
24+
push!(LOAD_PATH, @__DIR__)
25+
using Pkg
26+
Pkg.activate(@__DIR__)
27+
28+
using ArgParse
29+
s = ArgParseSettings(description = "Dagger Testsuite")
30+
@eval begin
31+
@add_arg_table! s begin
32+
"--test"
33+
nargs = '*'
34+
default = all_test_names
35+
help = "Enables the specified test to run in the testsuite"
36+
"-s", "--simulate"
37+
action = :store_true
38+
help = "Don't actually run the tests"
39+
end
40+
end
41+
parsed_args = parse_args(s)
42+
to_test = String[]
43+
for test in parsed_args["test"]
44+
if isdir(joinpath(@__DIR__, test))
45+
for (_, other_test) in tests
46+
if startswith(other_test, test)
47+
push!(to_test, other_test)
48+
continue
49+
end
50+
end
51+
elseif test in all_test_names
52+
push!(to_test, test)
53+
else
54+
println(stderr, "Unknown test: $test")
55+
println(stderr, "Available tests:")
56+
for ((test_title, _), test_name) in zip(tests, all_test_names)
57+
println(stderr, " $test_name: $test_title")
58+
end
59+
exit(1)
60+
end
61+
end
62+
@info "Running tests: $(join(to_test, ", "))"
63+
parsed_args["simulate"] && exit(0)
64+
else
65+
to_test = all_test_names
66+
@info "Running all tests"
67+
end
68+
69+
170
using Distributed
271
addprocs(3)
372

73+
include("util.jl")
74+
include("fakeproc.jl")
75+
476
using Test
577
using Dagger
678
using UUIDs
779
import MemPool
880

9-
include("util.jl")
10-
include("fakeproc.jl")
11-
12-
include("thunk.jl")
13-
14-
#= FIXME: Unreliable, and some thunks still get retained
15-
# N.B. We need a few of these probably because of incremental WeakRef GC
16-
@everywhere GC.gc()
17-
@everywhere GC.gc()
18-
@everywhere GC.gc()
19-
@everywhere GC.gc()
20-
sleep(1)
21-
@test isempty(Dagger.Sch.EAGER_ID_MAP)
22-
state = Dagger.Sch.EAGER_STATE[]
23-
@test isempty(state.waiting)
24-
@test_broken length(keys(state.waiting_data)) == 1
25-
# Ensure that all cache entries have expired
26-
@test_broken isempty(state.cache)
27-
=#
28-
29-
include("scheduler.jl")
30-
include("processors.jl")
31-
include("memory-spaces.jl")
32-
include("logging.jl")
33-
include("checkpoint.jl")
34-
include("scopes.jl")
35-
include("options.jl")
36-
include("mutation.jl")
37-
include("task-queues.jl")
38-
include("datadeps.jl")
39-
include("domain.jl")
40-
include("array.jl")
41-
include("linalg.jl")
42-
include("cache.jl")
43-
include("diskcaching.jl")
44-
include("file-io.jl")
45-
46-
try # TODO: Fault tolerance is sometimes unreliable
47-
#include("fault-tolerance.jl")
81+
try
82+
for test in to_test
83+
test_title = tests[findfirst(x->x[2]==test * ".jl", tests)][1]
84+
test_name = all_test_names[findfirst(x->x==test, all_test_names)]
85+
println()
86+
@info "Testing $test_title ($test_name)"
87+
@testset "$test_title" include(test * ".jl")
88+
end
4889
catch
90+
printstyled(stderr, "Tests Failed!\n"; color=:red)
91+
rethrow()
92+
finally
93+
state = Dagger.Sch.EAGER_STATE[]
94+
if state !== nothing
95+
notify(state.halt)
96+
end
97+
sleep(1)
98+
rmprocs(workers())
4999
end
50-
println(stderr, "tests done. cleaning up...")
51-
Dagger.cleanup()
52-
println(stderr, "all done.")
100+
101+
printstyled(stderr, "Tests Completed!\n"; color=:green)

0 commit comments

Comments
 (0)