Test result improvements: color
This commit is contained in:
@@ -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
|
||||||
|
IO.puts(IO.ANSI.format [:green, "Test #{test}.#{part} succeeded"])
|
||||||
|
end
|
||||||
else
|
else
|
||||||
IO.puts("Test #{test}.2 succeeded")
|
IO.puts("Test #{test}.#{part}:")
|
||||||
|
dbg(got)
|
||||||
end
|
end
|
||||||
else
|
|
||||||
IO.puts("Test #{test}.2")
|
|
||||||
dbg(p2)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
result.(1, p1, p1e)
|
||||||
|
result.(2, p2, p2e)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user