Skip to content

Commit aa260f4

Browse files
committed
use SafeTestsets
1 parent e3b7fe8 commit aa260f4

File tree

4 files changed

+49
-63
lines changed

4 files changed

+49
-63
lines changed

test/runtests.jl

Lines changed: 15 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
using DistributionFits
2-
using Test
3-
using Random: Random
4-
using LoggingExtras
5-
6-
71
tmpf = () -> begin
82
push!(LOAD_PATH, expanduser("~/julia/devtools/")) # access local pack
93
push!(LOAD_PATH, joinpath(pwd(), "test/")) # access local pack
@@ -13,60 +7,20 @@ using Test, SafeTestsets
137
const GROUP = get(ENV, "GROUP", "All") # defined in in CI.yml
148
@show GROUP
159

16-
# @time begin
17-
# if GROUP == "All" || GROUP == "Basic"
18-
# #@safetestset "Tests" include("test/test_plant_face_fluct.jl")
19-
# @time @safetestset "plant_face_fluct" include("test_plant_face_fluct.jl")
20-
# end
21-
# if GROUP == "All" || GROUP == "JET"
22-
# #@safetestset "Tests" include("test/test_JET.jl")
23-
# @time @safetestset "test_JET" include("test_JET.jl")
24-
# #@safetestset "Tests" include("test/test_aqua.jl")
25-
# @time @safetestset "test_Aqua" include("test_aqua.jl")
26-
# end
27-
# end
28-
29-
30-
#using Aqua; Aqua.test_all(DistributionFits) # ambiguities from other packages
31-
#using JET; JET.report_package(DistributionFits) #
32-
#invalid possible error due to quantile may accept/return an Array (we pass a scalar)
33-
#only report problems in this module:
34-
#using JET; JET.report_package(DistributionFits; target_modules=(@__MODULE__,)) #
35-
36-
@testset "optimize error" begin
37-
@test_throws Exception DistributionFits.optimize(x -> x * x, -1, 1)
38-
end
39-
using Optim: Optim, optimize
40-
41-
DistributionFitsOptimExt = isdefined(Base, :get_extension) ?
42-
Base.get_extension(DistributionFits, :DistributionFitsOptimExt) :
43-
DistributionFits.DistributionFitsOptimExt
44-
45-
@testset "optimize set in __init__ after using Optim" begin
46-
# set in __init__
47-
@test DistributionFits.df_optimizer isa DistributionFitsOptimExt.OptimOptimizer
10+
@time begin
11+
if GROUP == "All" || GROUP == "Basic"
12+
#@safetestset "Tests" include("test/test_optim.jl")
13+
@time @safetestset "test_optim" include("test_optim.jl")
14+
#@safetestset "Tests" include("test/fitstats.jl")
15+
@time @safetestset "fitstats" include("fitstats.jl")
16+
#@safetestset "Tests" include("test/univariate/test_univariate.jl")
17+
@time @safetestset "test_univariate" include("univariate/test_univariate.jl")
18+
end
19+
if GROUP == "All" || GROUP == "JET"
20+
#@safetestset "Tests" include("test/test_JET.jl")
21+
@time @safetestset "test_JET" include("test_JET.jl")
22+
#@safetestset "Tests" include("test/test_aqua.jl")
23+
@time @safetestset "test_Aqua" include("test_aqua.jl")
24+
end
4825
end
4926

50-
#include("test/testutils.jl")
51-
include("testutils.jl")
52-
53-
#include("test/fitstats.jl")
54-
include("fitstats.jl")
55-
56-
#include("test/univariate/test_univariate.jl")
57-
include("univariate/test_univariate.jl")
58-
59-
# test coverage of set_optimize (already called in init)
60-
61-
# print method ambiguities
62-
println("Potentially stale exports: ")
63-
display(Test.detect_ambiguities(DistributionFits))
64-
println()
65-
66-
using JET: JET
67-
@testset "JET" begin
68-
@static if VERSION v"1.9.2"
69-
JET.test_package(DistributionFits; target_modules=(@__MODULE__,)) #
70-
end
71-
end;
72-

test/test_aqua.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ using Aqua
88
DistributionFits;
99
#unbound_args = false, # does not recognize NamedTuple{K, NTuple{N,E}}
1010
stale_deps = (ignore = [:Requires],),
11-
#ambiguities = false, # many ambiguities in Symbolic and Stats packages
11+
ambiguities = false, # ambiguities in StatsBase
1212
piracies = false
1313
)
1414
end;

test/test_optim.jl

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using DistributionFits
2+
using Test
3+
4+
# before loading Optim
5+
@testset "optimize error" begin
6+
@test_throws Exception DistributionFits.optimize(x -> x * x, -1, 1)
7+
end
8+
9+
# after loading Optim
10+
using Optim: Optim, optimize
11+
12+
DistributionFitsOptimExt = isdefined(Base, :get_extension) ?
13+
Base.get_extension(DistributionFits, :DistributionFitsOptimExt) :
14+
DistributionFits.DistributionFitsOptimExt
15+
16+
@testset "optimize set in __init__ after using Optim" begin
17+
# set in __init__
18+
@test DistributionFits.df_optimizer isa DistributionFitsOptimExt.OptimOptimizer
19+
end
20+
21+

test/univariate/test_univariate.jl

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
using DistributionFits
2+
using Test
3+
using Random: Random
4+
using LoggingExtras
5+
using Optim
6+
7+
pkgdir = dirname(dirname(pathof(DistributionFits)))
8+
testdir = joinpath(pkgdir, "test")
9+
include(joinpath(testdir,"testutils.jl"))
10+
111
function test_univariate_fits(d, D = typeof(d))
212
@testset "fit moments" begin
313
if !occursin("fit(::Type{D}",
@@ -110,6 +120,7 @@ function test_univariate_fits(d, D = typeof(d))
110120
end
111121
end
112122

123+
113124
const tests = [
114125
"weibull",
115126
"normal",
@@ -124,6 +135,6 @@ const tests = [
124135
for t in tests
125136
@testset "Test $t" begin
126137
Random.seed!(345679)
127-
include("continuous/$t.jl")
138+
include(joinpath(testdir,"univariate","continuous","$t.jl"))
128139
end
129140
end

0 commit comments

Comments
 (0)