diff --git a/test/linting.jl b/test/linting.jl new file mode 100644 index 0000000..4ae6a26 --- /dev/null +++ b/test/linting.jl @@ -0,0 +1,78 @@ +using SparseConnectivityTracer +using Test + +using JuliaFormatter: JuliaFormatter +using Aqua: Aqua +using JET: JET +using ExplicitImports: ExplicitImports + +# Load package extensions so they get tested by ExplicitImports.jl +using DataInterpolations: DataInterpolations +using NaNMath: NaNMath +using NNlib: NNlib +using SpecialFunctions: SpecialFunctions + +@testset "Code formatting" begin + @info "...with JuliaFormatter.jl" + @test JuliaFormatter.format(SparseConnectivityTracer; verbose=false, overwrite=false) +end + +@testset "Aqua tests" begin + @info "...with Aqua.jl" + Aqua.test_all( + SparseConnectivityTracer; + ambiguities=false, + deps_compat=(check_extras=false,), + stale_deps=(ignore=[:Requires],), + persistent_tasks=false, + ) +end + +@testset "JET tests" begin + @info "...with JET.jl" + JET.test_package(SparseConnectivityTracer; target_defined_modules=true) +end + +@testset "ExplicitImports tests" begin + @info "...with ExplicitImports.jl" + @testset "Improper implicit imports" begin + @test ExplicitImports.check_no_implicit_imports(SparseConnectivityTracer) === + nothing + end + @testset "Improper explicit imports" begin + @test ExplicitImports.check_no_stale_explicit_imports( + SparseConnectivityTracer; + ignore=( + # Used in code generation, which ExplicitImports doesn't pick up + :AbstractTracer, + :AkimaInterpolation, + :BSplineApprox, + :BSplineInterpolation, + :CubicHermiteSpline, + :CubicSpline, + :LagrangeInterpolation, + :QuadraticInterpolation, + :QuadraticSpline, + :QuinticHermiteSpline, + ), + ) === nothing + @test ExplicitImports.check_all_explicit_imports_via_owners( + SparseConnectivityTracer + ) === nothing + # TODO: test in the future when `public` is more common + # @test ExplicitImports.check_all_explicit_imports_are_public( + # SparseConnectivityTracer + # ) === nothing + end + @testset "Improper qualified accesses" begin + @test ExplicitImports.check_all_qualified_accesses_via_owners( + SparseConnectivityTracer + ) === nothing + @test ExplicitImports.check_no_self_qualified_accesses(SparseConnectivityTracer) === + nothing + # TODO: test in the future when `public` is more common + # @test ExplicitImports.check_all_qualified_accesses_are_public( + # SparseConnectivityTracer + # ) === nothing + end +end diff --git a/test/runtests.jl b/test/runtests.jl index 1b5f103..c2eb073 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -5,19 +5,8 @@ Pkg.develop(; using SparseConnectivityTracer using Compat: pkgversion -using Test - -using JuliaFormatter: JuliaFormatter -using Aqua: Aqua -using JET: JET -using ExplicitImports: ExplicitImports using Documenter: Documenter, DocMeta - -# Load package extensions so they get tested by ExplicitImports.jl -using DataInterpolations: DataInterpolations -using NaNMath: NaNMath -using NNlib: NNlib -using SpecialFunctions: SpecialFunctions +using Test DocMeta.setdocmeta!( SparseConnectivityTracer, @@ -30,80 +19,18 @@ GROUP = get(ENV, "JULIA_SCT_TEST_GROUP", "Core") @testset verbose = true "SparseConnectivityTracer.jl" begin if GROUP in ("Core", "All") - @testset verbose = true "Formalities" begin - @info "Testing formalities..." - if VERSION >= v"1.10" - @testset "Code formatting" begin - @info "...with JuliaFormatter.jl" - @test JuliaFormatter.format( - SparseConnectivityTracer; verbose=false, overwrite=false - ) - end - @testset "Aqua tests" begin - @info "...with Aqua.jl" - Aqua.test_all( - SparseConnectivityTracer; - ambiguities=false, - deps_compat=(check_extras=false,), - stale_deps=(ignore=[:Requires],), - persistent_tasks=false, - ) - end - @testset "JET tests" begin - @info "...with JET.jl" - JET.test_package(SparseConnectivityTracer; target_defined_modules=true) - end - @testset "ExplicitImports tests" begin - @info "...with ExplicitImports.jl" - @testset "Improper implicit imports" begin - @test ExplicitImports.check_no_implicit_imports( - SparseConnectivityTracer - ) === nothing - end - @testset "Improper explicit imports" begin - @test ExplicitImports.check_no_stale_explicit_imports( - SparseConnectivityTracer; - ignore=( - :AbstractTracer, - :AkimaInterpolation, - :BSplineApprox, - :BSplineInterpolation, - :CubicHermiteSpline, - :CubicSpline, - :LagrangeInterpolation, - :QuadraticInterpolation, - :QuadraticSpline, - :QuinticHermiteSpline, - ), - ) === nothing - @test ExplicitImports.check_all_explicit_imports_via_owners( - SparseConnectivityTracer - ) === nothing - # TODO: test in the future when `public` is more common - # @test ExplicitImports.check_all_explicit_imports_are_public( - # SparseConnectivityTracer - # ) === nothing - end - @testset "Improper qualified accesses" begin - @test ExplicitImports.check_all_qualified_accesses_via_owners( - SparseConnectivityTracer - ) === nothing - @test ExplicitImports.check_no_self_qualified_accesses( - SparseConnectivityTracer - ) === nothing - # TODO: test in the future when `public` is more common - # @test ExplicitImports.check_all_qualified_accesses_are_public( - # SparseConnectivityTracer - # ) === nothing - end - end - end - @testset "Doctests" begin - Documenter.doctest(SparseConnectivityTracer) + if VERSION >= v"1.10" + @testset verbose = true "Linting" begin + @info "Testing linting..." + include("linting.jl") end end end - + if GROUP in ("Core", "All") + @testset "Doctests" begin + Documenter.doctest(SparseConnectivityTracer) + end + end if GROUP in ("Core", "All") @testset verbose = true "Set types" begin @testset "Correctness" begin