-
Notifications
You must be signed in to change notification settings - Fork 57
Expand file tree
/
Copy pathruntests.jl
More file actions
121 lines (105 loc) · 3.32 KB
/
runtests.jl
File metadata and controls
121 lines (105 loc) · 3.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
using Test
if VERSION >= v"1.2.0-DEV.573"
include("snoopi.jl")
end
if VERSION >= v"1.6.0-DEV.1190" # https://github.com/JuliaLang/julia/pull/37749
@testset "snoopi_deep" begin
include("snoopi_deep.jl")
end
end
if VERSION >= v"1.6.0-DEV.1192" # https://github.com/JuliaLang/julia/pull/37136
@testset "snoopl" begin
include("snoopl.jl")
end
@testset "snoop_all" begin
include("snoop_all.jl")
end
end
using SnoopCompile
@testset "Miscellaneous" begin
# issue #26
logfile = joinpath(tempdir(), "anon.log")
@snoopc logfile begin
map(x->x^2, [1,2,3])
end
data = SnoopCompile.read(logfile)
pc = SnoopCompile.parcel(reverse!(data[2]))
@test length(pc[:Base]) <= 1
# issue #29
keep, pcstring, topmod, name = SnoopCompile.parse_call("Tuple{getfield(JLD, Symbol(\"##s27#8\")), Any, Any, Any, Any, Any}")
@test keep
@test pcstring == "Tuple{getfield(JLD, Symbol(\"##s27#8\")), Int, Int, Int, Int, Int}"
@test topmod == :JLD
@test name == "##s27#8"
logfile = joinpath(tempdir(), "isdefined.log")
@snoopc logfile begin
@eval module IsDef
@generated function tm(x)
return :(typemax($x))
end
end
IsDef.tm(1)
end
data = SnoopCompile.read(logfile)
pc = SnoopCompile.parcel(reverse!(data[2]))
@test any(startswith.(pc[:IsDef], "isdefined"))
if Base.VERSION < v"1.7.0-DEV.694"
@testset "Warning for failures to precompile" begin
pcs = ["@warnpcfail precompile(fsimple, (Char,))",
"@warnpcfail precompile(fsimple, (Char, Char))",
"@warnpcfail precompile(fsimple, (Char, Char, Char))",
]
fn = tempname() * ".jl"
open(fn, "w") do io
println(io, "fsimple(x, y) = 1")
SnoopCompile.write(io, pcs; writewarnpcfail=true)
end
@test_logs (:warn, r"precompile\(fsimple, \(Char,\)\)") (:warn, r"precompile\(fsimple, \(Char, Char, Char\)\)") include(fn)
rm(fn)
end
end
end
#=
# Simple call
let str = "sum"
keep, pcstring, topmod = SnoopCompile.parse_call("Foo.any($str)")
@test keep
@test pcstring == "Tuple{$str}"
@test topmod == :Main
end
# Operator
let str = "Base.:*, Int, Int"
keep, pcstring, topmod = SnoopCompile.parse_call("Foo.any($str)")
@test keep
@test pcstring == "Tuple{$str}"
@test topmod == :Base
end
# Function as argument
let str = "typeof(Base.identity), Array{Bool, 1}"
keep, pcstring, topmod = SnoopCompile.parse_call("Foo.any($str, Vararg{Any, N} where N)")
@test keep
@test pcstring == "Tuple{$str, Int}"
@test topmod == :Base
end
# Anonymous function closure in a new module as argument
let func = (@eval Main module SnoopTestTemp
func = () -> (y = 2; (x -> x > y))
end).func
str = "getfield(SnoopTestTemp, Symbol(\"$(typeof(func()))\")), Array{Float32, 1}"
keep, pcstring, topmod = SnoopCompile.parse_call("Foo.any($str)")
@test keep
@test pcstring == "Tuple{$str}"
@test topmod == :SnoopTestTemp
end
# Function as a type
let str = "typeof(Base.Sort.sort!), Array{Any, 1}, Base.Sort.MergeSortAlg, Base.Order.By{typeof(Base.string)}"
keep, pcstring, topmod = SnoopCompile.parse_call("Foo.Bar.sort!($str)")
@test keep
@test pcstring == "Tuple{$str}"
@test topmod == :Base
end
=#
include("colortypes.jl")
if isdefined(SnoopCompile, :invalidation_trees)
include("snoopr.jl")
end