diff --git a/src/stale_deps.jl b/src/stale_deps.jl index 38eb1c6a..3c2b57c4 100644 --- a/src/stale_deps.jl +++ b/src/stale_deps.jl @@ -18,16 +18,24 @@ Test that `package` loads all dependencies listed in `Project.toml`. - `ignore::Vector{Symbol}`: names of dependent packages to be ignored. """ function test_stale_deps(packages; kwargs...) - @testset "$(result.label)" for result in analyze_stale_deps(packages, kwargs...) + @testset "$(result.label)" for result in + StaleDeps.analyze_stale_deps(packages, kwargs...) @debug result.label result @test result ⊜ true end end +module StaleDeps + +using Base: PkgId, UUID +using Pkg: TOML + +using Aqua: LazyTestResult, aspkgids, reprpkgid, root_project_or_failed_lazytest + analyze_stale_deps(packages, kwargs...) = - [_analyze_stale_deps_1(pkg; kwargs...) for pkg in aspkgids(packages)] + [analyze_stale_deps_1(pkg; kwargs...) for pkg in aspkgids(packages)] -function _analyze_stale_deps_1(pkg::PkgId; ignore::AbstractVector{Symbol} = Symbol[]) +function analyze_stale_deps_1(pkg::PkgId; ignore::AbstractVector{Symbol} = Symbol[]) label = "$pkg" result = root_project_or_failed_lazytest(pkg) @@ -62,7 +70,7 @@ function _analyze_stale_deps_1(pkg::PkgId; ignore::AbstractVector{Symbol} = Symb output = output[pos.stop+1:end] loaded_uuids = map(UUID, eachline(IOBuffer(output))) - return _analyze_stale_deps_2(; + return analyze_stale_deps_2(; pkg = pkg, deps = deps, weakdeps = weakdeps, @@ -72,7 +80,7 @@ function _analyze_stale_deps_1(pkg::PkgId; ignore::AbstractVector{Symbol} = Symb end # Side-effect -free part of stale dependency analysis. -function _analyze_stale_deps_2(; +function analyze_stale_deps_2(; pkg::PkgId, deps::AbstractVector{PkgId}, weakdeps::AbstractVector{PkgId}, @@ -109,3 +117,5 @@ function _analyze_stale_deps_2(; ] return LazyTestResult(label, join(msglines, "\n"), false) end + +end # module diff --git a/test/test_stale_deps.jl b/test/test_stale_deps.jl index 926840cb..7f14145b 100644 --- a/test/test_stale_deps.jl +++ b/test/test_stale_deps.jl @@ -1,9 +1,11 @@ module TestStaleDeps include("preamble.jl") -using Aqua: PkgId, UUID, _analyze_stale_deps_2, ispass, ⊜ +using Base: PkgId, UUID +using Aqua: ispass, ⊜ +using Aqua.StaleDeps: analyze_stale_deps, analyze_stale_deps_2 -@testset "_analyze_stale_deps_2" begin +@testset "analyze_stale_deps_2" begin pkg = PkgId(UUID(42), "TargetPkg") dep1 = PkgId(UUID(1), "Dep1") @@ -11,42 +13,42 @@ using Aqua: PkgId, UUID, _analyze_stale_deps_2, ispass, ⊜ dep3 = PkgId(UUID(3), "Dep3") @testset "pass" begin - @test _analyze_stale_deps_2(; + @test analyze_stale_deps_2(; pkg = pkg, deps = PkgId[], weakdeps = PkgId[], loaded_uuids = UUID[], ignore = Symbol[], ) ⊜ true - @test _analyze_stale_deps_2(; + @test analyze_stale_deps_2(; pkg = pkg, deps = PkgId[dep1], weakdeps = PkgId[], loaded_uuids = UUID[dep1.uuid, dep2.uuid, dep3.uuid], ignore = Symbol[], ) ⊜ true - @test _analyze_stale_deps_2(; + @test analyze_stale_deps_2(; pkg = pkg, deps = PkgId[dep1], weakdeps = PkgId[], loaded_uuids = UUID[dep2.uuid, dep3.uuid], ignore = Symbol[:Dep1], ) ⊜ true - @test _analyze_stale_deps_2(; + @test analyze_stale_deps_2(; pkg = pkg, deps = PkgId[dep1], weakdeps = PkgId[dep2], loaded_uuids = UUID[dep1.uuid], ignore = Symbol[], ) ⊜ true - @test _analyze_stale_deps_2(; + @test analyze_stale_deps_2(; pkg = pkg, deps = PkgId[dep1, dep2], weakdeps = PkgId[dep2], loaded_uuids = UUID[dep1.uuid], ignore = Symbol[], ) ⊜ true - @test _analyze_stale_deps_2(; + @test analyze_stale_deps_2(; pkg = pkg, deps = PkgId[dep1, dep2], weakdeps = PkgId[dep2], @@ -55,21 +57,21 @@ using Aqua: PkgId, UUID, _analyze_stale_deps_2, ispass, ⊜ ) ⊜ true end @testset "failure" begin - @test _analyze_stale_deps_2(; + @test analyze_stale_deps_2(; pkg = pkg, deps = PkgId[dep1], weakdeps = PkgId[], loaded_uuids = UUID[], ignore = Symbol[], ) ⊜ false - @test _analyze_stale_deps_2(; + @test analyze_stale_deps_2(; pkg = pkg, deps = PkgId[dep1], weakdeps = PkgId[], loaded_uuids = UUID[dep2.uuid, dep3.uuid], ignore = Symbol[], ) ⊜ false - @test _analyze_stale_deps_2(; + @test analyze_stale_deps_2(; pkg = pkg, deps = PkgId[dep1, dep2], weakdeps = PkgId[], @@ -82,7 +84,7 @@ end with_sample_pkgs() do @testset "Package without `deps`" begin pkg = AquaTesting.SAMPLE_PKG_BY_NAME["PkgWithoutTestProject"] - results = Aqua.analyze_stale_deps(pkg) + results = analyze_stale_deps(pkg) @test length(results) == 1 r, = results @test ispass(r) @@ -92,7 +94,7 @@ with_sample_pkgs() do end @testset "PkgWithoutProject" begin pkg = AquaTesting.SAMPLE_PKG_BY_NAME["PkgWithoutProject"] - results = Aqua.analyze_stale_deps(pkg) + results = analyze_stale_deps(pkg) @test length(results) == 1 r, = results @test !ispass(r)