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
commit 26890b6525
4 changed files with 10 additions and 6 deletions

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@
import import
parseutils, strutils, pegs, os, osproc, streams, parsecfg, json, parseutils, strutils, pegs, os, osproc, streams, parsecfg, json,
marshal, backend, parseopt, specs, htmlgen, browsers marshal, backend, parseopt, specs, htmlgen, browsers, terminal
const const
resultsFile = "testresults.html" resultsFile = "testresults.html"
@ -109,7 +109,12 @@ proc addResult(r: var TResults, test: TTest,
expected = expected, expected = expected,
given = given) given = given)
r.data.addf("$#\t$#\t$#\t$#", name, expected, given, $success) 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) = proc cmpMsgs(r: var TResults, expected, given: TSpec, test: TTest) =
if strip(expected.msg) notin strip(given.msg): 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 # major entry point for a single test
let tname = test.name.addFileExt(".nim") let tname = test.name.addFileExt(".nim")
inc(r.total) inc(r.total)
stdout.write extractFilename(tname) echo extractFilename(tname)
var expected = parseSpec(tname) var expected = parseSpec(tname)
if expected.err == reIgnored: if expected.err == reIgnored:
r.addResult(test, "", "", reIgnored) r.addResult(test, "", "", reIgnored)