Skip to content
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
5 changes: 3 additions & 2 deletions base/client.jl
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,17 @@ file.
"""
atreplinit(f::Function) = (unshift!(repl_hooks, f); nothing)

function _atreplinit(repl)
function __atreplinit(repl)
for f in repl_hooks
try
f(repl)
catch err
show(STDERR, err)
showerror(STDERR, err)
println(STDERR)
end
end
end
_atreplinit(repl) = eval(Main, :($__atreplinit($repl)))

function _start()
empty!(ARGS)
Expand Down
16 changes: 16 additions & 0 deletions test/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -548,3 +548,19 @@ let io = IOBuffer()
end, [])
@test length(String(take!(io))) < 1500
end

function test_replinit()
stdin_write, stdout_read, stdout_read, repl = fake_repl()
# Relies on implementation detail to make sure we only have the single
# replinit callback we want to test.
saved_replinit = copy(Base.repl_hooks)
slot = Ref(false)
# Create a closure from a newer world to check if `_atreplinit`
# can run it correctly
atreplinit(eval(:(repl::Base.REPL.LineEditREPL->($slot[] = true))))
Base._atreplinit(repl)
@test slot[]
@test_throws MethodError Base.repl_hooks[1](repl)
copy!(Base.repl_hooks, saved_replinit)
end
test_replinit()