Skip to content

Commit

Permalink
hook up test macro to ENV color settings
Browse files Browse the repository at this point in the history
  • Loading branch information
KristofferC committed Oct 28, 2016
1 parent 39398fd commit 2776cc6
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions base/test.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ type Fail <: Result
value
end
function Base.show(io::IO, t::Fail)
print_with_color(:light_red, io, "Test Failed\n"; bold = true)
print_with_color(Base.error_color(), io, "Test Failed\n"; bold = true)
print(io, " Expression: ", t.orig_expr)
if t.test_type == :test_throws_wrong
# An exception was thrown, but it was of the wrong type
Expand Down Expand Up @@ -100,7 +100,7 @@ type Error <: Result
backtrace
end
function Base.show(io::IO, t::Error)
print_with_color(:light_red, io, "Error During Test\n"; bold = true)
print_with_color(Base.error_color(), io, "Error During Test\n"; bold = true)
if t.test_type == :test_nonbool
println(io, " Expression evaluated to non-Boolean")
println(io, " Expression: ", t.orig_expr)
Expand Down Expand Up @@ -481,16 +481,16 @@ function print_test_results(ts::DefaultTestSet, depth_pad=0)
print_with_color(:green, lpad("Pass",pass_width," "), " "; bold = true)
end
if fail_width > 0
print_with_color(:light_red, lpad("Fail",fail_width," "), " "; bold = true)
print_with_color(Base.error_color(), lpad("Fail",fail_width," "), " "; bold = true)
end
if error_width > 0
print_with_color(:light_red, lpad("Error",error_width," "), " "; bold = true)
print_with_color(Base.error_color(), lpad("Error",error_width," "), " "; bold = true)
end
if broken_width > 0
print_with_color(:yellow, lpad("Broken",broken_width," "), " "; bold = true)
end
if total_width > 0
print_with_color(:blue, lpad("Total",total_width, " "); bold = true)
print_with_color(Base.info_color(), lpad("Total",total_width, " "); bold = true)
end
println()
# Recursively print a summary at every level
Expand Down Expand Up @@ -593,40 +593,40 @@ function print_counts(ts::DefaultTestSet, depth, align,

np = passes + c_passes
if np > 0
print_with_color(:green, lpad(string(np), pass_width, " "), " "; bold = true)
print_with_color(:green, lpad(string(np), pass_width, " "), " ")
elseif pass_width > 0
# No passes at this level, but some at another level
print(lpad(" ", pass_width), " ")
end

nf = fails + c_fails
if nf > 0
print_with_color(:light_red, lpad(string(nf), fail_width, " "), " "; bold = true)
print_with_color(Base.error_color(), lpad(string(nf), fail_width, " "), " ")
elseif fail_width > 0
# No fails at this level, but some at another level
print(lpad(" ", fail_width), " ")
end

ne = errors + c_errors
if ne > 0
print_with_color(:light_red, lpad(string(ne), error_width, " "), " "; bold = true)
print_with_color(Base.error_color(), lpad(string(ne), error_width, " "), " ")
elseif error_width > 0
# No errors at this level, but some at another level
print(lpad(" ", error_width), " ")
end

nb = broken + c_broken
if nb > 0
print_with_color(:yellow, lpad(string(nb), broken_width, " "), " "; bold = true)
print_with_color(:yellow, lpad(string(nb), broken_width, " "), " ")
elseif broken_width > 0
# None broken at this level, but some at another level
print(lpad(" ", broken_width), " ")
end

if np == 0 && nf == 0 && ne == 0 && nb == 0
print_with_color(:blue, "No tests"; bold = true)
print_with_color(Base.info_color(), "No tests")
else
print_with_color(:blue, lpad(string(subtotal), total_width, " "); bold = true)
print_with_color(Base.info_color(), lpad(string(subtotal), total_width, " "))
end
println()

Expand Down

0 comments on commit 2776cc6

Please sign in to comment.