mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 16:14:10 -08:00
Improves junit-support.js. Starts to rewrite generator
This commit is contained in:
parent
231c5a43ee
commit
03018a8f40
|
@ -1,9 +1,6 @@
|
||||||
package org.teavm.classlibgen;
|
package org.teavm.classlibgen;
|
||||||
|
|
||||||
import java.io.FileOutputStream;
|
import java.io.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.teavm.codegen.*;
|
import org.teavm.codegen.*;
|
||||||
|
@ -20,7 +17,7 @@ import org.teavm.optimization.ClassSetOptimizer;
|
||||||
* @author Alexey Andreev <konsoletyper@gmail.com>
|
* @author Alexey Andreev <konsoletyper@gmail.com>
|
||||||
*/
|
*/
|
||||||
public class ClasslibTestGenerator {
|
public class ClasslibTestGenerator {
|
||||||
private static PrintStream out;
|
private static File outputDir;
|
||||||
private static ClasspathClassHolderSource classSource;
|
private static ClasspathClassHolderSource classSource;
|
||||||
private static Decompiler decompiler;
|
private static Decompiler decompiler;
|
||||||
private static AliasProvider aliasProvider;
|
private static AliasProvider aliasProvider;
|
||||||
|
@ -34,11 +31,28 @@ public class ClasslibTestGenerator {
|
||||||
"java.lang.VMTests" };
|
"java.lang.VMTests" };
|
||||||
|
|
||||||
public static void main(String[] args) throws IOException {
|
public static void main(String[] args) throws IOException {
|
||||||
out = System.out;
|
outputDir = new File(args[0]);
|
||||||
if (args.length > 0) {
|
outputDir.mkdirs();
|
||||||
out = new PrintStream(new FileOutputStream(args[0]));
|
resourceToFile("org/teavm/javascript/runtime.js", "runtime.js");
|
||||||
}
|
resourceToFile("org/teavm/classlib/junit-support.js", "junit-support.js");
|
||||||
|
resourceToFile("org/teavm/classlib/junit.css", "junit.css");
|
||||||
classSource = new ClasspathClassHolderSource();
|
classSource = new ClasspathClassHolderSource();
|
||||||
|
for (int i = 0; i < testClasses.length; ++i) {
|
||||||
|
testClasses[i] = "org.teavm.classlib." + testClasses[i];
|
||||||
|
}
|
||||||
|
for (String testClass : testClasses) {
|
||||||
|
ClassHolder classHolder = classSource.getClassHolder(testClass);
|
||||||
|
findTests(classHolder);
|
||||||
|
}
|
||||||
|
writer.append("runTests = function() {").newLine().indent();
|
||||||
|
writer.append("document.getElementById(\"start-button\").style.display = 'none';").newLine();
|
||||||
|
for (String testClass : testClasses) {
|
||||||
|
renderClassTest(classSource.getClassHolder(testClass));
|
||||||
|
}
|
||||||
|
writer.outdent().append("}").newLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void decompileClassesForTest(MethodReference methodRef, String targetName) throws IOException {
|
||||||
decompiler = new Decompiler(classSource);
|
decompiler = new Decompiler(classSource);
|
||||||
aliasProvider = new MinifyingAliasProvider();
|
aliasProvider = new MinifyingAliasProvider();
|
||||||
naming = new DefaultNamingStrategy(aliasProvider, classSource);
|
naming = new DefaultNamingStrategy(aliasProvider, classSource);
|
||||||
|
@ -47,41 +61,21 @@ public class ClasslibTestGenerator {
|
||||||
builder.setMinified(true);
|
builder.setMinified(true);
|
||||||
writer = builder.build();
|
writer = builder.build();
|
||||||
renderer = new Renderer(writer, classSource);
|
renderer = new Renderer(writer, classSource);
|
||||||
|
renderer.renderRuntime();
|
||||||
DependencyChecker dependencyChecker = new DependencyChecker(classSource);
|
DependencyChecker dependencyChecker = new DependencyChecker(classSource);
|
||||||
for (int i = 0; i < testClasses.length; ++i) {
|
MethodReference cons = new MethodReference(methodRef.getClassName(),
|
||||||
testClasses[i] = "org.teavm.classlib." + testClasses[i];
|
new MethodDescriptor("<init>", ValueType.VOID));
|
||||||
}
|
|
||||||
for (String testClass : testClasses) {
|
|
||||||
ClassHolder classHolder = classSource.getClassHolder(testClass);
|
|
||||||
findTests(classHolder);
|
|
||||||
MethodReference cons = new MethodReference(testClass, new MethodDescriptor("<init>", ValueType.VOID));
|
|
||||||
dependencyChecker.addEntryPoint(cons);
|
dependencyChecker.addEntryPoint(cons);
|
||||||
}
|
|
||||||
for (MethodReference methodRef : testMethods) {
|
|
||||||
dependencyChecker.addEntryPoint(methodRef);
|
dependencyChecker.addEntryPoint(methodRef);
|
||||||
}
|
|
||||||
dependencyChecker.checkDependencies();
|
dependencyChecker.checkDependencies();
|
||||||
ListableClassHolderSource classSet = dependencyChecker.cutUnachievableClasses();
|
ListableClassHolderSource classSet = dependencyChecker.cutUnachievableClasses();
|
||||||
ClassSetOptimizer optimizer = new ClassSetOptimizer();
|
ClassSetOptimizer optimizer = new ClassSetOptimizer();
|
||||||
optimizer.optimizeAll(classSet);
|
optimizer.optimizeAll(classSet);
|
||||||
decompileClasses(classSet.getClassNames());
|
|
||||||
renderHead();
|
|
||||||
ClassLoader classLoader = ClasslibTestGenerator.class.getClassLoader();
|
|
||||||
try (InputStream input = classLoader.getResourceAsStream("org/teavm/classlib/junit-support.js")) {
|
|
||||||
out.println(IOUtils.toString(input));
|
|
||||||
}
|
|
||||||
try (InputStream input = classLoader.getResourceAsStream("org/teavm/javascript/runtime.js")) {
|
|
||||||
out.println(IOUtils.toString(input));
|
|
||||||
}
|
|
||||||
renderer.renderRuntime();
|
renderer.renderRuntime();
|
||||||
writer.append("runTests = function() {").newLine().indent();
|
decompileClasses(classSet.getClassNames());
|
||||||
writer.append("document.getElementById(\"start-button\").style.display = 'none';").newLine();
|
try (Writer out = new OutputStreamWriter(new FileOutputStream(new File(outputDir, targetName)), "UTF-8")) {
|
||||||
for (String testClass : testClasses) {
|
out.write(writer.toString());
|
||||||
renderClassTest(classSource.getClassHolder(testClass));
|
|
||||||
}
|
}
|
||||||
writer.outdent().append("}").newLine();
|
|
||||||
out.println(writer);
|
|
||||||
renderFoot();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void decompileClasses(Collection<String> classNames) {
|
private static void decompileClasses(Collection<String> classNames) {
|
||||||
|
@ -91,39 +85,6 @@ public class ClasslibTestGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void renderHead() {
|
|
||||||
out.println("<!DOCTYPE html>");
|
|
||||||
out.println("<html>");
|
|
||||||
out.println(" <head>");
|
|
||||||
out.println(" <title>TeaVM JUnit tests</title>");
|
|
||||||
out.println(" <meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/>");
|
|
||||||
out.println(" <title>TeaVM JUnit tests</title>");
|
|
||||||
out.println(" <style type=\"text/css\">");
|
|
||||||
out.println(" table {");
|
|
||||||
out.println(" border-collapse: collapse;");
|
|
||||||
out.println(" border: 2px solid black;");
|
|
||||||
out.println(" margin: 2em 1em 2em 1em;");
|
|
||||||
out.println(" }");
|
|
||||||
out.println(" table td, table th {");
|
|
||||||
out.println(" border: 1px solid gray;");
|
|
||||||
out.println(" padding: 0.1em 0.5em 0.2em 0.5em;");
|
|
||||||
out.println(" }");
|
|
||||||
out.println(" table thead, table tfoot {");
|
|
||||||
out.println(" border: 2px solid black;");
|
|
||||||
out.println(" }");
|
|
||||||
out.println(" </style>");
|
|
||||||
out.println(" </head>");
|
|
||||||
out.println(" <body>");
|
|
||||||
out.println(" <script type=\"text/javascript\">");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void renderFoot() {
|
|
||||||
out.println(" </script>");
|
|
||||||
out.println(" <button id=\"start-button\" onclick=\"runTests()\">Run tests</button>");
|
|
||||||
out.println(" </body>");
|
|
||||||
out.println("</html>");
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void renderClassTest(ClassHolder cls) {
|
private static void renderClassTest(ClassHolder cls) {
|
||||||
List<MethodReference> methods = groupedMethods.get(cls.getName());
|
List<MethodReference> methods = groupedMethods.get(cls.getName());
|
||||||
writer.append("testClass(\"" + cls.getName() + "\", function() {").newLine().indent();
|
writer.append("testClass(\"" + cls.getName() + "\", function() {").newLine().indent();
|
||||||
|
@ -159,4 +120,12 @@ public class ClasslibTestGenerator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void resourceToFile(String resource, String fileName) throws IOException {
|
||||||
|
try (InputStream input = ClasslibTestGenerator.class.getClassLoader().getResourceAsStream(resource)) {
|
||||||
|
try (OutputStream output = new FileOutputStream(new File(outputDir, fileName))) {
|
||||||
|
IOUtils.copy(input, output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,114 +1,135 @@
|
||||||
currentTestReportBody = null;
|
JUnitServer = function(container) {
|
||||||
currentTimeSpent = 0;
|
this.container = container;
|
||||||
totalTimeSpent = 0;
|
this.timeSpent = 0;
|
||||||
currentMethodCount = 0;
|
this.totalTimeSpent = 0;
|
||||||
currentStatusCell = null;
|
this.methodCount = 0;
|
||||||
currentExceptionCell = null;
|
this.statusCell = null;
|
||||||
currentTimeCell = null;
|
this.exceptionCell = null;
|
||||||
currentStartTime = 0;
|
this.timeCell = null;
|
||||||
currentExpectedExceptions = [];
|
this.startTime = 0;
|
||||||
currentFrame = null;
|
this.expectedExceptions = [];
|
||||||
|
this.table = null;
|
||||||
window.addEventListener("message", function(event) {
|
this.tableBody = null;
|
||||||
endTime = new Date().getTime();
|
this.frame = null;
|
||||||
var message = JSON.parse(event.data);
|
|
||||||
if (message.status == "ok") {
|
|
||||||
if (currentExpectedExceptions.length > 0) {
|
|
||||||
currentStatusCell.appendChild(document.createTextNode("expected exception not thrown"));
|
|
||||||
currentStatusCell.style.color = 'yellow';
|
|
||||||
} else {
|
|
||||||
currentStatusCell.appendChild(document.createTextNode("ok"));
|
|
||||||
currentStatusCell.style.color = 'green';
|
|
||||||
}
|
}
|
||||||
} else if (message.status == "exception") {
|
JUnitServer.prototype = new Object();
|
||||||
if (isExpectedException(e)) {
|
JUnitServer.prototype.handleEvent = function(message, callback) {
|
||||||
currentStatusCell.appendChild(document.createTextNode("ok"));
|
endTime = new Date().getTime();
|
||||||
currentStatusCell.style.color = 'green';
|
if (message.status === "ok") {
|
||||||
|
if (this.expectedExceptions.length > 0) {
|
||||||
|
this.statusCell.appendChild(document.createTextNode("expected exception not thrown"));
|
||||||
|
this.statusCell.style.color = 'yellow';
|
||||||
} else {
|
} else {
|
||||||
currentStatusCell.appendChild(document.createTextNode("unexpected exception"));
|
this.statusCell.appendChild(document.createTextNode("ok"));
|
||||||
|
this.statusCell.style.color = 'green';
|
||||||
|
}
|
||||||
|
} else if (message.status === "exception") {
|
||||||
|
if (message.exception && this.isExpectedException(message.exception)) {
|
||||||
|
this.statusCell.appendChild(document.createTextNode("ok"));
|
||||||
|
this.statusCell.style.color = 'green';
|
||||||
|
} else {
|
||||||
|
this.statusCell.appendChild(document.createTextNode("unexpected exception"));
|
||||||
var exceptionText = document.createElement("pre");
|
var exceptionText = document.createElement("pre");
|
||||||
exceptionText.appendChild(document.createTextNode(e.stack));
|
exceptionText.appendChild(document.createTextNode(message.stack));
|
||||||
currentExceptionCell.appendChild(exceptionText);
|
this.exceptionCell.appendChild(exceptionText);
|
||||||
currentStatusCell.style.color = 'red';
|
this.statusCell.style.color = 'red';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
++currentMethodCount;
|
++this.methodCount;
|
||||||
var timeSpent = (endTime - currentStartTime) / 1000;
|
var timeSpent = (endTime - this.startTime) / 1000;
|
||||||
currentTimeSpent += timeSpent;
|
this.timeSpent += timeSpent;
|
||||||
currentTimeCell.appendChild(document.createTextNode(timeSpent.toFixed(3)));
|
this.timeCell.appendChild(document.createTextNode(timeSpent.toFixed(3)));
|
||||||
document.body.removeChild(currentFrame);
|
document.body.removeChild(this.frame);
|
||||||
}, false);
|
self.frame = null;
|
||||||
|
callback();
|
||||||
runTestCase = function(methodName, path, expectedExceptions) {
|
|
||||||
var row = document.createElement("tr");
|
|
||||||
currentTestReportBody.appendChild(row);
|
|
||||||
var nameCell = document.createElement("td");
|
|
||||||
row.appendChild(nameCell);
|
|
||||||
nameCell.appendChild(document.createTextNode(methodName));
|
|
||||||
currentStatusCell = document.createElement("td");
|
|
||||||
row.appendChild(currentStatusCell);
|
|
||||||
currentExceptionCell = document.createElement("td");
|
|
||||||
row.appendChild(currentExceptionCell);
|
|
||||||
currentTimeCell = document.createElement("td");
|
|
||||||
row.appendChild(currentTimeCell);
|
|
||||||
currentStartTime = new Date().getTime();
|
|
||||||
currentExpectedExceptions = expectedExceptions;
|
|
||||||
var frame = document.createElement("iframe");
|
|
||||||
cirremtFrame = frame;
|
|
||||||
document.body.appendChild(frame);
|
|
||||||
var frameDoc = frame.contentWindow.document;
|
|
||||||
var frameScript = frameDoc.createElement("script");
|
|
||||||
frameScript.src = path;
|
|
||||||
frameDoc.body.appendChild(frameScript);
|
|
||||||
endTime = new Date().getTime();
|
|
||||||
if (expectedExceptions.length > 0) {
|
|
||||||
statusCell.appendChild(document.createTextNode("expected exception not thrown"));
|
|
||||||
statusCell.style.color = 'yellow';
|
|
||||||
} else {
|
|
||||||
statusCell.appendChild(document.createTextNode("ok"));
|
|
||||||
statusCell.style.color = 'green';
|
|
||||||
}
|
}
|
||||||
} catch (e) {
|
JUnitServer.prototype.isExpectedException = function(ex) {
|
||||||
endTime = new Date().getTime();
|
for (var i = 0; i < this.expectedExceptions.length; ++i) {
|
||||||
if (isExpectedException(e, expectedExceptions)) {
|
if (this.expectedExceptions[i] === ex) {
|
||||||
statusCell.appendChild(document.createTextNode("ok"));
|
|
||||||
statusCell.style.color = 'green';
|
|
||||||
} else {
|
|
||||||
statusCell.appendChild(document.createTextNode("unexpected exception"));
|
|
||||||
var exceptionText = document.createElement("pre");
|
|
||||||
exceptionText.appendChild(document.createTextNode(e.stack));
|
|
||||||
exceptionCell.appendChild(exceptionText);
|
|
||||||
statusCell.style.color = 'red';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
++currentMethodCount;
|
|
||||||
var timeSpent = (endTime - startTime) / 1000;
|
|
||||||
currentTimeSpent += timeSpent;
|
|
||||||
timeCell.appendChild(document.createTextNode(timeSpent.toFixed(3)));
|
|
||||||
}
|
|
||||||
|
|
||||||
isExpectedException = function(e) {
|
|
||||||
if (e.javaException !== undefined) {
|
|
||||||
for (var i = 0; i < currentExpectedExceptions.length; ++i) {
|
|
||||||
if (currentExpectedExceptions[i] === e.javaException) {
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
JUnitServer.prototype.runTestCase = function(methodName, path, expectedExceptions, callback) {
|
||||||
testClass = function(className, classTests) {
|
this.createRow(methodName);
|
||||||
currentTimeSpent = 0;
|
this.startTime = new Date().getTime();
|
||||||
currentMethodCount = 0;
|
this.expectedExceptions = expectedExceptions;
|
||||||
var table = document.createElement("table");
|
var self = this;
|
||||||
document.body.appendChild(table);
|
this.loadCode(path, function() {
|
||||||
|
messageHandler = function(event) {
|
||||||
|
window.removeEventListener("message", messageHandler);
|
||||||
|
self.handleEvent(JSON.parse(event.data), callback);
|
||||||
|
};
|
||||||
|
window.addEventListener("message", messageHandler);
|
||||||
|
self.frame.contentWindow.postMessage("runTest", "*");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
JUnitServer.prototype.createRow = function(methodName) {
|
||||||
|
var row = document.createElement("tr");
|
||||||
|
this.tableBody.appendChild(row);
|
||||||
|
var nameCell = document.createElement("td");
|
||||||
|
row.appendChild(nameCell);
|
||||||
|
nameCell.appendChild(document.createTextNode(methodName));
|
||||||
|
this.statusCell = document.createElement("td");
|
||||||
|
row.appendChild(this.statusCell);
|
||||||
|
this.exceptionCell = document.createElement("td");
|
||||||
|
row.appendChild(this.exceptionCell);
|
||||||
|
this.timeCell = document.createElement("td");
|
||||||
|
row.appendChild(this.timeCell);
|
||||||
|
}
|
||||||
|
JUnitServer.prototype.loadCode = function(path, callback) {
|
||||||
|
this.frame = document.createElement("iframe");
|
||||||
|
document.body.appendChild(this.frame);
|
||||||
|
var frameDoc = this.frame.contentWindow.document;
|
||||||
|
var self = this;
|
||||||
|
this.loadScript("junit-support.js", function() {
|
||||||
|
self.loadScript("runtime.js", function() {
|
||||||
|
self.loadScript(path, callback);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
JUnitServer.prototype.loadScript = function(name, callback) {
|
||||||
|
var doc = this.frame.contentWindow.document;
|
||||||
|
var script = doc.createElement("script");
|
||||||
|
script.src = name;
|
||||||
|
doc.body.appendChild(script);
|
||||||
|
script.onload = function() {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JUnitServer.prototype.runTest = function(test, callback) {
|
||||||
|
this.timeSpent = 0;
|
||||||
|
this.methodCount = 0;
|
||||||
|
this.createTable(test.name);
|
||||||
|
this.runMethodFromList(test.methods, 0, function() {
|
||||||
|
callback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
JUnitServer.prototype.runMethodFromList = function(methods, index, callback) {
|
||||||
|
if (index < methods.length) {
|
||||||
|
var method = methods[index];
|
||||||
|
var self = this;
|
||||||
|
this.runTestCase(method.name, method.script, method.expected, function() {
|
||||||
|
self.runMethodFromList(methods, index + 1, callback);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
callback();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JUnitServer.prototype.createTable = function(name) {
|
||||||
|
this.table = document.createElement("table");
|
||||||
|
this.container.appendChild(this.table);
|
||||||
var caption = document.createElement("caption");
|
var caption = document.createElement("caption");
|
||||||
table.appendChild(caption);
|
this.table.appendChild(caption);
|
||||||
caption.appendChild(document.createTextNode(className));
|
this.createHeader();
|
||||||
|
caption.appendChild(document.createTextNode(name));
|
||||||
|
this.tableBody = document.createElement("tbody");
|
||||||
|
this.table.appendChild(this.tableBody);
|
||||||
|
}
|
||||||
|
JUnitServer.prototype.createHeader = function() {
|
||||||
var head = document.createElement("thead");
|
var head = document.createElement("thead");
|
||||||
table.appendChild(head);
|
this.table.appendChild(head);
|
||||||
var headRow = document.createElement("tr");
|
var headRow = document.createElement("tr");
|
||||||
head.appendChild(headRow);
|
head.appendChild(headRow);
|
||||||
var headCell = document.createElement("th");
|
var headCell = document.createElement("th");
|
||||||
|
@ -123,14 +144,11 @@ testClass = function(className, classTests) {
|
||||||
headCell = document.createElement("th");
|
headCell = document.createElement("th");
|
||||||
headRow.appendChild(headCell);
|
headRow.appendChild(headCell);
|
||||||
headCell.appendChild(document.createTextNode("Time spent, s"));
|
headCell.appendChild(document.createTextNode("Time spent, s"));
|
||||||
|
this.table.appendChild(head);
|
||||||
var tbody = document.createElement("tbody");
|
}
|
||||||
table.appendChild(tbody);
|
JUnitServer.prototype.createFooter = function() {
|
||||||
currentTestReportBody = tbody;
|
|
||||||
classTests();
|
|
||||||
|
|
||||||
var foot = document.createElement("tfoot");
|
var foot = document.createElement("tfoot");
|
||||||
table.appendChild(foot);
|
this.table.appendChild(foot);
|
||||||
var footRow = document.createElement("tr");
|
var footRow = document.createElement("tr");
|
||||||
foot.appendChild(footRow);
|
foot.appendChild(footRow);
|
||||||
var footName = document.createElement("td");
|
var footName = document.createElement("td");
|
||||||
|
@ -138,14 +156,30 @@ testClass = function(className, classTests) {
|
||||||
footName.appendChild(document.createTextNode("---"));
|
footName.appendChild(document.createTextNode("---"));
|
||||||
var footMethods = document.createElement("td");
|
var footMethods = document.createElement("td");
|
||||||
footRow.appendChild(footMethods);
|
footRow.appendChild(footMethods);
|
||||||
footMethods.appendChild(document.createTextNode(currentMethodCount));
|
footMethods.appendChild(document.createTextNode(this.methodCount));
|
||||||
var footSpace = document.createElement("td");
|
var footSpace = document.createElement("td");
|
||||||
footRow.appendChild(footSpace);
|
footRow.appendChild(footSpace);
|
||||||
footSpace.appendChild(document.createTextNode("---"));
|
footSpace.appendChild(document.createTextNode("---"));
|
||||||
var footTime = document.createElement("td");
|
var footTime = document.createElement("td");
|
||||||
footRow.appendChild(footTime);
|
footRow.appendChild(footTime);
|
||||||
footTime.appendChild(document.createTextNode(currentTimeSpent.toFixed(3)));
|
footTime.appendChild(document.createTextNode(this.timeSpent.toFixed(3)));
|
||||||
totalTimeSpent += currentTimeSpent;
|
}
|
||||||
|
|
||||||
currentTestReportBody = null;
|
JUnitClient = {};
|
||||||
|
JUnitClient.run = function(runner) {
|
||||||
|
var handler = window.addEventListener("message", function() {
|
||||||
|
window.removeEventListener("message", handler);
|
||||||
|
var message = {};
|
||||||
|
try {
|
||||||
|
runner();
|
||||||
|
message.status = "ok";
|
||||||
|
} catch (e) {
|
||||||
|
message.status = "exception";
|
||||||
|
if (e.$javaException && e.$javaException.$class && e.$javaException.$class.$meta) {
|
||||||
|
message.exception = e.$javaException.$class.$meta.name;
|
||||||
|
}
|
||||||
|
message.stack = e.stack;
|
||||||
|
}
|
||||||
|
window.parent.postMessage(JSON.stringify(message), "*");
|
||||||
|
});
|
||||||
}
|
}
|
|
@ -11,6 +11,7 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function runTests() {
|
function runTests() {
|
||||||
document.getElementById("start-button").style.display = "none";
|
document.getElementById("start-button").style.display = "none";
|
||||||
|
doRunTests();
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<button id="start-button" onclick="runTests()">Run tests</button>
|
<button id="start-button" onclick="runTests()">Run tests</button>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user