Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Require [compat] entry for julia #236

Merged
merged 3 commits into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
40 changes: 36 additions & 4 deletions src/deps_compat.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@
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
them.

# 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
Expand All @@ -23,18 +24,29 @@
`@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
lgoettgens marked this conversation as resolved.
Show resolved Hide resolved
@testset "julia" begin

Check warning on line 35 in src/deps_compat.jl

View check run for this annotation

Codecov / codecov/patch

src/deps_compat.jl#L35

Added line #L35 was not covered by tests
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
Expand All @@ -59,6 +71,26 @@
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...)

Check warning on line 76 in src/deps_compat.jl

View check run for this annotation

Codecov / codecov/patch

src/deps_compat.jl#L76

Added line #L76 was not covered by tests
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")
Expand Down
25 changes: 24 additions & 1 deletion test/test_deps_compat.jl
Original file line number Diff line number Diff line change
@@ -1,17 +1,40 @@
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(
DictSA("deps" => DictSA(), "compat" => DictSA("julia" => "1")),
"deps",
)
@test isempty(result)

result = find_missing_deps_compat(
DictSA(
"deps" => DictSA("PkgA" => "229717a1-0d13-4dfb-ba8f-049672e31205"),
Expand Down
Loading