diff --git a/Project.toml b/Project.toml index 45782afe..898225a7 100644 --- a/Project.toml +++ b/Project.toml @@ -22,20 +22,28 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" ForwardDiffStaticArraysExt = "StaticArrays" [compat] +Aqua = "0.8" Calculus = "0.5" CommonSubexpressions = "0.3" DiffResults = "1.1" DiffRules = "1.4" DiffTests = "0.1" +InteractiveUtils = "1" +LinearAlgebra = "1" IrrationalConstants = "0.1, 0.2" LogExpFunctions = "0.3" NaNMath = "1" Preferences = "1" +Printf = "1" +Random = "1" +SparseArrays = "1" SpecialFunctions = "1, 2" StaticArrays = "1.5" +Test = "1" julia = "1.6" [extras] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" Calculus = "49dc2e85-a5d0-5ad3-a950-438e2897f1b9" DiffTests = "de460e47-3fe3-5279-bb4a-814414816d5d" InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240" @@ -45,4 +53,4 @@ StaticArrays = "90137ffa-7385-5640-81b9-e52037218182" Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" [targets] -test = ["Calculus", "DiffTests", "IrrationalConstants", "SparseArrays", "StaticArrays", "Test", "InteractiveUtils"] +test = ["Aqua", "Calculus", "DiffTests", "IrrationalConstants", "SparseArrays", "StaticArrays", "Test", "InteractiveUtils"] diff --git a/README.md b/README.md index c9e5154b..d13dbe85 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![](https://img.shields.io/badge/docs-stable-blue.svg)](https://juliadiff.org/ForwardDiff.jl/stable) [![](https://img.shields.io/badge/docs-dev-blue.svg)](https://juliadiff.org/ForwardDiff.jl/dev) +[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl) # ForwardDiff.jl diff --git a/test/AquaTest.jl b/test/AquaTest.jl new file mode 100644 index 00000000..625044e3 --- /dev/null +++ b/test/AquaTest.jl @@ -0,0 +1,41 @@ +module AquaTest + +using Test +using ForwardDiff +using Aqua + +@testset "Aqua tests - unbound_args" begin + # This tests that we don't accidentally run into + # https://github.com/JuliaLang/julia/issues/29393 + ua = Aqua.detect_unbound_args_recursively(ForwardDiff) + @test length(ua) == 6 +end + +@testset "Aqua tests - ambiguities" begin + # See: https://github.com/SciML/OrdinaryDiffEq.jl/issues/1750 + # Test that we're not introducing method ambiguities across deps + ambs = Aqua.detect_ambiguities(ForwardDiff; recursive = true) + pkg_match(pkgname, pkdir::Nothing) = false + pkg_match(pkgname, pkdir::AbstractString) = occursin(pkgname, pkdir) + filter!(x -> pkg_match("ForwardDiff", pkgdir(last(x).module)), ambs) + + ambs_dict = Dict() + ambs_dict[(1, 6)] = 2 + ambs_dict[(1, 10)] = 1 + verkey(v) = (Int(VERSION.major), Int(VERSION.minor)) + + if haskey(ambs_dict, verkey(VERSION)) + @test length(ambs) ≤ ambs_dict[verkey(VERSION)] + # notify us when we fix one + if length(ambs) < ambs_dict[verkey(VERSION)] + @info "Ambiguities may have been fixed, please lower the limit." + @info " length(ambs) = $(length(ambs))" + end + end +end + +@testset "Aqua tests - remaining" begin + Aqua.test_all(ForwardDiff; ambiguities = false, unbound_args = false) +end + +end diff --git a/test/runtests.jl b/test/runtests.jl index e440af65..33263baf 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -6,6 +6,11 @@ Random.seed!(SEED) @testset "ForwardDiff.jl" begin t0 = time() + @testset "Aqua" begin + println("##### Testing aqua...") + t = @elapsed include("AquaTest.jl") + println("##### done (took $t seconds).") + end @testset "Partials" begin println("##### Testing Partials...") t = @elapsed include("PartialsTest.jl")