From 623f3cc4f4191daa11c8726a0a80d1afad890cab Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Wed, 14 Oct 2009 06:35:07 +0000 Subject: test reports are saved proper git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@825019 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/couch_test_runner.js | 57 ++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/share/www/script/couch_test_runner.js b/share/www/script/couch_test_runner.js index 221d83d1..de9e6658 100644 --- a/share/www/script/couch_test_runner.js +++ b/share/www/script/couch_test_runner.js @@ -146,6 +146,7 @@ function updateTestsFooter() { $("#tests tbody.footer td").html(""+testsRun.length + " of " + tests.length + " test(s) run, " + testsFailed.length + " failures (" + totalDuration + " ms) "); + saveTestReport(); } // make report and save to local db @@ -155,28 +156,43 @@ function updateTestsFooter() { function saveTestReport() { var subject = $("#tests tbody.footer td").text(); var report = makeTestReport(); - var db = $.couch.db("test_suite_reports"); - var saveReport = function() { - db.saveDoc(report); - }; - db.create({error: saveReport, success: saveReport}); + if (report) { + var db = $.couch.db("test_suite_reports"); + var saveReport = function() { + db.saveDoc(report); + }; + var createDb = function() { + db.create({error: saveReport, success: saveReport}); + } + db.info({error: createDb, success:saveReport}); + } }; function makeTestReport() { var report = {}; - report.platform = testPlatform()); + report.platform = testPlatform(); + var date = new Date(); + report.timestamp = date.getTime(); + report.timezone = date.getTimezoneOffset(); + report.tests = []; $("#tests tbody.content tr").each(function() { var status = $("td.status", this).text(); if (status != "not run") { - var dur = $("td.duration", this).text(); - report.push(this.id+"\n "+status+" "+dur); - var details = []; + var test = {}; + test.name = this.id; + test.status = status; + test.duration = parseInt($("td.duration", this).text()); + test.details = []; $("td.details li", this).each(function() { - report.push(" "+$(this).text()); + test.details.push($(this).text()); }); + if (test.details.length == 0) { + delete test.details; + } + report.tests.push(test); } }); - return report.join("\n"); + if (report.tests.length > 0) return report; }; function testPlatform() { @@ -184,29 +200,14 @@ function testPlatform() { var bs = ["mozilla", "msie", "opera", "safari"]; for (var i=0; i < bs.length; i++) { if (b[bs[i]]) { - return "Platform: "+ bs[i] + " " + b.version; + return {"browser" : bs[i], "version" : b.version}; } }; } function reportTests() { - // var summary = $("#tests tbody.footer td span").text(); - // var report = makeTestReport(); - // var uri = "http://groups.google.com/group/couchdb-test-report/post" - // + "?subject=" + escape(summary); - // - // var d=document; - // var f=d.createElement("form"); - // // f.style.display='none'; - // f.action=uri; - // f.method="POST";f.target="_blank"; - // var t=d.createElement("textarea"); - // t.name="body"; - // t.value=report; - // f.appendChild(t); - // d.body.appendChild(f); - // f.submit(); + // replicate the database to couchdb.couchdb.org } // Use T to perform a test that returns false on failure and if the test fails, -- cgit v1.2.3