X-Git-Url: https://adrianiainlam.tk/git/?a=blobdiff_plain;f=auto_tests%2Fmisc%2Flocal.html;h=d24cab801022b51ae0172cb89e4d93d084fc4022;hb=86d724e52a93d4e75fdffdaa538b4f401e8fd3e6;hp=5bdf428386545129a19d07ed64d16a016d000984;hpb=a4e734cc6f4dea9698265e9333c33532010b254c;p=dygraphs.git
diff --git a/auto_tests/misc/local.html b/auto_tests/misc/local.html
index 5bdf428..d24cab8 100644
--- a/auto_tests/misc/local.html
+++ b/auto_tests/misc/local.html
@@ -35,6 +35,7 @@
+
@@ -48,9 +49,11 @@
var query = window.location.search.substring(1);
var args = {};
var vars = query.split("&");
- for (var i = 0;i < vars.length; i++) {
- var pair = vars[i].split("=");
- args[pair[0]] = pair[1];
+ for (var i = 0; i < vars.length; i++) {
+ if (vars[i].length > 0) {
+ var pair = vars[i].split("=");
+ args[pair[0]] = pair[1];
+ }
}
return args;
}
@@ -59,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;
@@ -70,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 ?
@@ -100,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"));
+ }
}
@@ -156,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);