mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-01-29 02:09:30 +08:00
Don't warn on module redefinition (#52)
This commit is contained in:
parent
dc1930634f
commit
207f168239
2 changed files with 31 additions and 2 deletions
|
@ -93,11 +93,22 @@ defmodule LiveBook.Runtime.ErlDist.Manager do
|
|||
|
||||
Process.send_after(self(), :check_owner, @await_owner_timeout)
|
||||
|
||||
{:ok, %{owner: nil, evaluators: %{}}}
|
||||
# Set `ignore_module_conflict` only for the Manager lifetime.
|
||||
initial_ignore_module_conflict = Code.compiler_options()[:ignore_module_conflict]
|
||||
Code.compiler_options(ignore_module_conflict: true)
|
||||
|
||||
{:ok,
|
||||
%{
|
||||
owner: nil,
|
||||
evaluators: %{},
|
||||
initial_ignore_module_conflict: initial_ignore_module_conflict
|
||||
}}
|
||||
end
|
||||
|
||||
@impl true
|
||||
def terminate(_reason, _state) do
|
||||
def terminate(_reason, state) do
|
||||
Code.compiler_options(ignore_module_conflict: state.initial_ignore_module_conflict)
|
||||
|
||||
ErlDist.unload_required_modules()
|
||||
|
||||
:ok
|
||||
|
|
|
@ -38,5 +38,23 @@ defmodule LiveBook.Runtime.ErlDist.ManagerTest do
|
|||
|
||||
Manager.stop(node())
|
||||
end
|
||||
|
||||
test "prevents from module redefinition warning being printed to standard error" do
|
||||
Manager.start()
|
||||
Manager.set_owner(node(), self())
|
||||
|
||||
stderr =
|
||||
ExUnit.CaptureIO.capture_io(:stderr, fn ->
|
||||
Manager.evaluate_code(node(), "defmodule Foo do end", :container1, :evaluation1)
|
||||
Manager.evaluate_code(node(), "defmodule Foo do end", :container1, :evaluation2)
|
||||
|
||||
assert_receive {:evaluation_response, :evaluation1, _}
|
||||
assert_receive {:evaluation_response, :evaluation2, _}
|
||||
end)
|
||||
|
||||
assert stderr == ""
|
||||
|
||||
Manager.stop(node())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue