Test result improvements: color

This commit is contained in:
bluepython508
2023-12-02 19:25:19 +00:00
parent 2784245b2d
commit c086fc1773

View File

@@ -128,32 +128,24 @@ defmodule Mix.Tasks.Aoc do
|> Enum.map(fn {test, input, p1e, p2e} -> |> Enum.map(fn {test, input, p1e, p2e} ->
parsed = mod.parse(input) parsed = mod.parse(input)
p1 = mod.part1(parsed) p1 = mod.part1(parsed)
if p1e do
if stringify(p1) != p1e do
IO.puts("Failed at #{test}.1: expected #{p1e}, got:")
dbg(p1)
else
IO.puts("Test #{test}.1 succeeded")
end
else
IO.puts("Test #{test}.1")
dbg(p1)
end
p2 = mod.part2(parsed) p2 = mod.part2(parsed)
if p2e do result = fn (part, got, expected) ->
if stringify(p2) != p2e do if expected do
IO.puts("Failed at #{test}.2: expected #{p2e}, got:") if stringify(got) != expected do
dbg(p2) IO.puts(IO.ANSI.format [:red, "Test #{test}.#{part} failed: expected #{expected}"])
dbg(got)
else else
IO.puts("Test #{test}.2 succeeded") IO.puts(IO.ANSI.format [:green, "Test #{test}.#{part} succeeded"])
end end
else else
IO.puts("Test #{test}.2") IO.puts("Test #{test}.#{part}:")
dbg(p2) dbg(got)
end end
end
result.(1, p1, p1e)
result.(2, p2, p2e)
end) end)
end end