Skip to content

Commit 4cfe280

Browse files
committed
Improve error if dialyzer errors in tests
1 parent d3fb79e commit 4cfe280

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/elixir/test/elixir/kernel/dialyzer_test.exs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ defmodule Kernel.DialyzerTest do
2424
# Add a few key Elixir modules for types and macro functions
2525
mods = [Kernel, String, Keyword, Exception, Macro, Macro.Env, :elixir_env]
2626
files = Enum.map(mods, &:code.which/1)
27-
:dialyzer.run([analysis_type: :plt_build, output_plt: plt,
28-
apps: [:erts], files: files])
27+
dialyzer_run([analysis_type: :plt_build, output_plt: plt,
28+
apps: [:erts], files: files])
2929

3030
# Compile Dialyzer fixtures
3131
assert '' = elixirc("#{fixture_path("dialyzer")} -o #{dir}")
@@ -99,11 +99,20 @@ defmodule Kernel.DialyzerTest do
9999
end
100100

101101
defp assert_dialyze_no_warnings!(context) do
102-
case :dialyzer.run(context[:dialyzer]) do
102+
case dialyzer_run(context[:dialyzer]) do
103103
[] ->
104104
:ok
105105
warnings ->
106106
flunk IO.chardata_to_string(for warn <- warnings, do: [:dialyzer.format_warning(warn), ?\n])
107107
end
108108
end
109+
110+
defp dialyzer_run(opts) do
111+
try do
112+
:dialyzer.run(opts)
113+
catch
114+
:throw, {:dialyzer_error, chardata} ->
115+
raise "dialyzer error: " <> IO.chardata_to_string(chardata)
116+
end
117+
end
109118
end

0 commit comments

Comments
 (0)