Skip to content

Commit

Permalink
Merge pull request #48 from timholy/teh/fix0.7
Browse files Browse the repository at this point in the history
Fix Revise on 0.7
  • Loading branch information
timholy authored Sep 28, 2017
2 parents cf06d0d + 78f3920 commit 7039126
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
17 changes: 14 additions & 3 deletions src/Revise.jl
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function parse_pkg_files(modsym::Symbol)
# We got it from the precompile cache
length(paths) > 1 && error("Multiple paths detected: ", paths)
_, files_mtimes = Base.cache_dependencies(paths[1])
files = map(first, files_mtimes) # idx 1 is the filename, idx 2 is the mtime
files = map(ft->normpath(first(ft)), files_mtimes) # idx 1 is the filename, idx 2 is the mtime
mainfile = first(files)
# We still have to parse the source code, and if there are
# multiple modules then we don't know which module to `eval`
Expand All @@ -305,9 +305,9 @@ function parse_pkg_files(modsym::Symbol)
mainfile = Base.find_source_file(string(modsym))
empty!(new_files)
parse_source(mainfile, Main, dirname(mainfile))
files = new_files
files = map(normpath, new_files)
end
module2files[modsym] = copy(files)
module2files[modsym] = files
files
end

Expand Down Expand Up @@ -517,11 +517,17 @@ module is "parented" by `mod`. Source-code expressions are added to
`md` under the appropriate module name.
"""
function parse_module!(md::ModDict, ex::Expr, file::Symbol, mod::Module, path)
mod = moduleswap(mod)
newmod = getfield(mod, _module_name(ex))
md[newmod] = OrderedSet{RelocatableExpr}()
parse_source!(md, ex.args[3], file, newmod, path) # recurse into the body of the module
newmod
end
if VERSION >= v"0.7.0-DEV.1877"
moduleswap(mod) = mod == Base.__toplevel__ ? Main : mod
else
moduleswap(mod) = mod
end

function watch_files_via_dir(dirname)
watch_file(dirname) # this will block until there is a modification
Expand All @@ -544,6 +550,11 @@ function watch_package(modsym::Symbol)
end
return nothing
end
@schedule watch_package_impl(modsym)
nothing
end

function watch_package_impl(modsym)
files = parse_pkg_files(modsym)
process_parsed_files(files)
end
Expand Down
1 change: 1 addition & 0 deletions test/REQUIRE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
Example
Compat 0.30
13 changes: 8 additions & 5 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using Revise
using Base.Test
using DataStructures: OrderedSet
using Compat

to_remove = String[]

Expand Down Expand Up @@ -49,7 +50,7 @@ k(x) = 4
@test convert(Revise.RelocatableExpr, :(g(x) = 2)) md[Main]
end
end
@test contains(readstring(warnfile), "parsing error near line 3")
@test contains(read(warnfile, String), "parsing error near line 3")
rm(warnfile)
end

Expand Down Expand Up @@ -388,7 +389,7 @@ end
yry()
@test ModDocstring.f() == 3
ds = @doc ModDocstring
@test ds.content[2].content[1].content[1] == "Hello! "
@test ds.content[end].content[1].content[1] == "Hello! "

pop!(LOAD_PATH)
end
Expand Down Expand Up @@ -434,7 +435,7 @@ foo(y::Int) = y-51
lines = Int[]
files = String[]
for m in methods(LineNumberMod.foo)
push!(files, m.file)
push!(files, String(m.file))
push!(lines, m.line)
end
@test all(f->endswith(string(f), "incl.jl"), files)
Expand Down Expand Up @@ -484,7 +485,7 @@ foo(y::Int) = y-51
Revise.silence("GSL")
@test isfile(sfiletemp)
pkgs = readlines(sfiletemp)
@test contains(==, pkgs, "GSL")
@test any(p->p=="GSL", pkgs)
rm(sfiletemp)
finally
Revise.silencefile[] = sfile
Expand Down Expand Up @@ -528,7 +529,9 @@ revise_f(x) = 2
yry()
end
end
@test contains(readstring(warnfile), "is not an existing directory")
if !is_apple()
@test contains(read(warnfile, String), "is not an existing directory")
end
rm(warnfile)
end
end

0 comments on commit 7039126

Please sign in to comment.