Skip to content

Commit fe2561b

Browse files
committed
Workaround elixir bug in ExUnit.Formatter.format_test_all_failure
1 parent e581624 commit fe2561b

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

apps/debug_adapter/lib/debug_adapter/exunit_formatter.ex

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,24 @@ defmodule ElixirLS.DebugAdapter.ExUnitFormatter do
181181
formatter_cb = fn _key, value -> value end
182182

183183
message =
184-
ExUnit.Formatter.format_test_all_failure(
185-
test_module,
186-
failures,
187-
state.failure_counter + 1,
188-
@width,
189-
formatter_cb
190-
)
184+
try do
185+
ExUnit.Formatter.format_test_all_failure(
186+
test_module,
187+
failures,
188+
state.failure_counter + 1,
189+
@width,
190+
formatter_cb
191+
)
192+
rescue
193+
e ->
194+
Output.debugger_console(
195+
"ExUnit.Formatter.format_test_all_failure failed: #{Exception.format(:error, e, __STACKTRACE__)}"
196+
)
197+
198+
# Workaround for https://github.com/elixir-lang/elixir/issues/14900
199+
# TODO remove when we require elixir >= 1.20
200+
"invalid test module #{test_module}: #{inspect(failures)}"
201+
end
191202

192203
Output.ex_unit_event(%{
193204
"event" => "test_errored",
@@ -216,7 +227,9 @@ defmodule ElixirLS.DebugAdapter.ExUnitFormatter do
216227
end
217228

218229
def handle_cast(:max_failures_reached, state) do
219-
# undocumented event - we probably don't need to do anything
230+
# the test run has been aborted due to reaching max failures limit set
231+
# with `:max_failures` option
232+
# we probably don't need to do anything
220233
{:noreply, state}
221234
end
222235

0 commit comments

Comments
 (0)