Skip to content

Commit

Permalink
Add separate linting file
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill committed Sep 4, 2024
1 parent f360475 commit 376e79b
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 83 deletions.
78 changes: 78 additions & 0 deletions test/linting.jl
Original file line number Diff line number Diff line change
@@ -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
93 changes: 10 additions & 83 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 376e79b

Please sign in to comment.