Skip to content

Commit e6d935e

Browse files
authored
Ability to select particular test cases (#762)
1 parent bc78ee6 commit e6d935e

File tree

3 files changed

+81
-66
lines changed

3 files changed

+81
-66
lines changed

test/ambiguities.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
# Allow no new ambiguities (see #18), unless you fix some old ones first!
3+
@test length(detect_ambiguities(Base, LinearAlgebra, StaticArrays)) <= 5
4+

test/runtests.jl

Lines changed: 58 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,67 @@
11
using StaticArrays, Test, Random, LinearAlgebra
22
using InteractiveUtils
33

4-
# Allow no new ambiguities (see #18), unless you fix some old ones first!
5-
if VERSION >= v"1.0.0"
6-
@test length(detect_ambiguities(Base, LinearAlgebra, StaticArrays)) <= 5
7-
end
8-
94
# We generate a lot of matrices using rand(), but unit tests should be
105
# deterministic. Therefore seed the RNG here (and further down, to avoid test
116
# file order dependence)
127
Random.seed!(42)
13-
148
include("testutil.jl")
15-
include("SVector.jl")
16-
include("MVector.jl")
17-
include("SMatrix.jl")
18-
include("MMatrix.jl")
19-
include("SArray.jl")
20-
include("MArray.jl")
21-
include("FieldVector.jl")
22-
include("FieldMatrix.jl")
23-
include("Scalar.jl")
24-
include("SUnitRange.jl")
25-
include("SizedArray.jl")
26-
include("SDiagonal.jl")
27-
include("SHermitianCompact.jl")
289

29-
include("custom_types.jl")
30-
include("convert.jl")
31-
include("core.jl")
32-
include("abstractarray.jl")
33-
include("indexing.jl")
34-
include("initializers.jl")
35-
Random.seed!(42); include("mapreduce.jl")
36-
Random.seed!(42); include("sort.jl")
37-
Random.seed!(42); include("accumulate.jl")
38-
Random.seed!(42); include("arraymath.jl")
39-
include("broadcast.jl")
40-
include("linalg.jl")
41-
Random.seed!(42); include("matrix_multiply.jl")
42-
Random.seed!(42); include("triangular.jl")
43-
include("det.jl")
44-
include("inv.jl")
45-
Random.seed!(42); include("solve.jl")
46-
Random.seed!(44); include("eigen.jl")
47-
include("expm.jl")
48-
include("sqrtm.jl")
49-
include("lyap.jl")
50-
Random.seed!(42); include("lu.jl")
51-
Random.seed!(42); include("qr.jl")
52-
Random.seed!(42); include("chol.jl") # hermitian_type(::Type{Any}) for block algorithm
53-
include("deque.jl")
54-
include("flatten.jl")
55-
include("io.jl")
56-
include("svd.jl")
57-
include("deprecated.jl")
10+
# Hook into Pkg.test so that tests from a single file can be run. For example,
11+
# to run only the MVector and SVector tests, use:
12+
#
13+
# Pkg.test("StaticArrays", test_args=["MVector", "SVector"])
14+
#
15+
enabled_tests = lowercase.(ARGS)
16+
function addtests(fname)
17+
key = lowercase(splitext(fname)[1])
18+
if isempty(enabled_tests) || key in enabled_tests
19+
Random.seed!(42)
20+
include(fname)
21+
end
22+
end
23+
24+
addtests("SVector.jl")
25+
addtests("MVector.jl")
26+
addtests("SMatrix.jl")
27+
addtests("MMatrix.jl")
28+
addtests("SArray.jl")
29+
addtests("MArray.jl")
30+
addtests("FieldVector.jl")
31+
addtests("FieldMatrix.jl")
32+
addtests("Scalar.jl")
33+
addtests("SUnitRange.jl")
34+
addtests("SizedArray.jl")
35+
addtests("SDiagonal.jl")
36+
addtests("SHermitianCompact.jl")
37+
38+
addtests("ambiguities.jl")
39+
addtests("custom_types.jl")
40+
addtests("convert.jl")
41+
addtests("core.jl")
42+
addtests("abstractarray.jl")
43+
addtests("indexing.jl")
44+
addtests("initializers.jl")
45+
addtests("mapreduce.jl")
46+
addtests("sort.jl")
47+
addtests("accumulate.jl")
48+
addtests("arraymath.jl")
49+
addtests("broadcast.jl")
50+
addtests("linalg.jl")
51+
addtests("matrix_multiply.jl")
52+
addtests("triangular.jl")
53+
addtests("det.jl")
54+
addtests("inv.jl")
55+
addtests("solve.jl")
56+
addtests("eigen.jl")
57+
addtests("expm.jl")
58+
addtests("sqrtm.jl")
59+
addtests("lyap.jl")
60+
addtests("lu.jl")
61+
addtests("qr.jl")
62+
addtests("chol.jl") # hermitian_type(::Type{Any}) for block algorithm
63+
addtests("deque.jl")
64+
addtests("flatten.jl")
65+
addtests("io.jl")
66+
addtests("svd.jl")
67+
addtests("deprecated.jl")

test/testutil.jl

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,6 @@ macro testinf(ex)
2626
esc(:(@test $ex))
2727
end
2828

29-
@testset "@testinf" begin
30-
@testinf [1,2] == [1,2]
31-
x = [1,2]
32-
@testinf x == [1,2]
33-
@testinf (@SVector [1,2]) == (@SVector [1,2])
34-
end
35-
3629
function test_expand_error(ex)
3730
@test_throws LoadError macroexpand(@__MODULE__, ex)
3831
end
@@ -85,17 +78,6 @@ should_be_inlined(x) = x*x
8578
@noinline _should_not_be_inlined(x) = x*x
8679
should_not_be_inlined(x) = _should_not_be_inlined(x)
8780

88-
@testset "@test_inlined" begin
89-
@test_inlined should_be_inlined(1)
90-
@test_inlined should_not_be_inlined(1) false
91-
ts = @testset ErrorCounterTestSet "" begin
92-
@test_inlined should_be_inlined(1) false
93-
@test_inlined should_not_be_inlined(1)
94-
end
95-
@test ts.errorcount == 0 && ts.failcount == 2 && ts.passcount == 0
96-
end
97-
98-
9981
"""
10082
@inferred_maybe_allow allow ex
10183
@@ -109,3 +91,22 @@ macro inferred_maybe_allow(allow, ex)
10991
return esc(:(@inferred $allow $ex))
11092
end
11193
end
94+
95+
@testset "test utils" begin
96+
@testset "@testinf" begin
97+
@testinf [1,2] == [1,2]
98+
x = [1,2]
99+
@testinf x == [1,2]
100+
@testinf (@SVector [1,2]) == (@SVector [1,2])
101+
end
102+
103+
@testset "@test_inlined" begin
104+
@test_inlined should_be_inlined(1)
105+
@test_inlined should_not_be_inlined(1) false
106+
ts = @testset ErrorCounterTestSet "" begin
107+
@test_inlined should_be_inlined(1) false
108+
@test_inlined should_not_be_inlined(1)
109+
end
110+
@test ts.errorcount == 0 && ts.failcount == 2 && ts.passcount == 0
111+
end
112+
end

0 commit comments

Comments
 (0)