Skip to content

Commit

Permalink
Rename test_piracy to test_piracies (#230)
Browse files Browse the repository at this point in the history
Co-authored-by: Lars Göttgens <lars.goettgens@gmail.com>
  • Loading branch information
hyrodium and lgoettgens authored Oct 31, 2023
1 parent 8348f74 commit de25cfa
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,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_piracy` is renamed to `test_piracies`. ([#230](https://github.com/JuliaTesting/Aqua.jl/pull/230)) [BREAKING]

### Removed

Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ using Aqua
project_extras=true,
stale_deps=(ignore=[:SomePackage],),
deps_compat=(ignore=[:SomeOtherPackage],),
piracy=false,
piracies=false,
)
end
```
Expand Down
12 changes: 6 additions & 6 deletions src/Aqua.jl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ include("exports.jl")
include("project_extras.jl")
include("stale_deps.jl")
include("deps_compat.jl")
include("piracy.jl")
include("piracies.jl")
include("persistent_tasks.jl")

"""
Expand All @@ -33,7 +33,7 @@ Run following tests in isolated testset:
* [`test_project_extras(testtarget)`](@ref test_project_extras)
* [`test_stale_deps(testtarget)`](@ref test_stale_deps)
* [`test_deps_compat(testtarget)`](@ref test_deps_compat)
* [`test_piracy(testtarget)`](@ref test_piracy)
* [`test_piracies(testtarget)`](@ref test_piracies)
* [`test_persistent_tasks(testtarget)`](@ref test_persistent_tasks)
The keyword argument `\$x` (e.g., `ambiguities`) can be used to
Expand All @@ -48,7 +48,7 @@ passed to `\$x` to specify the keyword arguments for `test_\$x`.
- `project_extras = true`
- `stale_deps = true`
- `deps_compat = true`
- `piracy = true`
- `piracies = true`
- `persistent_tasks = true`
"""
function test_all(
Expand All @@ -59,7 +59,7 @@ function test_all(
project_extras = true,
stale_deps = true,
deps_compat = true,
piracy = true,
piracies = true,
persistent_tasks = true,
)
@testset "Method ambiguity" begin
Expand Down Expand Up @@ -93,8 +93,8 @@ function test_all(
end
end
@testset "Piracy" begin
if piracy !== false
test_piracy(testtarget; askwargs(piracy)...)
if piracies !== false
test_piracies(testtarget; askwargs(piracies)...)
end
end
@testset "Persistent tasks" begin
Expand Down
17 changes: 8 additions & 9 deletions src/piracy.jl → src/piracies.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ is_foreign(@nospecialize(x), pkg::Base.PkgId; treat_as_own) =
#
# as a type piracy even if this is actually the intended use-case (which is not
# a crazy API). The symbol name may also come from `gensym`. Since the aim of
# `Aqua.test_piracy` is to detect only "obvious" piracy, let us play on the
# `Aqua.test_piracies` is to detect only "obvious" piracies, let us play on the
# safe side.
is_foreign(x::Symbol, pkg::Base.PkgId; treat_as_own) = false

Expand All @@ -111,8 +111,8 @@ function is_foreign(@nospecialize(T::DataType), pkg::Base.PkgId; treat_as_own)
end

function is_foreign(@nospecialize(U::UnionAll), pkg::Base.PkgId; treat_as_own)
# We do not consider extending Set{T} to be piracy, if T is not foreign.
# Extending it goes against Julia style, but it's not piracy IIUC.
# We do not consider extending Set{T} to be piracies, if T is not foreign.
# Extending it goes against Julia style, but it's not piracies IIUC.
is_foreign(U.body, pkg; treat_as_own = treat_as_own) &&
is_foreign(U.var, pkg; treat_as_own = treat_as_own)
end
Expand All @@ -127,8 +127,7 @@ is_foreign(@nospecialize(T::TypeVar), pkg::Base.PkgId; treat_as_own) =
end

function is_foreign(@nospecialize(U::Union), pkg::Base.PkgId; treat_as_own)
# Even if Foo is local, overloading f(::Union{Foo, Int}) with foreign f
# is piracy.
# Even if Foo is local, overloading f(::Union{Foo, Int}) with foreign f is piracy.
any(T -> is_foreign(T, pkg; treat_as_own = treat_as_own), Base.uniontypes(U))
end

Expand Down Expand Up @@ -199,9 +198,9 @@ end
end # module

"""
test_piracy(m::Module)
test_piracies(m::Module)
Test that `m` does not commit type piracy.
Test that `m` does not commit type piracies.
See [Julia documentation](https://docs.julialang.org/en/v1/manual/style-guide/#Avoid-type-piracy) for more information about type piracy.
# Keyword Arguments
Expand All @@ -210,11 +209,11 @@ See [Julia documentation](https://docs.julialang.org/en/v1/manual/style-guide/#A
- `skip_deprecated::Bool = true`: If true, it does not check deprecated methods.
- `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
testing packages that deliberately commit some type piracies, 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...)
function test_piracies(m::Module; broken::Bool = false, kwargs...)
v = Piracy.hunt(m; kwargs...)
if !isempty(v)
printstyled(
Expand Down
2 changes: 1 addition & 1 deletion test/test_smoke.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Aqua.test_all(
project_extras = false,
stale_deps = false,
deps_compat = false,
piracy = false,
piracies = false,
persistent_tasks = false,
)

Expand Down

0 comments on commit de25cfa

Please sign in to comment.