-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tracking non-.jl source files (#680)
Co-authored-by: Tim Holy <tim.holy@gmail.com> Co-authored-by: Sebastian Pfitzner <pfitzseb@gmail.com> Co-authored-by: Keno Fischer <keno@juliacomputing.com>
- Loading branch information
1 parent
fe8d3b4
commit 2de4173
Showing
9 changed files
with
90 additions
and
14 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
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
2=x |
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
1=x | ||
2=y |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
struct MyFile | ||
file::String | ||
end | ||
Base.abspath(file::MyFile) = MyFile(Base.abspath(file.file)) | ||
Base.isabspath(file::MyFile) = Base.isabspath(file.file) | ||
Base.joinpath(str::String, file::MyFile) = MyFile(Base.joinpath(str, file.file)) | ||
Base.normpath(file::MyFile) = MyFile(Base.normpath(file.file)) | ||
Base.isfile(file::MyFile) = Base.isfile(file.file) | ||
Base.findfirst(str::String, file::MyFile) = Base.findfirst(str, file.file) | ||
Base.String(file::MyFile) = file.file | ||
|
||
function make_module(file::MyFile) | ||
exprs = [] | ||
for line in eachline(file.file) | ||
val, name = split(line, '=') | ||
push!(exprs, :(function $(Symbol(name))() $val end)) | ||
end | ||
Expr(:toplevel, :(baremodule fake_lang | ||
$(exprs...) | ||
end), :(using .fake_lang)) | ||
end | ||
|
||
function Base.include(mod::Module, file::MyFile) | ||
Core.eval(mod, make_module(file)) | ||
end | ||
Base.include(file::MyFile) = Base.include(Core.Main, file) | ||
|
||
using Revise | ||
function Revise.parse_source!(mod_exprs_sigs::Revise.ModuleExprsSigs, file::MyFile, mod::Module; kwargs...) | ||
ex = make_module(file) | ||
Revise.process_source!(mod_exprs_sigs, ex, file, mod; kwargs...) | ||
end | ||
|
||
path = joinpath(@__DIR__, "test.program") | ||
try | ||
cp(joinpath(@__DIR__, "fake_lang", "test.program"), path, force=true) | ||
m=MyFile(path) | ||
includet(m) | ||
Revise.revise() | ||
@test fake_lang.y() == "2" | ||
@test fake_lang.x() == "1" | ||
cp(joinpath(@__DIR__, "fake_lang", "new_test.program"), path, force=true) | ||
Revise.revise() | ||
@test fake_lang.x() == "2" | ||
@test_throws MethodError fake_lang.y() | ||
finally | ||
rm(path, force=true) | ||
end |
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