-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from timholy/teh/fix_20
Parse `where` signatures (fixes #20)
- Loading branch information
Showing
2 changed files
with
38 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,41 @@ | ||
using SnoopCompile, Test, Pkg | ||
|
||
mktempdir() do tmpdir | ||
tmpfile = joinpath(tmpdir, "colortypes_compiles.csv") | ||
tmpdir2 = joinpath(tmpdir, "precompile") | ||
tmpfile2 = joinpath(tmpdir, "userimg_ColorTypes.jl") | ||
@testset "ColorTypes" begin | ||
success, line, modsym = SnoopCompile.parse_call("Tuple{typeof(ColorTypes.to_top), Type{C}} where C<:(ColorTypes.Colorant{T, N} where N where T)") | ||
@test success | ||
@test modsym == :ColorTypes | ||
|
||
### Log the compiles (in a separate process) | ||
SnoopCompile.@snoop tmpfile begin | ||
using ColorTypes, Pkg | ||
include(joinpath(dirname(dirname(pathof(ColorTypes))), "test", "runtests.jl")) | ||
end | ||
mktempdir() do tmpdir | ||
tmpfile = joinpath(tmpdir, "colortypes_compiles.csv") | ||
tmpdir2 = joinpath(tmpdir, "precompile") | ||
tmpfile2 = joinpath(tmpdir, "userimg_ColorTypes.jl") | ||
|
||
### Parse the compiles and generate precompilation scripts | ||
let data = SnoopCompile.read(tmpfile) | ||
# Use these two lines if you want to create precompile functions for | ||
# individual packages | ||
pc = SnoopCompile.parcel(reverse!(data[2])) | ||
SnoopCompile.write(tmpdir2, pc) | ||
### Log the compiles (in a separate process) | ||
SnoopCompile.@snoop tmpfile begin | ||
using ColorTypes, Pkg | ||
include(joinpath(dirname(dirname(pathof(ColorTypes))), "test", "runtests.jl")) | ||
end | ||
|
||
# Use these two lines if you want to add to your userimg.jl | ||
pc = SnoopCompile.format_userimg(reverse!(data[2])) | ||
SnoopCompile.write(tmpfile2, pc) | ||
end | ||
### Parse the compiles and generate precompilation scripts | ||
let data = SnoopCompile.read(tmpfile) | ||
# Use these two lines if you want to create precompile functions for | ||
# individual packages | ||
pc = SnoopCompile.parcel(reverse!(data[2])) | ||
SnoopCompile.write(tmpdir2, pc) | ||
|
||
function notisempty(filename, minlength) | ||
@test isfile(filename) | ||
@test length(readlines(filename)) >= minlength | ||
nothing | ||
end | ||
# Use these two lines if you want to add to your userimg.jl | ||
pc = SnoopCompile.format_userimg(reverse!(data[2])) | ||
SnoopCompile.write(tmpfile2, pc) | ||
end | ||
|
||
notisempty(joinpath(tmpdir2, "precompile_ColorTypes.jl"), 100) | ||
notisempty(joinpath(tmpdir2, "precompile_FixedPointNumbers.jl"), 2) | ||
notisempty(tmpfile2, 100) | ||
function notisempty(filename, minlength) | ||
@test isfile(filename) | ||
@test length(readlines(filename)) >= minlength | ||
nothing | ||
end | ||
|
||
notisempty(joinpath(tmpdir2, "precompile_ColorTypes.jl"), 100) | ||
notisempty(joinpath(tmpdir2, "precompile_FixedPointNumbers.jl"), 2) | ||
notisempty(tmpfile2, 100) | ||
end | ||
end |