diff --git a/CHANGELOG.md b/CHANGELOG.md index f7df6b41..76ed4b52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `test_ambiguities` now excludes the keyword sorter of all `exclude`d functions with keyword arguments as well. ([#203](https://github.com/JuliaTesting/Aqua.jl/pull/204)) - In `test_deps_compat`, the two subtests `check_extras` and `check_weakdeps` are now run by default. ([#202](https://github.com/JuliaTesting/Aqua.jl/pull/202)) [BREAKING] - `test_deps_compat` now reqiures compat entries for all dependencies. Stdlibs no longer get ignored. This change is motivated by similar changes in the General registry. ([#215](https://github.com/JuliaTesting/Aqua.jl/pull/215)) [BREAKING] +- `test_deps_compat` now requires a compat entry for `julia` This can be disabling by setting `compat_julia = false`. ([#236](https://github.com/JuliaTesting/Aqua.jl/pull/236)) [BREAKING] - `test_piracy` is renamed to `test_piracies`. ([#230](https://github.com/JuliaTesting/Aqua.jl/pull/230)) [BREAKING] - `test_ambiguities` and `test_piracies` now return issues in a defined order. This order may change in a patch release of Aqua.jl. ([#233](https://github.com/JuliaTesting/Aqua.jl/pull/233)) - Improved the message for `test_project_extras` failures. ([#233](https://github.com/JuliaTesting/Aqua.jl/pull/233)) diff --git a/src/deps_compat.jl b/src/deps_compat.jl index 8cbebc18..acb4f3d9 100644 --- a/src/deps_compat.jl +++ b/src/deps_compat.jl @@ -2,7 +2,7 @@ Aqua.test_deps_compat(package) Test that the `Project.toml` of `package` has a `compat` entry for -each package listed under `deps`. +each package listed under `deps` and for `julia`. # Arguments - `packages`: a top-level `Module`, a `Base.PkgId`, or a collection of @@ -10,6 +10,7 @@ each package listed under `deps`. # Keyword Arguments ## Test choosers +- `check_julia = true`: If true, additionally check for a compat entry for "julia". - `check_extras = true`: If true, additionally check "extras". A NamedTuple can be used to pass keyword arguments with test options (see below). - `check_weakdeps = true`: If true, additionally check "weakdeps". A NamedTuple @@ -23,18 +24,29 @@ to the corresponding `check_\$x` keyword argument. `@test` for "deps". - `ignore::Vector{Symbol}`: names of dependent packages to be ignored. """ -function test_deps_compat(pkg::PkgId; check_extras = true, check_weakdeps = true, kwargs...) +function test_deps_compat( + pkg::PkgId; + check_julia = true, + check_extras = true, + check_weakdeps = true, + kwargs..., +) + if check_julia !== false + @testset "julia" begin + test_julia_compat(pkg; askwargs(check_julia)...) + end + end @testset "$pkg deps" begin test_deps_compat(pkg, "deps"; kwargs...) end if check_extras !== false @testset "$pkg extras" begin - result = test_deps_compat(pkg, "extras"; askwargs(check_extras)...) + test_deps_compat(pkg, "extras"; askwargs(check_extras)...) end end if check_weakdeps !== false @testset "$pkg weakdeps" begin - result = test_deps_compat(pkg, "weakdeps"; askwargs(check_weakdeps)...) + test_deps_compat(pkg, "weakdeps"; askwargs(check_weakdeps)...) end end end @@ -59,6 +71,26 @@ function test_deps_compat(mod::Module; kwargs...) test_deps_compat(aspkgid(mod); kwargs...) end +function test_julia_compat(pkg::PkgId; broken::Bool = false, kwargs...) + if broken + @test_broken has_julia_compat(pkg; kwargs...) + else + @test has_julia_compat(pkg; kwargs...) + end +end + +function has_julia_compat(pkg::PkgId) + result = root_project_or_failed_lazytest(pkg) + result isa LazyTestResult && error("Unable to locate Project.toml") + root_project_path = result + prj = TOML.parsefile(root_project_path) + return has_julia_compat(prj) +end + +function has_julia_compat(prj::Dict{String,Any}) + return "julia" in keys(get(prj, "compat", Dict{String,Any}())) +end + function find_missing_deps_compat(pkg::PkgId, deps_type::String = "deps"; kwargs...) result = root_project_or_failed_lazytest(pkg) result isa LazyTestResult && error("Unable to locate Project.toml") diff --git a/test/test_deps_compat.jl b/test/test_deps_compat.jl index acb8558c..e62df2e0 100644 --- a/test/test_deps_compat.jl +++ b/test/test_deps_compat.jl @@ -1,10 +1,32 @@ module TestDepsCompat include("preamble.jl") -using Aqua: find_missing_deps_compat +using Aqua: find_missing_deps_compat, has_julia_compat const DictSA = Dict{String,Any} +@testset "has_julia_compat" begin + @test has_julia_compat(DictSA("compat" => DictSA("julia" => "1"))) + @test has_julia_compat(DictSA("compat" => DictSA("julia" => "1.0"))) + @test has_julia_compat(DictSA("compat" => DictSA("julia" => "1.6"))) + @test has_julia_compat( + DictSA( + "deps" => DictSA("PkgA" => "229717a1-0d13-4dfb-ba8f-049672e31205"), + "compat" => DictSA("julia" => "1", "PkgA" => "1.0"), + ), + ) + + @test !has_julia_compat(DictSA()) + @test !has_julia_compat(DictSA("compat" => DictSA())) + @test !has_julia_compat(DictSA("compat" => DictSA("PkgA" => "1.0"))) + @test !has_julia_compat( + DictSA( + "deps" => DictSA("PkgA" => "229717a1-0d13-4dfb-ba8f-049672e31205"), + "compat" => DictSA("PkgA" => "1.0"), + ), + ) +end + @testset "find_missing_deps_compat" begin @testset "pass" begin result = find_missing_deps_compat( @@ -12,6 +34,7 @@ const DictSA = Dict{String,Any} "deps", ) @test isempty(result) + result = find_missing_deps_compat( DictSA( "deps" => DictSA("PkgA" => "229717a1-0d13-4dfb-ba8f-049672e31205"),