Skip to content

Commit 7caf869

Browse files
authored
Merge pull request #511 from mcabbott/test_args
Accept `test_args` to specify which files to test
2 parents 649bfbb + 2aae1c4 commit 7caf869

File tree

6 files changed

+51
-48
lines changed

6 files changed

+51
-48
lines changed

test/rulesets/Base/array.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "constructors" begin
1+
@testset "Array constructors" begin
22

33
# We can't use test_rrule here (as it's currently implemented) because the elements of
44
# the array have arbitrary values. The only thing we can do is ensure that we're getting

test/rulesets/Base/arraymath.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "arraymath" begin
1+
@testset "arraymath.jl" begin
22
@testset "inv(::Matrix{$T})" for T in (Float64, ComplexF64)
33
B = generate_well_conditioned_matrix(T, 3)
44
test_frule(inv, B)

test/rulesets/Base/base.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "base" begin
1+
@testset "base.jl" begin
22
@testset "copysign" begin
33
# don't go too close to zero as the numerics may jump over it yielding wrong results
44
@testset "at $y" for y in (-1.1, 0.1, 100.0)

test/rulesets/LinearAlgebra/dense.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@testset "dense" begin
1+
@testset "dense LinearAlgebra" begin
22
@testset "dot" begin
33
@testset "Vector{$T}" for T in (Float64, ComplexF64)
44
test_frule(dot, randn(T, 3), randn(T, 3))

test/rulesets/Random/random.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ struct NormalDistribution
55
end
66
Random.rand(d::NormalDistribution) = d.μ + d.σ*randn()
77

8-
@testset "random" begin
8+
@testset "Random" begin
99
rng_types = [MersenneTwister]
1010
isdefined(Random, :Xoshiro) && push!(rng_types, getfield(Random, :Xoshiro))
1111

test/runtests.jl

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,55 +22,58 @@ union!(JuliaInterpreter.compiled_modules, Any[Base, Base.Broadcast, Compat, Line
2222

2323
Random.seed!(1) # Set seed that all testsets should reset to.
2424

25-
function include_test(path::String)
26-
println("Testing $path:") # print so TravisCI doesn't timeout due to no output
27-
@time Base.include(@__MODULE__(), path) do ex
28-
Meta.isexpr(ex, :macrocall) && ex.args[1] == Symbol("@testset") || return ex
29-
return :(@interpret (() -> $ex)()) # interpret testsets using JuliaInterpreter
25+
function include_test(path)
26+
if isempty(ARGS) || any(occursin(a, path) for a in ARGS)
27+
println("Testing $path:") # print so TravisCI doesn't timeout due to no output
28+
@time Base.include(@__MODULE__(), path) do ex
29+
Meta.isexpr(ex, :macrocall) && ex.args[1] == Symbol("@testset") || return ex
30+
return :(@interpret (() -> $ex)()) # interpret testsets using JuliaInterpreter
31+
end
32+
else
33+
# If you provide ARGS like so, then it runs only matching testsets:
34+
# Pkg.test("ChainRules", test_args = ["index", "LinearAlgebra"])
35+
println("(Not testing $path)")
3036
end
3137
end
3238

33-
println("Testing ChainRules.jl")
34-
@testset "ChainRules" begin
35-
include_test("test_helpers.jl")
39+
if isempty(ARGS)
40+
println("Testing ChainRules.jl")
41+
else
42+
println("Testing ChainRules.jl with test_args = ", ARGS)
43+
end
44+
45+
@testset "ChainRules" begin # One overall @testset ensures it keeps going after failures
46+
include("test_helpers.jl")
3647
println()
37-
@testset "rulesets" begin
38-
@testset "Core" begin
39-
include_test("rulesets/Core/core.jl")
40-
end
4148

42-
@testset "Base" begin
43-
include_test("rulesets/Base/base.jl")
44-
include_test("rulesets/Base/fastmath_able.jl")
45-
include_test("rulesets/Base/evalpoly.jl")
46-
include_test("rulesets/Base/array.jl")
47-
include_test("rulesets/Base/arraymath.jl")
48-
include_test("rulesets/Base/indexing.jl")
49-
include_test("rulesets/Base/mapreduce.jl")
50-
include_test("rulesets/Base/sort.jl")
51-
end
52-
println()
49+
# Each file puts all tests inside one or more @testset blocks
50+
include_test("rulesets/Base/base.jl")
51+
include_test("rulesets/Base/fastmath_able.jl")
52+
include_test("rulesets/Base/evalpoly.jl")
53+
include_test("rulesets/Base/array.jl")
54+
include_test("rulesets/Base/arraymath.jl")
55+
include_test("rulesets/Base/indexing.jl")
56+
include_test("rulesets/Base/mapreduce.jl")
57+
include_test("rulesets/Base/sort.jl")
5358

54-
@testset "Statistics" begin
55-
include_test("rulesets/Statistics/statistics.jl")
56-
end
57-
println()
59+
println()
5860

59-
@testset "LinearAlgebra" begin
60-
include_test("rulesets/LinearAlgebra/dense.jl")
61-
include_test("rulesets/LinearAlgebra/norm.jl")
62-
include_test("rulesets/LinearAlgebra/matfun.jl")
63-
include_test("rulesets/LinearAlgebra/structured.jl")
64-
include_test("rulesets/LinearAlgebra/symmetric.jl")
65-
include_test("rulesets/LinearAlgebra/factorization.jl")
66-
include_test("rulesets/LinearAlgebra/blas.jl")
67-
include_test("rulesets/LinearAlgebra/lapack.jl")
68-
end
69-
println()
61+
include_test("rulesets/Statistics/statistics.jl")
7062

71-
@testset "Random" begin
72-
include_test("rulesets/Random/random.jl")
73-
end
74-
println()
75-
end
63+
println()
64+
65+
include_test("rulesets/LinearAlgebra/dense.jl")
66+
include_test("rulesets/LinearAlgebra/norm.jl")
67+
include_test("rulesets/LinearAlgebra/matfun.jl")
68+
include_test("rulesets/LinearAlgebra/structured.jl")
69+
include_test("rulesets/LinearAlgebra/symmetric.jl")
70+
include_test("rulesets/LinearAlgebra/factorization.jl")
71+
include_test("rulesets/LinearAlgebra/blas.jl")
72+
include_test("rulesets/LinearAlgebra/lapack.jl")
73+
74+
println()
75+
76+
include_test("rulesets/Random/random.jl")
77+
78+
println()
7679
end

0 commit comments

Comments
 (0)