From 15a62d51d83a647f0cdd970e74f3ade5ad011ce8 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Tue, 5 Sep 2023 13:28:36 -0700 Subject: [PATCH] Add and fix aqua tests --- test/Project.toml | 3 ++- test/aqua.jl | 37 +++++++++++++++++++++++++++++++++++++ test/runtests.jl | 1 + 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 test/aqua.jl diff --git a/test/Project.toml b/test/Project.toml index cc349f71..dba60b07 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,4 +1,5 @@ [deps] +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" ArtifactWrappers = "a14bc488-3040-4b00-9dc1-f6467924858a" BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf" CLIMAParameters = "6eacf6c3-8458-43b9-ae03-caf5306d3d53" @@ -20,8 +21,8 @@ Thermodynamics = "b60c26fb-14c3-4610-9d3e-2d17fe7ff00c" UnPack = "3a884ed6-31ef-47d7-9d2a-63182c4928ed" [compat] -CLIMAParameters = "0.6, 0.7" ArtifactWrappers = "0.2" +CLIMAParameters = "0.6, 0.7" KernelAbstractions = "0.7, 0.8" RootSolvers = "0.4" UnPack = "1.0" diff --git a/test/aqua.jl b/test/aqua.jl new file mode 100644 index 00000000..ce47cdb4 --- /dev/null +++ b/test/aqua.jl @@ -0,0 +1,37 @@ +using Test +using Thermodynamics +using Aqua + +@testset "Aqua tests (performance)" begin + # This tests that we don't accidentally run into + # https://github.com/JuliaLang/julia/issues/29393 + ua = Aqua.detect_unbound_args_recursively(Thermodynamics) + @test length(ua) == 0 + + # See: https://github.com/SciML/OrdinaryDiffEq.jl/issues/1750 + # Test that we're not introducing method ambiguities across deps + ambs = Aqua.detect_ambiguities(Thermodynamics; recursive = true) + pkg_match(pkgname, pkdir::Nothing) = false + pkg_match(pkgname, pkdir::AbstractString) = occursin(pkgname, pkdir) + filter!(x -> pkg_match("Thermodynamics", pkgdir(last(x).module)), ambs) + + # If the number of ambiguities is less than the limit below, + # then please lower the limit based on the new number of ambiguities. + # We're trying to drive this number down to zero to reduce latency. + # Uncomment for debugging: + for method_ambiguity in ambs + @show method_ambiguity + end + @test length(ambs) ≤ 0 +end + +@testset "Aqua tests (additional)" begin + Aqua.test_undefined_exports(Thermodynamics) + Aqua.test_stale_deps(Thermodynamics) + Aqua.test_deps_compat(Thermodynamics) + Aqua.test_project_extras(Thermodynamics) + Aqua.test_project_toml_formatting(Thermodynamics) + Aqua.test_piracy(Thermodynamics) +end + +nothing diff --git a/test/runtests.jl b/test/runtests.jl index 80c83bc6..df5c396c 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,6 +3,7 @@ if !haskey(ENV, "BUILDKITE") Pkg.develop(Pkg.PackageSpec(; path = dirname(@__DIR__))) end +include("aqua.jl") include("TemperatureProfiles.jl") include("relations.jl")