make some tests red :) (i.e. print failure details while running the tester)

This commit is contained in:
Zahary Karadjov
2014-03-16 20:52:09 +02:00
parent 49b0440c47
commit 26890b6525
4 changed files with 10 additions and 6 deletions

View File

@@ -1,6 +1,5 @@
discard """
line: 11
file: "tbindtypedesc.nim"
errormsg: "type mismatch: got (typedesc[float], string)"
"""

View File

@@ -1,5 +1,5 @@
discard """
line: 1912
line: 1913
file: "system.nim"
errormsg: "can raise an unlisted exception: ref EIO"
"""

View File

@@ -1,5 +1,5 @@
discard """
msg: "type mismatch: got (PTest)"
errormsg: "type mismatch: got (PTest)"
"""
type

View File

@@ -11,7 +11,7 @@
import
parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
marshal, backend, parseopt, specs, htmlgen, browsers
marshal, backend, parseopt, specs, htmlgen, browsers, terminal
const
resultsFile = "testresults.html"
@@ -109,7 +109,12 @@ proc addResult(r: var TResults, test: TTest,
expected = expected,
given = given)
r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success)
echo " [", $success, "]"
if success notin {reSuccess, reIgnored}:
styledEcho styleBright, fgRed, "^^^ [", $success, "]"
styledEcho styleDim, "EXPECTED:"
echo expected
styledEcho styleDim, "GIVEN:"
echo given
proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
if strip(expected.msg) notin strip(given.msg):
@@ -147,7 +152,7 @@ proc testSpec(r: var TResults, test: TTest) =
# major entry point for a single test
let tname = test.name.addFileExt(".nim")
inc(r.total)
stdout.write extractFilename(tname)
echo extractFilename(tname)
var expected = parseSpec(tname)
if expected.err == reIgnored:
r.addResult(test, "", "", reIgnored)