From 825a47fc3dec99c3f8351d598d4dec34081be43a Mon Sep 17 00:00:00 2001 From: Robert Konigsberg Date: Fri, 15 Jun 2012 11:21:02 -0400 Subject: [PATCH] Add failure count to top of file. --- auto_tests/misc/local.html | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/auto_tests/misc/local.html b/auto_tests/misc/local.html index 076e3ec..a2bff4b 100644 --- a/auto_tests/misc/local.html +++ b/auto_tests/misc/local.html @@ -124,15 +124,16 @@ } } resultsDiv = createResultsDiv(); - postResults(results); + var failures = postResults(results); resultsDiv.appendChild(document.createElement("hr")); + document.getElementById('summary').innerText = "(" + failures + " failures)"; } function createResultsDiv() { var body = document.getElementsByTagName("body")[0]; div = document.createElement("div"); div.id='results'; - div.innerHTML = "Test results: passed failed all
"; + div.innerHTML = "Test results: passed failed all
"; body.insertBefore(div, body.firstChild); var setByClassName = function(name, displayStyle) { @@ -167,6 +168,7 @@ return div; } + /* also returns an in representing sum of failures below. */ function postResults(results, title) { if (typeof(results) == "boolean") { var elem = document.createElement("div"); @@ -175,18 +177,21 @@ var prefix = title ? (title + ": ") : ""; elem.innerHTML = prefix + '' + (results ? 'pass' : 'fail') + ''; resultsDiv.appendChild(elem); + return results ? 0 : 1; } else { // hash + var failed = 0; var html = ""; for (var key in results) { if (results.hasOwnProperty(key)) { var elem = results[key]; if (typeof(elem) == "boolean" && title) { - postResults(results[key], title + "." + key); + failed += postResults(results[key], title + "." + key); } else { - postResults(results[key], key); + failed += postResults(results[key], key); } } } + return failed; } } -- 2.7.4