diff --git a/koch.nim b/koch.nim index 22e30ac5e2..f9eacfbf48 100644 --- a/koch.nim +++ b/koch.nim @@ -263,16 +263,8 @@ when defined(withUpdate): proc tests(args: string) = # we compile the tester with taintMode:on to have a basic # taint mode test :-) - exec("nimrod cc --taintMode:on tests/tester") - exec(getCurrentDir() / "tests/tester".exe & " reject") - exec(getCurrentDir() / "tests/tester".exe & " compile") - exec(getCurrentDir() / "tests/tester".exe & " run") - exec(getCurrentDir() / "tests/tester".exe & " merge") - when false: - # activate real soon: - exec("nimrod cc --taintMode:on tests/testament/tester") - exec(getCurrentDir() / "tests/testament/tester".exe & " all") - + exec("nimrod cc --taintMode:on tests/testament/tester") + exec(getCurrentDir() / "tests/testament/tester".exe & " all") proc temp(args: string) = var output = "compiler" / "nimrod".exe diff --git a/tests/lookup/tredef.nim b/tests/lookups/tredef.nim similarity index 100% rename from tests/lookup/tredef.nim rename to tests/lookups/tredef.nim diff --git a/tests/testament/backend.nim b/tests/testament/backend.nim index 65d040b24e..500535d9b8 100644 --- a/tests/testament/backend.nim +++ b/tests/testament/backend.nim @@ -1,7 +1,7 @@ # # # The Nimrod Tester -# (c) Copyright 2013 Andreas Rumpf +# (c) Copyright 2014 Andreas Rumpf # # Look at license.txt for more info. # All rights reserved. @@ -49,10 +49,10 @@ proc createDb() = # """, []) type - MachineId = distinct int64 + MachineId* = distinct int64 CommitId = distinct int64 -proc `$`(id: MachineId): string {.borrow.} +proc `$`*(id: MachineId): string {.borrow.} proc `$`(id: CommitId): string {.borrow.} var @@ -61,7 +61,7 @@ var proc `()`(cmd: string{lit}): string = cmd.execProcess.string.strip -proc getMachine: MachineId = +proc getMachine*: MachineId = var name = "hostname"() if name.len == 0: name = when defined(posix): getenv"HOSTNAME".string @@ -73,7 +73,7 @@ proc getMachine: MachineId = if id.len > 0: result = id.parseInt.MachineId else: - result = db.insertId(sql"insert into Machine(name, os, cpu) values (?,?,?)", + result = db.insertId(sql"insert into Machine(name, os, cpu) values (?,?,?)", name, system.hostOS, system.hostCPU).MachineId proc getCommit: CommitId = diff --git a/tests/caasdriver.nim b/tests/testament/caasdriver.nim similarity index 100% rename from tests/caasdriver.nim rename to tests/testament/caasdriver.nim diff --git a/tests/css/boilerplate.css b/tests/testament/css/boilerplate.css similarity index 100% rename from tests/css/boilerplate.css rename to tests/testament/css/boilerplate.css diff --git a/tests/css/style.css b/tests/testament/css/style.css similarity index 100% rename from tests/css/style.css rename to tests/testament/css/style.css diff --git a/tests/testament/htmlgen.nim b/tests/testament/htmlgen.nim new file mode 100644 index 0000000000..6e3865bab6 --- /dev/null +++ b/tests/testament/htmlgen.nim @@ -0,0 +1,127 @@ +# +# +# Nimrod Tester +# (c) Copyright 2014 Andreas Rumpf +# +# See the file "copying.txt", included in this +# distribution, for details about the copyright. +# + +## HTML generator for the tester. + +import db_sqlite, cgi, backend, strutils + +const + TableHeader = """ + + + + + """ + TableFooter = "
TestCategoryTargetActionExpectedGivenSuccess
" + HtmlBegin = """ + + Test results + + + + + """ + + HtmlEnd = "" + +proc td(s: string): string = + result = "" & s.substr(0, 200).XMLEncode & "" + +proc generateHtml*(filename: string) = + const selRow = """select name, category, target, action, + expected, given, result + from TestResult + where [commit] = ? and machine = ? + order by category""" + var db = open(connection="testament.db", user="testament", password="", + database="testament") + var outfile = open(filename, fmWrite) + outfile.write(HtmlBegin) + let thisMachine = backend.getMachine() + outfile.write() + + let machine = db.getRow(sql"select name, os, cpu from machine where id = ?", + thisMachine) + outfile.write("

$#

" % machine.join(" ")) + + outfile.write("""") + + for lastCommit in db.getRow(sql"select id from [Commit] order by id desc"): + outfile.write("""
""" % lastCommit) + + outfile.write(TableHeader) + for row in db.rows(sql(selRow), lastCommit, thisMachine): + outfile.write("") + for x in row: + outfile.write(x.td) + outfile.write("") + + outfile.write(TableFooter) + outfile.write("
") + outfile.write(HtmlEnd) + close(db) + close(outfile) diff --git a/tests/testament/tester.nim b/tests/testament/tester.nim index 2c9a32e5e5..61d0072e32 100644 --- a/tests/testament/tester.nim +++ b/tests/testament/tester.nim @@ -10,8 +10,8 @@ ## This program verifies Nimrod against the testcases. import - parseutils, strutils, pegs, os, osproc, streams, parsecfg, browsers, json, - marshal, cgi, backend, parseopt, specs #, caas + parseutils, strutils, pegs, os, osproc, streams, parsecfg, json, + marshal, backend, parseopt, specs, htmlgen, browsers const resultsFile = "testresults.html" @@ -249,16 +249,18 @@ proc main() = processCategory(r, Category(dir), p.cmdLineRest.string) for a in AdditionalCategories: processCategory(r, Category(a), p.cmdLineRest.string) - of "c", "category": + of "c", "cat", "category": var cat = Category(p.key) p.next processCategory(r, cat, p.cmdLineRest.string) of "html": - quit "too implement" + generateHtml(resultsFile) else: quit usage - if optPrintResults: echo r, r.data + if optPrintResults: + if action == "html": openDefaultBrowser(resultsFile) + else: echo r, r.data backend.close() if paramCount() == 0: