Skip to content

Commit

Permalink
Use Base.depwarn() exclusively, and fix deprecation tests (#4333)
Browse files Browse the repository at this point in the history
* Use `Base.depwarn()` exclusively, and fix deprecation tests

A few changes:
- Use `Base.depwarn()` instead of `Base.@deprecate_binding` to avoid warnings
  when importing symbols.
- Pass the missing `funcsym` argument to `Base.depwarn()` in `Combined()`.
- Fix the deprecation tests. Most of them were actually getting skipped because
  `@depwarn_message` had a `return` statement, causing the entire testset to
  return early as soon as the passed expression was evaluated.

* fixup! Use `Base.depwarn()` exclusively, and fix deprecation tests
  • Loading branch information
JamesWrigley authored Sep 18, 2024
1 parent 65a7181 commit b971fbb
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
18 changes: 13 additions & 5 deletions src/deprecated.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
###########################################
# v0.20 deprecations:
##
Base.@deprecate_binding DiscreteSurface CellGrid true
Base.@deprecate_binding ContinuousSurface VertexGrid true

function DiscreteSurface(args...; kwargs...)
@warn "Makie.DiscreteSurface() is deprecated, use Makie.CellGrid() instead" maxlog=1
CellGrid(args...; kwargs...)
end

function ContinuousSurface(args...; kwargs...)
@warn "Makie.ContinuousSurface() is deprecated, use Makie.VertexGrid() instead" maxlog=1
VertexGrid(args...; kwargs...)
end

function Base.getproperty(scene::Scene, field::Symbol)
if field === :px_area
Expand All @@ -14,7 +22,7 @@ end

@deprecate pixelarea viewport true

function Combined(args...)
Base.depwarn("Makie.Combined(args...) is deprecated, use Makie.Plot(args...) instead")
Plot(args...)
function Combined(args...; kwargs...)
@warn "Makie.Combined() is deprecated, use Makie.Plot() instead" maxlog=1
Plot(args...; kwargs...)
end
19 changes: 8 additions & 11 deletions test/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ macro depwarn_message(expr)
$(esc(expr))
end
if length(logger.logs) == 1
return logger.logs[1].message
logger.logs[1].message
else
return nothing
nothing
end
end
end
Expand All @@ -34,17 +34,14 @@ end
end
@testset "Plot -> Combined" begin
logger = Test.TestLogger()
msg = @depwarn_message Combined
@test occursin("Combined is deprecated", msg)
@test Combined == Plot
msg = @depwarn_message Makie.Combined()
@test occursin("Combined() is deprecated", msg)
end
@testset "Surface Traits" begin
@test DiscreteSurface == CellGrid
@test ContinuousSurface == VertexGrid
msg = @depwarn_message DiscreteSurface()
@test occursin("DiscreteSurface is deprecated", msg)
msg = @depwarn_message ContinuousSurface()
@test occursin("ContinuousSurface is deprecated", msg)
msg = @depwarn_message Makie.DiscreteSurface()
@test occursin("DiscreteSurface() is deprecated", msg)
msg = @depwarn_message Makie.ContinuousSurface()
@test occursin("ContinuousSurface() is deprecated", msg)
end
@testset "AbstractVector ImageLike" begin
msg = @depwarn_message image(1:10, 1..10, zeros(10, 10))
Expand Down

0 comments on commit b971fbb

Please sign in to comment.