fixed the tester; more tests green

This commit is contained in:
Araq 2015-03-10 12:32:16 +01:00
commit 0032912d10
7 changed files with 68 additions and 50 deletions

View file

@ -20,7 +20,7 @@ const
<td>Success</td></tr>"""
TableFooter = "</table>"
HtmlBegin = """<html>
<head>
<head>
<title>Test results</title>
<style type="text/css">
<!--""" & slurp("css/boilerplate.css") & "\n" &
@ -28,13 +28,13 @@ const
"""
ul#tabs { list-style-type: none; margin: 30px 0 0 0; padding: 0 0 0.3em 0; }
ul#tabs li { display: inline; }
ul#tabs li a { color: #42454a; background-color: #dedbde;
border: 1px solid #c9c3ba; border-bottom: none;
ul#tabs li a { color: #42454a; background-color: #dedbde;
border: 1px solid #c9c3ba; border-bottom: none;
padding: 0.3em; text-decoration: none; }
ul#tabs li a:hover { background-color: #f1f0ee; }
ul#tabs li a.selected { color: #000; background-color: #f1f0ee;
ul#tabs li a.selected { color: #000; background-color: #f1f0ee;
font-weight: bold; padding: 0.7em 0.3em 0.38em 0.3em; }
div.tabContent { border: 1px solid #c9c3ba;
div.tabContent { border: 1px solid #c9c3ba;
padding: 0.5em; background-color: #f1f0ee; }
div.tabContent.hide { display: none; }
-->
@ -43,7 +43,7 @@ div.tabContent.hide { display: none; }
var tabLinks = new Array();
var contentDivs = new Array();
function init() {
// Grab the tab links and content divs from the page
var tabListItems = document.getElementById('tabs').childNodes;
@ -103,7 +103,7 @@ div.tabContent.hide { display: none; }
</head>
<body onload="init()">"""
HtmlEnd = "</body></html>"
proc td(s: string): string =
@ -115,8 +115,8 @@ proc getCommit(db: TDbConn, c: int): string =
if commit == 0: result = thisCommit[0]
inc commit
proc generateHtml*(filename: string, commit: int) =
const selRow = """select name, category, target, action,
proc generateHtml*(filename: string, commit: int; onlyFailing: bool) =
const selRow = """select name, category, target, action,
expected, given, result
from TestResult
where [commit] = ? and machine = ?
@ -140,17 +140,20 @@ proc generateHtml*(filename: string, commit: int) =
for m in db.rows(sql"select id, name, os, cpu from Machine order by id"):
outfile.writeln """<li><a href="#$#">$#: $#, $#</a></li>""" % m
outfile.write("</ul>")
for currentMachine in db.rows(sql"select id from Machine order by id"):
let m = currentMachine[0]
outfile.write("""<div class="tabContent" id="$#">""" % m)
outfile.write(TableHeader)
for row in db.rows(sql(selRow), lastCommit, m):
outfile.write("<tr>")
for x in row:
outfile.write(x.td)
outfile.write("</tr>")
if onlyFailing and row.len > 0 and row[row.high] == "reSuccess":
discard
else:
outfile.write("<tr>")
for x in row:
outfile.write(x.td)
outfile.write("</tr>")
outfile.write(TableFooter)
outfile.write("</div>")
@ -161,7 +164,7 @@ proc generateHtml*(filename: string, commit: int) =
proc generateJson*(filename: string, commit: int) =
const
selRow = """select count(*),
sum(result = 'reSuccess'),
sum(result = 'reSuccess'),
sum(result = 'reIgnored')
from TestResult
where [commit] = ? and machine = ?
@ -174,9 +177,9 @@ proc generateJson*(filename: string, commit: int) =
on A.name = B.name and A.category = B.category
where A.[commit] = ? and B.[commit] = ? and A.machine = ?
and A.result != B.result"""
selResults = """select
category || '/' || target || '/' || name,
category, target, action, result, expected, given
selResults = """select
category || '/' || target || '/' || name,
category, target, action, result, expected, given
from TestResult
where [commit] = ?"""
var db = open(connection="testament.db", user="testament", password="",

View file

@ -30,6 +30,7 @@ Arguments:
arguments are passed to the compiler
Options:
--print also print results to the console
--failing only show failing/ignored tests
""" % resultsFile
type
@ -48,7 +49,7 @@ type
# ----------------------------------------------------------------------------
let
pegLineError =
pegLineError =
peg"{[^(]*} '(' {\d+} ', ' \d+ ') ' ('Error') ':' \s* {.*}"
pegOtherError = peg"'Error:' \s* {.*}"
pegSuccess = peg"'Hint: operation successful'.*"
@ -107,7 +108,7 @@ proc addResult(r: var TResults, test: TTest,
expected, given: string, success: TResultEnum) =
let name = test.name.extractFilename & test.options
backend.writeTestResult(name = name,
category = test.cat.string,
category = test.cat.string,
target = $test.target,
action = $test.action,
result = $success,
@ -141,7 +142,7 @@ proc generatedFile(path, name: string, target: TTarget): string =
(if target == targetJS: path.splitPath.tail & "_" else: "compiler_") &
name.changeFileExt(ext)
proc codegenCheck(test: TTest, check: string, given: var TSpec, r: var TResults) =
proc codegenCheck(test: TTest, check: string, given: var TSpec) =
try:
let (path, name, ext2) = test.name.splitFile
let genFile = generatedFile(path, name, test.target)
@ -151,10 +152,11 @@ proc codegenCheck(test: TTest, check: string, given: var TSpec, r: var TResults)
given.err = reCodegenFailure
except ValueError:
given.err = reInvalidPeg
echo getCurrentExceptionMsg()
except IOError:
given.err = reCodeNotFound
proc nimoutCheck(test: TTest; expectedNimout: string; given: var TSpec, r: var TResults) =
proc nimoutCheck(test: TTest; expectedNimout: string; given: var TSpec) =
let exp = expectedNimout.strip.replace("\C\L", "\L")
let giv = given.nimout.strip.replace("\C\L", "\L")
if exp notin giv:
@ -165,18 +167,19 @@ proc makeDeterministic(s: string): string =
sort(x, system.cmp)
result = join(x, "\n")
proc compilerOutputTests(test: TTest, given: var TSpec, expected: TSpec, r: var TResults) =
proc compilerOutputTests(test: TTest, given: var TSpec, expected: TSpec;
r: var TResults) =
var expectedmsg: string = ""
var givenmsg: string = ""
if given.err == reSuccess:
if expected.ccodeCheck.len > 0:
codegenCheck(test, expectedmsg, given, r)
codegenCheck(test, expected.ccodeCheck, given)
expectedmsg = expected.ccodeCheck
givenmsg = given.msg
if expected.nimout.len > 0:
expectedmsg = expected.nimout
givenmsg = given.nimout.strip
nimoutCheck(test, expectedmsg, given, r)
nimoutCheck(test, expectedmsg, given)
if given.err == reSuccess: inc(r.passed)
r.addResult(test, expectedmsg, givenmsg, given.err)
@ -260,11 +263,13 @@ proc main() =
backend.open()
var optPrintResults = false
var optFailing = false
var p = initOptParser()
p.next()
if p.kind == cmdLongoption:
while p.kind == cmdLongoption:
case p.key.string.normalize
of "print", "verbose": optPrintResults = true
of "failing": optFailing = true
else: quit Usage
p.next()
if p.kind != cmdArgument: quit Usage
@ -288,7 +293,7 @@ proc main() =
of "html":
var commit = 0
discard parseInt(p.cmdLineRest.string, commit)
generateHtml(resultsFile, commit)
generateHtml(resultsFile, commit, optFailing)
generateJson(jsonFile, commit)
else:
quit Usage