Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
t-bltg committed Jan 8, 2023
1 parent 5af4cf2 commit f3089e4
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
7 changes: 7 additions & 0 deletions SnoopPrecompile/test/SnoopPC_D/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name = "SnoopPC_D"
uuid = "8c347477-c4a5-4b7f-b911-c68b2b9ed891"
authors = ["Tim Holy <tim.holy@gmail.com>"]
version = "0.1.0"

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

using SnoopPrecompile

@precompile_setup begin
@precompile_all_calls begin
global workload_ran = true
end
end

end # module SnoopPC_D
20 changes: 17 additions & 3 deletions SnoopPrecompile/test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using UUIDs
push!(LOAD_PATH, @__DIR__)

using SnoopPC_A
if Base.VERSION >= v"1.8.0-rc1"
if VERSION >= v"1.8.0-rc1"
# Check that calls inside :setup are not precompiled
m = which(Tuple{typeof(Base.vect), Vararg{T}} where T)
have_mytype = false
Expand Down Expand Up @@ -39,7 +39,7 @@ using UUIDs
@test count == 1
end

if Base.VERSION >= v"1.7" # so we can use redirect_stderr(f, ::Pipe)
if VERSION >= v"1.7" # so we can use redirect_stderr(f, ::Pipe)
pipe = Pipe()
id = Base.PkgId(UUID("d38b61e7-59a2-4ef9-b4d3-320bdc69b817"), "SnoopPC_B")
redirect_stderr(pipe) do
Expand All @@ -50,7 +50,21 @@ using UUIDs
@test occursin(r"UndefVarError: `?missing_function`? not defined", str)
end

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

if VERSION >= v"1.6"
script = """
push!(LOAD_PATH, @__DIR__)
using SnoopPC_D
exit(isdefined(SnoopPC_D, :workload_ran) === parse(Bool, ARGS[1]) ? 0 : 1)
"""

SnoopPrecompile.Preferences.set_preferences!(SnoopPrecompile, "skip_precompile" => ["SnoopPC_D"])
@test success(run(`$(Base.julia_cmd()) --project=$(Base.active_project()) -e $script 0`))

SnoopPrecompile.Preferences.delete_preferences!(SnoopPrecompile, "skip_precompile"; force = true)
@test success(run(`$(Base.julia_cmd()) --project=$(Base.active_project()) -e $script 1`))
end
end

0 comments on commit f3089e4

Please sign in to comment.