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

lazy Traceur loading #309

Merged
merged 2 commits into from
Apr 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ Profile = "9abbd945-dff8-562f-b5e8-e1ebf5ef1b79"
REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
Sockets = "6462fe0b-24de-5631-8697-dd941f90decc"
Traceur = "37b6cedf-1f77-55f8-9503-c64b63398394"
TreeViews = "a2a6695c-b41b-5b7d-aed9-dbfdeacea5d7"
WebIO = "0f1e0344-ec1d-5b48-a673-e5cf874b6c29"
WebSockets = "104b5d7c-a370-577a-8038-80a2059c5097"
Expand Down Expand Up @@ -60,6 +59,7 @@ julia = "0.7, 1"
[extras]
Example = "7876af07-990d-54b4-ab0e-23690620f79a"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Traceur = "37b6cedf-1f77-55f8-9503-c64b63398394"

[targets]
test = ["Example", "Test"]
9 changes: 3 additions & 6 deletions src/Atom.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ __precompile__()
module Atom

using Base.StackTraces, InteractiveUtils, Logging
using Juno, Lazy, JSON, MacroTools, Media
import Requires
using Juno, Lazy, JSON, MacroTools, Media, Requires
import Media: @dynamic

function __init__()
Expand Down Expand Up @@ -38,9 +37,8 @@ function __init__()
nothing
end

Requires.@require WebIO="0f1e0344-ec1d-5b48-a673-e5cf874b6c29" begin
include("display/webio.jl")
end
@require WebIO="0f1e0344-ec1d-5b48-a673-e5cf874b6c29" include("display/webio.jl")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why webio.jl is better to be loaded by @require. Maybe because building WebIO sometimes fails ?

@require Traceur="37b6cedf-1f77-55f8-9503-c64b63398394" include("profiler/traceur.jl")
end

# basics
Expand All @@ -64,7 +62,6 @@ include("formatter.jl")
include("frontend.jl")
include("debugger/debugger.jl")
include("profiler/profiler.jl")
include("profiler/traceur.jl")

include("precompile.jl")
_precompile_()
Expand Down
2 changes: 1 addition & 1 deletion src/profiler/traceur.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Traceur
import .Traceur

function trace(ex, args...)
:($(showtrace)($(gettrace)(() -> $(esc(ex)); $(map(esc, args)...))))
Expand Down
30 changes: 17 additions & 13 deletions test/modules.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,17 @@
if use_compiled_modules()
# works for precompiled packages
let (parentfile, included_files) = modulefiles(Atom)
expected = Set(atommodfiles)
actual = Set((parentfile, included_files...))
@test actual == expected
for f in included_files
@test f in atommodfiles
end
# NOTE: `+ 1` stands for Atom.jl (`parentfile`)
@test length(included_files) + 1 === length(atommodfiles)

# can't detect display/webio.jl
@test_broken webiofile in modfiles
# TODO:
# Revise-like module traverse fails to detect lazily loaded files even if
# they are actually loaded.
@test_broken webiofile in included_files
@test_broken traceurfile in included_files
end

# fails for non-precompiled packages
Expand All @@ -41,17 +46,16 @@
## CSTPraser-based module file detection
# basic
let included_files = normpath.(modulefiles("Atom", atomjlfile))
# finds all the files in Atom module except display/webio.jl
for f in atommodfiles
f == webiofile && continue
@test f in included_files
for f in included_files
@test f in atommodfiles
end
@test length(included_files) === length(atommodfiles)

# only finds files in a module -- exclude files in the submodules
@test length(atommodfiles) == length(included_files)

# can't look for non-toplevel `include` calls
# TODO:
# CSTParser-based module traverse is currently not able to find non-toplevel
# `include` calls
@test_broken webiofile in included_files
@test_broken traceurfile in included_files
end

# safety checks for recursive `include`s
Expand Down
11 changes: 6 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@ atomjldir = joinpath′(@__DIR__, "..")
atomsrcdir = joinpath′(atomjldir, "src")
atomjlfile = joinpath′(atomsrcdir, "Atom.jl")
webiofile = joinpath′(atomsrcdir, "display", "webio.jl")
traceurfile = joinpath′(atomsrcdir, "profiler", "traceur.jl")

# files in `Atom` module (except files in its submodules)
# files in `Atom` module except files in submodules
# TODO:
# currently both Revise-like and CSTPraser-based module traverse fails
# to detect lazily loaded files even if they are actually loaded.
atommodfiles = let
files = []
debuggerdir = joinpath′(atomsrcdir, "debugger")
Expand All @@ -23,15 +27,12 @@ atommodfiles = let
end
if d == profilerdir
push!(files, joinpath′(d, "profiler.jl"))
push!(files, joinpath′(d, "traceur.jl"))
# push!(files, joinpath′(d, "traceur.jl"))
continue
end

for f in fs
# NOTE: currently both Revise-like and CSTPraser-based approach fails
# to detect display/webio.jl as a file in Atom module
f == "webio.jl" && continue

# .jl check is needed for travis, who creates hoge.cov files
endswith(f, ".jl") && push!(files, joinpath′(d, f))
end
Expand Down