Skip to content

Commit f6d8eb4

Browse files
authored
Add report for "normal" exits in IEx (#13753)
1 parent 4629fb6 commit f6d8eb4

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

lib/iex/lib/iex/server.ex

+8-15
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,14 @@ defmodule IEx.Server do
266266
input,
267267
_callback
268268
) do
269-
if abnormal_reason?(reason) do
270-
try do
271-
io_error(
272-
"** (EXIT from #{inspect(evaluator)}) shell process exited with reason: " <>
273-
Exception.format_exit(reason)
274-
)
275-
catch
276-
type, detail ->
277-
io_error("** (IEx.Error) #{type} when printing EXIT message: #{inspect(detail)}")
278-
end
269+
try do
270+
io_error(
271+
"** (EXIT from #{inspect(evaluator)}) shell process exited with reason: " <>
272+
Exception.format_exit(reason)
273+
)
274+
catch
275+
type, detail ->
276+
io_error("** (IEx.Error) #{type} when printing EXIT message: #{inspect(detail)}")
279277
end
280278

281279
rerun(state, [], evaluator, evaluator_ref, input)
@@ -285,11 +283,6 @@ defmodule IEx.Server do
285283
callback.(state)
286284
end
287285

288-
defp abnormal_reason?(:normal), do: false
289-
defp abnormal_reason?(:shutdown), do: false
290-
defp abnormal_reason?({:shutdown, _}), do: false
291-
defp abnormal_reason?(_), do: true
292-
293286
defp take_over?(take_pid, take_ref, take_location, take_whereami, take_opts, counter) do
294287
evaluator = take_opts[:evaluator] || self()
295288
message = "Request to pry #{inspect(evaluator)} at #{take_location}#{take_whereami}"

lib/iex/test/iex/interaction_test.exs

+10
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@ defmodule IEx.InteractionTest do
198198
~r"\*\* \(EXIT from #PID<\d+\.\d+\.\d+>\) shell process exited with reason: {:bye, \[:world\]}"
199199
end
200200

201+
test "receive normal exits" do
202+
assert capture_iex("spawn_link(fn -> exit(:normal) end); Process.sleep(1000)") =~ ":ok"
203+
204+
assert capture_iex("spawn_link(fn -> exit(:shutdown) end); Process.sleep(1000)") =~
205+
~r"\*\* \(EXIT from #PID<\d+\.\d+\.\d+>\) shell process exited with reason: shutdown"
206+
207+
assert capture_iex("spawn_link(fn -> exit({:shutdown, :bye}) end); Process.sleep(1000)") =~
208+
~r"\*\* \(EXIT from #PID<\d+\.\d+\.\d+>\) shell process exited with reason: shutdown: :bye"
209+
end
210+
201211
test "receive exit from exception" do
202212
# use exit/1 to fake an error so that an error message
203213
# is not sent to the error logger.

0 commit comments

Comments
 (0)