Skip to content

Commit

Permalink
revert broken commit - add test (#318)
Browse files Browse the repository at this point in the history
Reverts changes in d11c578
  • Loading branch information
t-bltg authored Dec 15, 2022
1 parent d11c578 commit dcae62d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
11 changes: 4 additions & 7 deletions SnoopPrecompile/src/SnoopPrecompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,10 @@ macro precompile_all_calls(ex::Expr)
end
if have_inference_tracking
ex = quote
thunk() = $ex
Core.Compiler.Timings.reset_timings()
Core.Compiler.__set_measure_typeinf(true)
try
Base.invokelatest(thunk)
$ex
finally
Core.Compiler.__set_measure_typeinf(false)
Core.Compiler.Timings.close_current_timer()
Expand All @@ -74,9 +73,7 @@ macro precompile_all_calls(ex::Expr)
end
return esc(quote
if ccall(:jl_generating_output, Cint, ()) == 1 || $SnoopPrecompile.verbose[]
let
$ex
end
$ex
end
end)
end
Expand Down Expand Up @@ -105,11 +102,11 @@ to your package).
"""
macro precompile_setup(ex::Expr)
return esc(quote
let
# let
if ccall(:jl_generating_output, Cint, ()) == 1 || $SnoopPrecompile.verbose[]
$ex
end
end
# end
end)
end

Expand Down
7 changes: 7 additions & 0 deletions SnoopPrecompile/test/SnoopPC_C/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "SnoopPC_C"
uuid = "e6c49816-f2a1-47f5-8743-1735c486fd91"
authors = ["Tim Holy <[email protected]>"]
version = "0.1.0"

[deps]
SnoopPrecompile = "66db9d55-30c0-4569-8b51-7e840670fc0c"
32 changes: 32 additions & 0 deletions SnoopPrecompile/test/SnoopPC_C/src/SnoopPC_C.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
module SnoopPC_C

using SnoopPrecompile

# mimic `RecipesBase` code - see github.com/JuliaPlots/Plots.jl/issues/4597 and #317
module RB
export @recipe

apply_recipe(args...) = nothing
macro recipe(ex::Expr)
_, func_body = ex.args
func = Expr(:call, :($RB.apply_recipe))
Expr(
:function,
func,
quote
@nospecialize
func_return = $func_body
end |> esc
)
end
end
using .RB

@precompile_setup begin
struct Foo end
@precompile_all_calls begin
@recipe f(::Foo) = nothing
end
end

end # module SnoopPC_C
4 changes: 4 additions & 0 deletions SnoopPrecompile/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,8 @@ using UUIDs
str = read(pipe.out, String)
@test occursin(r"UndefVarError: `?missing_function`? not defined", str)
end

if Base.VERSION >= v"1.6"
using SnoopPC_C
end
end

0 comments on commit dcae62d

Please sign in to comment.