/
runtests.jl
78 lines (66 loc) · 2.43 KB
/
runtests.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Work around JuliaLang/Pkg.jl#2500
# Must be before loading anything
if VERSION < v"1.8-"
test_project = first(Base.load_path())
preferences_file = "../LocalPreferences.toml"
test_preferences_file = joinpath(dirname(test_project), "LocalPreferences.toml")
if isfile(preferences_file) && !isfile(test_preferences_file)
cp(preferences_file, test_preferences_file)
@info "copied LocalPreferences.toml to $test_preferences_file"
end
end
using Aqua
using TestItemRunner
using DFTK
using Random
#
# This test suite supports test arguments. For example:
# Pkg.test("DFTK"; test_args = ["fast"])
# only runs the "fast" tests (i.e. not the expensive ones)
# Pkg.test("DFTK"; test_args = ["example"])
# runs only the tests tagged as "example" and
# Pkg.test("DFTK"; test_args = ["example", "all"])
# runs all tests plus the "example" tests.
#
# Setup threading in DFTK
setup_threading(; n_blas=2)
# Initialize seed
Random.seed!(0)
const DFTK_TEST_ARGS = let
if "DFTK_TEST_ARGS" in keys(ENV) && isempty(ARGS)
split(ENV["DFTK_TEST_ARGS"], ",")
else
ARGS
end
end
# Tags supplied by the user.
const TAGS = isempty(DFTK_TEST_ARGS) ? [:all] : Symbol.(DFTK_TEST_ARGS)
# Tags excluded from the first run of "all" tests
const EXCLUDED_FROM_ALL = Symbol[:example, :gpu]
:fast ∈ TAGS && push!(EXCLUDED_FROM_ALL, :slow)
mpi_nprocs() > 1 && push!(EXCLUDED_FROM_ALL, :dont_test_mpi)
Sys.iswindows() && push!(EXCLUDED_FROM_ALL, :dont_test_windows)
# Tags explicitly included
const EXTRA_TAGS = filter(!in((:all, :fast)), TAGS)
println("Running tests")
if :all ∈ TAGS || :fast ∈ TAGS
println(" all except: $(join(EXCLUDED_FROM_ALL, ", "));")
end
if !isempty(EXTRA_TAGS)
println(" plus: $(join(EXTRA_TAGS, ", "));")
end
if :all ∈ TAGS || :fast ∈ TAGS
is_excluded(ti) = any(in(ti.tags), EXCLUDED_FROM_ALL)
@run_package_tests filter=!is_excluded
if mpi_nprocs() == 1
# TODO For now disable type piracy check, as we use that at places to patch
# up missing functionality. Should disable this on a more fine-grained scale.
Aqua.test_all(DFTK;
ambiguities=false,
piracies=false,
deps_compat=(check_extras=false, ),
stale_deps=(ignore=[:Primes, ], ))
end
end
is_explicitly_selected(ti) = any(in(ti.tags), EXTRA_TAGS)
@run_package_tests filter=is_explicitly_selected