Skip to content

Commit 8c6197c

Browse files
Fix JSON formatter hanging forever
1 parent 40bf5b8 commit 8c6197c

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

exercism_test_helper/lib/json_formatter.ex

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,7 @@ defmodule JSONFormatter do
235235

236236
# Colorize Utility Functions -- from ExUnit.CLIFormatter, but can't import d/t being private in source
237237

238-
defp colorize(escape, msg, config) when is_doc(msg) do
239-
msg = Inspect.Algebra.format(msg, 2)
240-
colorize(escape, msg, config)
241-
end
242-
243-
defp colorize(escape, string, %{colors: colors}) do
238+
defp colorize(escape, string, %{colors: colors}) when is_binary(string) do
244239
if colors[:enabled] do
245240
[escape, string, :reset]
246241
|> IO.ANSI.format_fragment(true)
@@ -250,6 +245,15 @@ defmodule JSONFormatter do
250245
end
251246
end
252247

248+
defp colorize(escape, msg, config) when is_doc(msg) do
249+
msg =
250+
msg
251+
|> Inspect.Algebra.format(2)
252+
|> IO.iodata_to_binary()
253+
254+
colorize(escape, msg, config)
255+
end
256+
253257
@doc """
254258
Helper function to get the full path of the generated report file.
255259
It can be passed 2 configurations via environment variable

exercism_test_helper/lib/meta/style.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule Meta.Style do
22
def format(ast) do
33
ast
44
|> Macro.to_string()
5-
|> Code.format_string!([line_length: 120, force_do_end_blocks: true])
5+
|> Code.format_string!(line_length: 120, force_do_end_blocks: true)
66
|> IO.iodata_to_binary()
77
end
88
end

0 commit comments

Comments
 (0)