X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Fmisc%2Flocal.html;h=d24cab801022b51ae0172cb89e4d93d084fc4022;hb=3cfc4c9f46493dfa98464ee6fdb78e72aabd32a6;hp=a7efaf62a6bf6efdc7f72feec6ff5d0095c76535;hpb=3d8093fa2d6b9db4991204ac6a066f4eb424e3d6;p=dygraphs.git diff --git a/auto_tests/misc/local.html b/auto_tests/misc/local.html index a7efaf6..d24cab8 100644 --- a/auto_tests/misc/local.html +++ b/auto_tests/misc/local.html @@ -62,6 +62,7 @@ var test = args.test; var command = args.command; + // args.testCaseName uses the string name of the test. if (args.testCaseName) { var testCases = getAllTestCases(); name = args.testCaseName; @@ -73,28 +74,49 @@ break; } } - } else if (args.testCase) { + } else if (args.testCase) { // The class name of the test. name = args.testCase; eval("tc = new " + args.testCase + "()"); } + + // If the test class is defined. if (tc != null) { - if (args.command) { - if (args.command == "runAllTests") { - console.log("Running all tests for " + args.testCase); - postResults(tc.runAllTests()); - } - if (args.command == "runTest") { - console.log("Running test " + args.testCase + "." + args.test); - postResults(tc.runTest(args.test)); + if (args.command == "runAllTests") { + console.log("Running all tests for " + args.testCase); + postResults(tc.runAllTests()); + } + if (args.command == "runTest") { + console.log("Running test " + args.testCase + "." + args.test); + postResults(tc.runTest(args.test)); + } + } else { + if (args.command == "runAllTests") { + console.log("Running all tests for all test cases"); + var testCases = getAllTestCases(); + var results = {}; + for (var idx in testCases) { + var entry = testCases[idx]; + var prototype = entry.testCase; + tc = new entry.testCase(); + results[entry.name] = tc.runAllTests(); } + postResults(results); } } } - function postResults(results) { - var body = document.getElementsByTagName("body")[0]; - var div = document.createElement("div"); - body.insertBefore(div, body.firstChild); + function postResults(results, title, div) { + var first = false; + if (div == null) { + var body = document.getElementsByTagName("body")[0]; + div = document.createElement("div"); + div.innerHTML = "Test results:"; + if (typeof(results) != "boolean"); { + div.innerHTML = "Test results:
"; + } + body.insertBefore(div, body.firstChild); + first = true; + } var resultToHtml = function(result) { return result ? @@ -103,17 +125,29 @@ } if (typeof(results) == "boolean") { - div.innerHTML = "Test results: " + resultToHtml(results); + var elem = document.createElement("div"); + if (title) { + elem.innerHTML = title + ": " + resultToHtml(results); + } else { + elem.innerHTML = resultToHtml(results); + } + div.appendChild(elem); } else { // hash var html = ""; for (var key in results) { if (results.hasOwnProperty(key)) { - html = html + key + ": " + resultToHtml(results[key]) + "
"; + var elem = results[key]; + if (typeof(elem) == "boolean" && title) { + postResults(results[key], title + "." + key, div); + } else { + postResults(results[key], key, div); + } } } - div.innerHTML = "Test results:
" + html; } - div.appendChild(document.createElement("hr")); + if (first) { + div.appendChild(document.createElement("hr")); + } } @@ -159,6 +193,7 @@ if (selector != null) { // running a test if (tc == null) { description.innerHTML = "Test cases:"; var testCases = getAllTestCases(); + createLink(list, "(run all tests)", document.URL + "?command=runAllTests"); for (var idx in testCases) { var entryName = testCases[idx].name; createLink(list, entryName, document.URL + "?testCaseName=" + entryName);