diff --git a/src/Aqua.jl b/src/Aqua.jl index cec5fd1d..a4c903ed 100644 --- a/src/Aqua.jl +++ b/src/Aqua.jl @@ -21,7 +21,7 @@ using .Versions: VersionSpec, semver_spec include("utils.jl") include("ambiguities.jl") include("unbound_args.jl") -include("exports.jl") +include("undefined_exports.jl") include("project_extras.jl") include("stale_deps.jl") include("deps_compat.jl") diff --git a/src/ambiguities.jl b/src/ambiguities.jl index 4491a49b..c9ec338d 100644 --- a/src/ambiguities.jl +++ b/src/ambiguities.jl @@ -25,31 +25,27 @@ false-positive. - Other keyword arguments such as `imported` and `ambiguous_bottom` are passed to `Test.detect_ambiguities` as-is. """ -test_ambiguities(packages; kwargs...) = _test_ambiguities(aspkgids(packages); kwargs...) +function test_ambiguities(packages; broken::Bool = false, kwargs...) + num_ambiguities, strout, strerr = Ambiguities.find_ambiguities(packages; kwargs...) -const ExcludeSpec = Pair{Base.PkgId,String} - -aspkgids(pkg::Union{Module,PkgId}) = aspkgids([pkg]) -aspkgids(packages) = mapfoldl(aspkgid, push!, packages, init = PkgId[]) + println(stderr, strerr) + println(stdout, strout) -aspkgid(pkg::PkgId) = pkg -function aspkgid(m::Module) - if !ispackage(m) - error("Non-package (non-toplevel) module is not supported. Got: $m") + if broken + @test_broken num_ambiguities == 0 + else + @test num_ambiguities == 0 end - return PkgId(m) -end -function aspkgid(name::Symbol) - # Maybe `Base.depwarn()` - return Base.identify_package(String(name))::PkgId end -ispackage(m::Module) = - if m in (Base, Core) - true - else - parentmodule(m) == m - end +module Ambiguities + +using Base: PkgId +using Test: detect_ambiguities + +using ..Aqua: aspkgids, checked_repr, reprpkgid + +const ExcludeSpec = Pair{Base.PkgId,String} strnameof(x) = string(x) strnameof(x::Type) = string(nameof(x)) @@ -81,23 +77,15 @@ function reprexclude(exspecs::Vector{ExcludeSpec}) itemreprs = map(exspecs) do (pkgid, name) string("(", reprpkgid(pkgid), " => ", repr(name), ")") end - return string("Aqua.ExcludeSpec[", join(itemreprs, ", "), "]") + return string("Aqua.Ambiguities.ExcludeSpec[", join(itemreprs, ", "), "]") end -function _test_ambiguities(packages::Vector{PkgId}; broken::Bool = false, kwargs...) - num_ambiguities, strout, strerr = _find_ambiguities(packages; kwargs...) - - println(stderr, strerr) - println(stdout, strout) - - if broken - @test_broken num_ambiguities == 0 - else - @test num_ambiguities == 0 - end +function find_ambiguities(packages; kwargs...) + package_ids = aspkgids(packages)::Vector{PkgId} + return find_ambiguities(package_ids; kwargs...) end -function _find_ambiguities( +function find_ambiguities( packages::Vector{PkgId}; color::Union{Bool,Nothing} = nothing, exclude::AbstractVector = [], @@ -113,7 +101,7 @@ function _find_ambiguities( code = """ $(Base.load_path_setup_code()) using Aqua - Aqua.test_ambiguities_impl( + Aqua.Ambiguities.test_ambiguities_impl( $packages_repr, $options_repr, $exclude_repr, @@ -153,15 +141,6 @@ function reprpkgids(packages::Vector{PkgId}) return packages_repr end -function reprpkgid(pkg::PkgId) - name = pkg.name - if pkg.uuid === nothing - return "Base.PkgId($(repr(name)))" - end - uuid = pkg.uuid.value - return "Base.PkgId(Base.UUID($(repr(uuid))), $(repr(name)))" -end - struct _NoValue end function getobj(m::Method) @@ -252,3 +231,5 @@ function ambiguity_hint(m1::Method, m2::Method) end end end + +end # module diff --git a/src/deps_compat.jl b/src/deps_compat.jl index 3039d155..424e6b89 100644 --- a/src/deps_compat.jl +++ b/src/deps_compat.jl @@ -11,14 +11,27 @@ Test that `Project.toml` of `package` list all `compat` for `deps`. - `ignore::Vector{Symbol}`: names of dependent packages to be ignored. """ function test_deps_compat(packages; kwargs...) - @testset "$(result.label)" for result in analyze_deps_compat(packages; kwargs...) + @testset "$(result.label)" for result in + DepsCompat.analyze_deps_compat(packages; kwargs...) @debug result.label result @test result ⊜ true end end +module DepsCompat + +using Base: PkgId, UUID +using Pkg: TOML + +using ..Aqua: LazyTestResult, aspkgids, isnothing, root_project_or_failed_lazytest, stdlibs + function analyze_deps_compat(packages; kwargs...) - result = [_analyze_deps_compat_1(pkg; kwargs...) for pkg in aspkgids(packages)] + package_ids = aspkgids(packages)::Vector{PkgId} + return analyze_deps_compat(package_ids; kwargs...) +end + +function analyze_deps_compat(packages::Vector{PkgId}; kwargs...) + result = [_analyze_deps_compat_1(pkg; kwargs...) for pkg in packages] return result end @@ -82,3 +95,5 @@ function _analyze_deps_compat_2( true, ) end + +end # module diff --git a/src/exports.jl b/src/exports.jl deleted file mode 100644 index 538b6d96..00000000 --- a/src/exports.jl +++ /dev/null @@ -1,43 +0,0 @@ -function walkmodules(f, x::Module) - f(x) - for n in names(x; all = true) - # `isdefined` and `getproperty` can trigger deprecation warnings - if Base.isbindingresolved(x, n) && !Base.isdeprecated(x, n) - isdefined(x, n) || continue - y = getproperty(x, n) - if y isa Module && y !== x && parentmodule(y) === x - walkmodules(f, y) - end - end - end -end - -""" - undefined_exports(m::Module) :: Vector{Symbol} -""" -function undefined_exports(m::Module) - undefined = Symbol[] - walkmodules(m) do x - for n in names(x) - isdefined(x, n) || push!(undefined, n) - end - end - return undefined -end - -""" - test_undefined_exports(module::Module) - -Test that all `export`ed names in `module` actually exist. - -# Keyword Arguments -- `broken::Bool = false`: If true, it uses `@test_broken` instead of - `@test`. -""" -function test_undefined_exports(m::Module; broken::Bool = false) - if broken - @test_broken undefined_exports(m) == [] - else - @test undefined_exports(m) == [] - end -end diff --git a/src/piracy.jl b/src/piracy.jl index a552b623..b79ea4c4 100644 --- a/src/piracy.jl +++ b/src/piracy.jl @@ -1,3 +1,38 @@ +""" + test_piracy(m::Module) + +Test that `m` does not commit type piracy. +See [Julia documentation](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-type-piracy) +for more information about type piracy. + +# Keyword Arguments +- `broken::Bool = false`: If true, it uses `@test_broken` instead of + `@test`. +- `treat_as_own = Union{Function, Type}[]`: The types in this container + are considered to be "owned" by the module `m`. This is useful for + testing packages that deliberately commit some type piracy, e.g. modules + adding higher-level functionality to a lightweight C-wrapper, or packages + that are extending `StatsAPI.jl`. +""" +function test_piracy(m::Module; broken::Bool = false, kwargs...) + v = Piracy.hunt(m; kwargs...) + if !isempty(v) + printstyled( + stderr, + "Possible type-piracy detected:\n"; + bold = true, + color = Base.error_color(), + ) + show(stderr, MIME"text/plain"(), v) + println(stderr) + end + if broken + @test_broken isempty(v) + else + @test isempty(v) + end +end + module Piracy using Test: @test, @test_broken @@ -172,37 +207,3 @@ function hunt(pkg::Base.PkgId; from::Module, kwargs...) end end # module - -""" - test_piracy(m::Module) - -Test that `m` does not commit type piracy. -See [Julia documentation](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-type-piracy) for more information about type piracy. - -# Keyword Arguments -- `broken::Bool = false`: If true, it uses `@test_broken` instead of - `@test`. -- `treat_as_own = Union{Function, Type}[]`: The types in this container - are considered to be "owned" by the module `m`. This is useful for - testing packages that deliberately commit some type piracy, e.g. modules - adding higher-level functionality to a lightweight C-wrapper, or packages - that are extending `StatsAPI.jl`. -""" -function test_piracy(m::Module; broken::Bool = false, kwargs...) - v = Piracy.hunt(m; kwargs...) - if !isempty(v) - printstyled( - stderr, - "Possible type-piracy detected:\n"; - bold = true, - color = Base.error_color(), - ) - show(stderr, MIME"text/plain"(), v) - println(stderr) - end - if broken - @test_broken isempty(v) - else - @test isempty(v) - end -end diff --git a/src/project_extras.jl b/src/project_extras.jl index d64bd50a..57883817 100644 --- a/src/project_extras.jl +++ b/src/project_extras.jl @@ -8,25 +8,36 @@ Julia < 1.2 while recording test-only dependency compatibility in `test/Project.toml`. """ function test_project_extras(packages) - @testset "$(result.label)" for result in analyze_project_extras(packages) + @testset "$(result.label)" for result in map( + ProjectExtras.analyze_project_extras, + aspkgids(packages), + ) @debug result.label result @test result ⊜ true end end -function project_toml_path(dir) - candidates = joinpath.(dir, ["Project.toml", "JuliaProject.toml"]) - i = findfirst(isfile, candidates) - i === nothing && return candidates[1], false - return candidates[i], true -end +module ProjectExtras + +using Base: PkgId +using Pkg: TOML -analyze_project_extras(packages) = map(_analyze_project_extras, aspkgids(packages)) +using ..Aqua: + LazyTestResult, + VersionSpec, + aspkgid, + project_toml_path, + root_project_or_failed_lazytest, + semver_spec is_julia12_or_later(compat::AbstractString) = is_julia12_or_later(semver_spec(compat)) is_julia12_or_later(compat::VersionSpec) = isempty(compat ∩ semver_spec("1.0 - 1.1")) -function _analyze_project_extras(pkg::PkgId) +function analyze_project_extras(pkg) + return analyze_project_extras(aspkgid(pkg)) +end + +function analyze_project_extras(pkg::PkgId) label = string(pkg) result = root_project_or_failed_lazytest(pkg) @@ -101,3 +112,5 @@ function _analyze_project_extras(pkg::PkgId) return LazyTestResult(label, msg, false) end end + +end # module diff --git a/src/project_toml_formatting.jl b/src/project_toml_formatting.jl index 7431f725..ff1eb61b 100644 --- a/src/project_toml_formatting.jl +++ b/src/project_toml_formatting.jl @@ -2,14 +2,21 @@ Aqua.test_project_toml_formatting(packages) """ function test_project_toml_formatting(packages) - @testset "$(result.label)" for result in analyze_project_toml_formatting(packages) + @testset "$(result.label)" for result in + ProjectTomlFormatting.analyze_project_toml_formatting( + packages, + ) @debug result.label result @test result ⊜ true end end -analyze_project_toml_formatting(packages) = - [_analyze_project_toml_formatting_1(path) for path in project_toml_files_in(packages)] +module ProjectTomlFormatting + +using Base: PkgId +using Pkg: TOML + +using Aqua: LazyTestResult, format_diff, project_toml_path project_toml_files_in(path::AbstractString) = [path] project_toml_files_in(m::Module) = project_toml_files_in(PkgId(m)) @@ -31,7 +38,32 @@ end project_toml_files_in(iterable) = [path for x in iterable for path in project_toml_files_in(x)] -function _analyze_project_toml_formatting_1(path::AbstractString) +const _project_key_order = [ + "name", + "uuid", + "keywords", + "license", + "desc", + "deps", + "weakdeps", + "extensions", + "compat", + "extras", + "targets", +] + +print_project(io, dict) = + TOML.print(io, dict, sorted = true, by = key -> (project_key_order(key), key)) + +project_key_order(key::String) = + something(findfirst(x -> x == key, _project_key_order), length(_project_key_order) + 1) + +splitlines(str; kwargs...) = readlines(IOBuffer(str); kwargs...) + +analyze_project_toml_formatting(packages) = + [analyze_project_toml_formatting_1(path) for path in project_toml_files_in(packages)] + +function analyze_project_toml_formatting_1(path::AbstractString) label = path if !isfile(path) @@ -39,10 +71,10 @@ function _analyze_project_toml_formatting_1(path::AbstractString) end original = read(path, String) - return _analyze_project_toml_formatting_2(path, original) + return analyze_project_toml_formatting_2(path, original) end -function _analyze_project_toml_formatting_2(path::AbstractString, original) +function analyze_project_toml_formatting_2(path::AbstractString, original) @debug "Checking TOML style: `$path`" Text(original) label = path @@ -66,3 +98,5 @@ function _analyze_project_toml_formatting_2(path::AbstractString, original) ) end end + +end # module diff --git a/src/stale_deps.jl b/src/stale_deps.jl index 38eb1c6a..af1b1075 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, isnothing, 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/src/unbound_args.jl b/src/unbound_args.jl index 35a15601..d7e64625 100644 --- a/src/unbound_args.jl +++ b/src/unbound_args.jl @@ -33,7 +33,7 @@ h(x1::T, x2::T...) = do_something(T[x1, x2...]) ``` """ function test_unbound_args(m::Module; broken::Bool = false) - unbounds = detect_unbound_args_recursively(m) + unbounds = UnboundArgs.detect_unbound_args_recursively(m) if !isempty(unbounds) printstyled( stderr, @@ -51,19 +51,27 @@ function test_unbound_args(m::Module; broken::Bool = false) end end +module UnboundArgs + +using Test + # There used to be a bug in `Test.detect_unbound_args` when used on # a top-level module together with `recursive = true`, see # . This was fixed # some time between 1.4.2 and 1.5.4, but for older versions we # define `detect_unbound_args_recursively` with a workaround. @static if VERSION < v"1.5.4" + using Aqua: walkmodules + function detect_unbound_args_recursively(m) methods = [] walkmodules(m) do x - append!(methods, detect_unbound_args(x)) + append!(methods, Test.detect_unbound_args(x)) end return methods end else detect_unbound_args_recursively(m) = Test.detect_unbound_args(m; recursive = true) end + +end # module diff --git a/src/undefined_exports.jl b/src/undefined_exports.jl new file mode 100644 index 00000000..649785d7 --- /dev/null +++ b/src/undefined_exports.jl @@ -0,0 +1,32 @@ +""" + test_undefined_exports(module::Module) + +Test that all `export`ed names in `module` actually exist. + +# Keyword Arguments +- `broken::Bool = false`: If true, it uses `@test_broken` instead of + `@test`. +""" +function test_undefined_exports(m::Module; broken::Bool = false) + if broken + @test_broken UndefinedExports.undefined_exports(m) == [] + else + @test UndefinedExports.undefined_exports(m) == [] + end +end + +module UndefinedExports + +using ..Aqua: walkmodules + +function undefined_exports(m::Module) + undefined = Symbol[] + walkmodules(m) do x + for n in names(x) + isdefined(x, n) || push!(undefined, n) + end + end + return undefined +end + +end # module diff --git a/src/utils.jl b/src/utils.jl index 0179714e..92bda696 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -2,8 +2,6 @@ if !@isdefined(isnothing) isnothing(x) = x === nothing end -splitlines(str; kwargs...) = readlines(IOBuffer(str); kwargs...) - askwargs(kwargs) = (; kwargs...) function askwargs(flag::Bool) if !flag @@ -12,6 +10,33 @@ function askwargs(flag::Bool) return NamedTuple() end +aspkgids(pkg::Union{Module,PkgId}) = aspkgids([pkg]) +aspkgids(packages) = map(aspkgid, packages) + +aspkgid(pkg::PkgId) = pkg +function aspkgid(m::Module) + if !ispackage(m) + error("Non-package (non-toplevel) module is not supported. Got: $m") + end + return PkgId(m) +end + +ispackage(m::Module) = + if m in (Base, Core) + true + else + parentmodule(m) == m + end + +function reprpkgid(pkg::PkgId) + name = pkg.name + if pkg.uuid === nothing + return "Base.PkgId($(repr(name)))" + end + uuid = pkg.uuid.value + return "Base.PkgId(Base.UUID($(repr(uuid))), $(repr(name)))" +end + struct LazyTestResult label::String message::String @@ -71,6 +96,27 @@ function root_project_or_failed_lazytest(pkg::PkgId) return root_project_path end +function project_toml_path(dir) + candidates = joinpath.(dir, ["Project.toml", "JuliaProject.toml"]) + i = findfirst(isfile, candidates) + i === nothing && return candidates[1], false + return candidates[i], true +end + +function walkmodules(f, x::Module) + f(x) + for n in names(x; all = true) + # `isdefined` and `getproperty` can trigger deprecation warnings + if Base.isbindingresolved(x, n) && !Base.isdeprecated(x, n) + isdefined(x, n) || continue + y = getproperty(x, n) + if y isa Module && y !== x && parentmodule(y) === x + walkmodules(f, y) + end + end + end +end + module _TempModule end @@ -96,25 +142,6 @@ catch end end -const _project_key_order = [ - "name", - "uuid", - "keywords", - "license", - "desc", - "deps", - "weakdeps", - "extensions", - "compat", - "extras", - "targets", -] -project_key_order(key::String) = - something(findfirst(x -> x == key, _project_key_order), length(_project_key_order) + 1) - -print_project(io, dict) = - TOML.print(io, dict, sorted = true, by = key -> (project_key_order(key), key)) - ensure_exception(e::Exception) = e ensure_exception(x) = ErrorException(string(x)) diff --git a/test/test_ambiguities.jl b/test/test_ambiguities.jl index ad2d8557..33a7051c 100644 --- a/test/test_ambiguities.jl +++ b/test/test_ambiguities.jl @@ -2,12 +2,15 @@ module TestAmbiguities include("preamble.jl") +using Aqua: Ambiguities + using PkgWithAmbiguities @testset begin function check_testcase(exclude, num_ambiguities::Int; broken::Bool = false) pkgids = Aqua.aspkgids([PkgWithAmbiguities, Core]) # include Core to find constructor ambiguities - num_ambiguities_, strout, strerr = Aqua._find_ambiguities(pkgids; exclude = exclude) + num_ambiguities_, strout, strerr = + Ambiguities.find_ambiguities(pkgids; exclude = exclude) if broken @test_broken num_ambiguities_ == num_ambiguities else diff --git a/test/test_deps_compat.jl b/test/test_deps_compat.jl index 4e700d93..d8123a07 100644 --- a/test/test_deps_compat.jl +++ b/test/test_deps_compat.jl @@ -1,12 +1,14 @@ module TestDepsCompat include("preamble.jl") -using Aqua: PkgId, UUID, _analyze_deps_compat_2, ⊜ + +using Aqua: ⊜ +using Aqua.DepsCompat: _analyze_deps_compat_2 const DictSA = Dict{String,Any} @testset "_analyze_deps_compat_2" begin - pkg = PkgId(UUID(42), "TargetPkg") + pkg = Base.PkgId(Base.UUID(42), "TargetPkg") root_project_path = "DUMMY_PATH" @testset "pass" begin @test _analyze_deps_compat_2( diff --git a/test/test_exclude.jl b/test/test_exclude.jl index 6eca9659..4f15c2a7 100644 --- a/test/test_exclude.jl +++ b/test/test_exclude.jl @@ -1,8 +1,11 @@ module TestExclude include("preamble.jl") + using Base: PkgId -using Aqua: getobj, normalize_exclude, normalize_and_check_exclude, rootmodule, reprexclude + +using Aqua.Ambiguities: + getobj, normalize_exclude, normalize_and_check_exclude, rootmodule, reprexclude @assert parentmodule(Tuple) === Core @assert parentmodule(foldl) === Base diff --git a/test/test_getobj.jl b/test/test_getobj.jl index 48acc11c..01096c18 100644 --- a/test/test_getobj.jl +++ b/test/test_getobj.jl @@ -1,6 +1,6 @@ module TestGetObj -using Aqua: getobj +using Aqua.Ambiguities: getobj using Test module ModuleA diff --git a/test/test_project_extras.jl b/test/test_project_extras.jl index 7053e415..1c633a7f 100644 --- a/test/test_project_extras.jl +++ b/test/test_project_extras.jl @@ -1,8 +1,9 @@ module TestProjectExtras include("preamble.jl") -using Aqua: is_julia12_or_later, ispass, ⊜ -using Base: PkgId, UUID + +using Aqua: ProjectExtras, ispass, ⊜ +using Aqua.ProjectExtras: is_julia12_or_later @testset "is_julia12_or_later" begin @test is_julia12_or_later("1.2") @@ -17,13 +18,10 @@ end with_sample_pkgs() do - results = Dict( - zip( - [p.name for p in AquaTesting.SAMPLE_PKGIDS], - Aqua.analyze_project_extras(collect(AquaTesting.SAMPLE_PKGIDS)), - ), - ) - pkgids = Dict([p.name => p for p in AquaTesting.SAMPLE_PKGIDS]) + results = Dict([ + p.name => ProjectExtras.analyze_project_extras(p) for p in AquaTesting.SAMPLE_PKGIDS + ]) + pkgids = AquaTesting.SAMPLE_PKG_BY_NAME @testset "PkgWithIncompatibleTestProject" begin r = results["PkgWithIncompatibleTestProject"] diff --git a/test/test_project_toml_formatting.jl b/test/test_project_toml_formatting.jl index 36ce6e81..56576b63 100644 --- a/test/test_project_toml_formatting.jl +++ b/test/test_project_toml_formatting.jl @@ -1,12 +1,13 @@ module TestProjectTomlFormatting -using Aqua: _analyze_project_toml_formatting_2, ⊜ +using Aqua: ⊜ +using Aqua.ProjectTomlFormatting: analyze_project_toml_formatting_2 using Test -@testset "_analyze_project_toml_formatting_2" begin +@testset "analyze_project_toml_formatting_2" begin path = "DUMMY/PATH" @testset "pass" begin - @test _analyze_project_toml_formatting_2( + @test analyze_project_toml_formatting_2( path, """ [deps] @@ -14,7 +15,7 @@ using Test Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" """, ) ⊜ true - @test _analyze_project_toml_formatting_2( + @test analyze_project_toml_formatting_2( path, """ name = "Aqua" @@ -38,7 +39,7 @@ using Test ) ⊜ true end @testset "pass: ignore carriage returns" begin - @test _analyze_project_toml_formatting_2( + @test analyze_project_toml_formatting_2( path, join([ """[deps]\r\n""", @@ -48,7 +49,7 @@ using Test ) ⊜ true end @testset "failure: reversed deps" begin - t = _analyze_project_toml_formatting_2( + t = analyze_project_toml_formatting_2( path, """ [deps] @@ -61,7 +62,7 @@ using Test @test occursin("is not in canonical format", string(t)) end @testset "failure: reversed table" begin - t = _analyze_project_toml_formatting_2( + t = analyze_project_toml_formatting_2( path, """ [compat] 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)