From d8fd62d32873c2c0033a189fc5763e2eaffddfc5 Mon Sep 17 00:00:00 2001 From: Charles Kawczynski Date: Wed, 14 Jun 2023 09:40:53 -0700 Subject: [PATCH] Add aqua tests --- test/Project.toml | 1 + test/aqua.jl | 37 +++++++++++++++++++++++++++++++++++++ test/runtests.jl | 4 ++++ 3 files changed, 42 insertions(+) create mode 100644 test/aqua.jl diff --git a/test/Project.toml b/test/Project.toml index ec5354dea7..201d4ea27b 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -1,5 +1,6 @@ [deps] Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" +Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595" BFloat16s = "ab4f0b2a-ad5b-11e8-123f-65d77653426b" CUDA_Runtime_jll = "76a88914-d11a-5bdc-97e0-2f5a05c973a2" DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8" diff --git a/test/aqua.jl b/test/aqua.jl new file mode 100644 index 0000000000..039b72bf33 --- /dev/null +++ b/test/aqua.jl @@ -0,0 +1,37 @@ +using Test +using CUDA +using Aqua + +@testset "Aqua tests (performance)" begin + # This tests that we don't accidentally run into + # https://github.com/JuliaLang/julia/issues/29393 + # Aqua.test_unbound_args(CUDA) + ua = Aqua.detect_unbound_args_recursively(CUDA) + @info "Number of unbound argument methods: $(length(ua))" + @test length(ua) ≤ 26 + + # See: https://github.com/SciML/OrdinaryDiffEq.jl/issues/1750 + # Test that we're not introducing method ambiguities across deps + ambs = Aqua.detect_ambiguities(CUDA; recursive = true) + pkg_match(pkgname, pkdir::Nothing) = false + pkg_match(pkgname, pkdir::AbstractString) = occursin(pkgname, pkdir) + filter!(x -> pkg_match("CUDA", pkgdir(last(x).module)), ambs) + + # Uncomment for debugging: + # for method_ambiguity in ambs + # @show method_ambiguity + # end + @test length(ambs) ≤ 35 + @info "Number of method ambiguities: $(length(ambs))" +end + +@testset "Aqua tests (additional)" begin + Aqua.test_undefined_exports(CUDA) + # Aqua.test_stale_deps(CUDA) # failing + Aqua.test_deps_compat(CUDA) + Aqua.test_project_extras(CUDA) + Aqua.test_project_toml_formatting(CUDA) + # Aqua.test_piracy(CUDA) # failing +end + +nothing diff --git a/test/runtests.jl b/test/runtests.jl index 6d79a0ffe5..c686928334 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -4,6 +4,10 @@ import REPL using Printf: @sprintf using TimerOutputs +@testset "Aqua" begin + include("aqua.jl") +end + # work around JuliaLang/Pkg.jl#2500 if VERSION < v"1.8" test_project = first(Base.load_path())