From f5ec001fc4a538181492b0d61931708f6ac9a28d Mon Sep 17 00:00:00 2001 From: John Christopher Anderson Date: Mon, 12 Oct 2009 04:59:58 +0000 Subject: link to submit test failures to a google group git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@824224 13f79535-47bb-0310-9956-ffa450edef68 --- share/www/script/couch_test_runner.js | 61 +++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) (limited to 'share') diff --git a/share/www/script/couch_test_runner.js b/share/www/script/couch_test_runner.js index a6d09848..aeb1de59 100644 --- a/share/www/script/couch_test_runner.js +++ b/share/www/script/couch_test_runner.js @@ -142,9 +142,63 @@ function updateTestsFooter() { var text = $(this).text(); totalDuration += parseInt(text.substr(0, text.length - 2), 10); }); - $("#tests tbody.footer td").text(testsRun.length + " of " + tests.length + + $("#tests tbody.footer td").html(""+testsRun.length + " of " + tests.length + " test(s) run, " + testsFailed.length + " failures (" + - totalDuration + " ms)"); + totalDuration + " ms) "); + if (testsFailed.length > 0) { + $("#tests tbody.footer td").append($('Click to Report Test Failures').click(function(e) { + e.preventDefault(); + reportTests(); + })); + } +} + + +function testReport() { + var report = []; + report.push(testPlatform()+"\n"); + $("#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 = []; + $("td.details li", this).each(function() { + report.push(" "+$(this).text()); + }); + } + }); + return report.join("\n"); +}; + +function testPlatform() { + var b = $.browser; + var bs = ["mozilla", "msie", "opera", "safari"]; + for (var i=0; i < bs.length; i++) { + if (b[bs[i]]) { + return "Platform: "+ bs[i] + " " + b.version; + } + }; +} + + +function reportTests() { + var summary = $("#tests tbody.footer td span").text(); + var report = testReport(); + 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(); } // Use T to perform a test that returns false on failure and if the test fails, @@ -157,8 +211,9 @@ function T(arg1, arg2, testName) { if ($("td.details ol", currentRow).length == 0) { $("
    ").appendTo($("td.details", currentRow)); } + var message = (arg2 != null ? arg2 : arg1).toString(); $("
  1. Assertion " + (testName ? "'" + testName + "'" : "") + " failed:
  2. ") - .find("code").text((arg2 != null ? arg2 : arg1).toString()).end() + .find("code").text(message).end() .appendTo($("td.details ol", currentRow)); } numFailures += 1 -- cgit v1.2.3