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

Use ScopedValue to fix async issue #112

Merged
merged 10 commits into from
Jul 13, 2024
Prev Previous commit
Use VERSION check instead
  • Loading branch information
omus committed Jul 13, 2024
commit 372e44b751aa3c241fef81f4e15658fe01ec547d
2 changes: 1 addition & 1 deletion src/Mocking.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using ExprTools: splitdef, combinedef
# Available in Julia 1.11+: https://github.com/JuliaLang/julia/pull/50958
# We cannot use ScopedValues.jl for backwards compatability as that implementation breaks
# `@test_logs`.
if isdefined(Base, :ScopedValue)
if VERSION >= v"1.11.0-DEV.482"
using Base: ScopedValue, with
end

Expand Down
3 changes: 2 additions & 1 deletion src/patch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ function apply(body::Function, patches; debug::Bool=false)
return apply(body, PatchEnv(patches, debug))
end

if isdefined(@__MODULE__, :ScopedValue)
# https://github.com/JuliaLang/julia/pull/50958
if VERSION >= v"1.11.0-DEV.482"
const PATCH_ENV = ScopedValue(PatchEnv())
with_active_env(body::Function, pe::PatchEnv) = with(body, PATCH_ENV => pe)
else
Expand Down
Loading