diff --git a/src/unbound_args.jl b/src/unbound_args.jl index a6413f5e..5338246a 100644 --- a/src/unbound_args.jl +++ b/src/unbound_args.jl @@ -9,9 +9,17 @@ of the method. # Keyword Arguments - `broken::Bool = false`: If true, it uses `@test_broken` instead of `@test` and shortens the error message. +- `exclude::AbstractVector = []`: A vector of signatures of methods to exclude + from testing. A signature is usually of the form `Tuple{typeof(f), T1, T2, ...}`. + where `f` is the function and `T1, T2, ...` the type parameters. For example, the + signature of `f(x::Float64, y)` is `Tuple{typeof(f), Float64, Any}`. """ -function test_unbound_args(m::Module; broken::Bool = false) +function test_unbound_args(m::Module; broken::Bool = false, exclude = []) unbounds = detect_unbound_args_recursively(m) + for signature in exclude + filter!(method -> (method.sig != signature), unbounds) + end + if broken if !isempty(unbounds) printstyled( diff --git a/test/pkgs/PkgUnboundArgs.jl b/test/pkgs/PkgUnboundArgs.jl index 4eb5e27b..8b3972f5 100644 --- a/test/pkgs/PkgUnboundArgs.jl +++ b/test/pkgs/PkgUnboundArgs.jl @@ -7,4 +7,18 @@ end # `_totuple` is taken from # https://github.com/JuliaLang/julia/blob/48634f9f8669e1dc1be0a1589cd5be880c04055a/test/ambiguous.jl#L257-L259 +# taken from https://github.com/JuliaTesting/Aqua.jl/issues/86 +module Issue86 +f(::NTuple{N,T}) where {N,T} = (N, T) +f(::Tuple{}) = (0, Any) +end + +module ExcludeCallableObject +struct Callable{U} + s::U +end + +(::Callable{U})(::NTuple{N,T}) where {N,T,U} = (N, T, U) +(::Callable{U})(::Tuple{}) where {U} = (0, Any, U) +end end # module diff --git a/test/test_unbound_args.jl b/test/test_unbound_args.jl index 97206032..84557ff2 100644 --- a/test/test_unbound_args.jl +++ b/test/test_unbound_args.jl @@ -13,6 +13,20 @@ using PkgUnboundArgs @test length(results) == 1 @test results[1] isa Test.Fail + Aqua.test_unbound_args( + PkgUnboundArgs, + exclude = [ + Tuple{ + typeof(PkgUnboundArgs.M25341._totuple), + Type{Tuple{Vararg{E}}} where E, + Any, + Vararg{Any}, + }, + Tuple{typeof(PkgUnboundArgs.Issue86.f),NTuple}, + Tuple{PkgUnboundArgs.ExcludeCallableObject.Callable,NTuple}, + ], + ) + # It works with other tests: Aqua.test_ambiguities(PkgUnboundArgs) Aqua.test_undefined_exports(PkgUnboundArgs)