Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}, function(){
var nodes = apf.queryNodes(fileNode, "test[@status=0 or error]");
if (_self.stopping) {
testpanel.setError(fileNode, "Test Cancelled");
return;
}
else if (nodes.length)
testpanel.setError(fileNode, "failed " + (nodes.length) + " tests of " + tests.length);
else
testpanel.setPass(fileNode, tests.length + " of " + tests.length);
_self.running = false;
callback();
});
},
function completed(){
var nodes = apf.queryNodes(fileNode, "test[@status=0 or error]");
if (_self.stopping) {
testpanel.setError(fileNode, "Test Cancelled");
return;
}
else if (nodes.length)
testpanel.setError(fileNode, "Failed " + (nodes.length)
+ " tests of " + fileNode.selectNodes("test").length);
else
testpanel.setPass(fileNode,
"(" + fileNode.selectNodes("test").length + ")");
}
apf.asyncForEach(tests, function(name, nextTest, i){
if (_self.stopping) {
testpanel.setError(fileNode, "Test Cancelled");
_self.stopped();
return;
}
var actions = testObject[name];
var script = sp.compile(actions);
var testNode = nodes[i];
var actionIndex = -1;
var assertIndex = -1;
_self.lastTestNode = testNode;
testpanel.setLog(fileNode, "running test " + (i + 1) + " of " + tests.length);
testpanel.setLog(testNode, "connecting...");
var data = {
if (actionNode) {
var actionName = actionNode.getAttribute("name");
if ((_self.actionLookup[actionName] || actionName)
== (_self.actionLookup[msg.cmd] || msg.cmd)) {
testpanel.setExecute(actionNode);
actionIndex++;
assertIndex = -1;
}
}
case 3: //LOG
testpanel.setLog(testNode, "command '"
+ (msg.out || msg.cmd) + "'");
break;
case 4:
if (testNode.selectSingleNode("error|assert[@status=0]"))
testpanel.setError(testNode, "Test Failed");
else
testpanel.setPass(testNode);
testpanel.setExecute();
apf.xmldb.setAttribute(fileNode, "video", msg.video);
//Small hack
if (self.dgTestProject)
dgTestProject.reselect(); //Due to apf bug
if (self.dgUiRecorder)
dgUiRecorder.reselect(); //Due to apf bug
ide.removeEventListener("socketMessage", arguments.callee);
nextTest();
break;
ide.addEventListener("socketMessage", function(e){
if (e.message.subtype == "selenium") {
var msg = e.message.body;
switch (msg.type) {
case 0:
testpanel.setError(testNode, msg.err);
testpanel.setError(fileNode, msg.err);
ide.removeEventListener("socketMessage", arguments.callee);
if (_self.stopping)
_self.stopped();
else {
_self.running = false;
callback();
}
break;
case 1: //PASS .data[input | match]
var assertNode;
var actions = testNode.selectNodes("action");
if (actions.length) {
var actionNode = actions[actionIndex];
var asserts = actionNode.selectNodes("assert");
if (!assertNode) {
assertNode = testNode.ownerDocument
.createElement("assert");
assertNode.setAttribute("name",
msg.data.input + " == " + msg.data.match);
assertNode.setAttribute("input",
msg.data.input);
assertNode.setAttribute("match",
msg.data.match);
apf.xmldb.appendChild(testNode, assertNode);
}
}
if (assertNode)
testpanel.setError(assertNode, "Got: "
+ msg.data.measured);
break;
case 6: //CMD
var actions = testNode.selectNodes("action");
var actionNode = actions.length && actions[actionIndex+1];
if (actionNode) {
var actionName = actionNode.getAttribute("name");
if ((_self.actionLookup[actionName] || actionName)
== (_self.actionLookup[msg.cmd] || msg.cmd)) {
testpanel.setExecute(actionNode);
actionIndex++;
assertIndex = -1;
}
}
case 3: //LOG
testpanel.setLog(testNode, "command '"
ide.addEventListener("socketMessage", function(e){
if (e.message.subtype == "selenium") {
var msg = e.message.body;
switch (msg.type) {
case 0:
testpanel.setError(testNode, msg.err);
testpanel.setError(fileNode, msg.err);
ide.removeEventListener("socketMessage", arguments.callee);
if (_self.stopping)
_self.stopped();
else {
_self.running = false;
callback();
}
break;
case 1: //PASS .data[input | match]
var assertNode;
var actions = testNode.selectNodes("action");
if (actions.length) {
var actionNode = actions[actionIndex];
function completed(){
var nodes = apf.queryNodes(fileNode, "test[@status=0 or error]");
if (_self.stopping) {
testpanel.setError(fileNode, "Test Cancelled");
return;
}
else if (nodes.length)
testpanel.setError(fileNode, "Failed " + (nodes.length)
+ " tests of " + fileNode.selectNodes("test").length);
else
testpanel.setPass(fileNode,
"(" + fileNode.selectNodes("test").length + ")");
}
ide.addEventListener("socketMessage", function(e){
//@todo testpanel.setLog(node, "started");
if (e.message.type == "node-data") {
parseMessage(e.message);
}
else if (e.message.type.indexOf("node-exit") > -1) {
ide.removeEventListener("socketMessage", arguments.callee);
if (_self.stopping)
_self.stopped();
else {
_self.running = false;
if (fileNode.getAttribute("status") == -1)
testpanel.setError(fileNode, "failed");
if (!stProcessRunning.active)
next();
else {
stProcessRunning.addEventListener("deactivate", function(){
next();
stProcessRunning.removeEventListener("deactivate", arguments.callee);
});
}
}
}
});
var part = parts[i];
//FAIL
if (part.substr(0, 3) == "[31") {
match = part.match(/^\[31m\[(\d+)\/(\d+)\]\s+(.*?)\s+FAIL.*([\S\s]*?)(?=\[\d+m|$)/);
if(!match)
continue;
var testNode = fileNode.selectSingleNode("test[@name=" + escapeXpathString(match[3]) + "]");
if (!testNode) {
var doc = fileNode.ownerDocument;
testNode = doc.createElement("test");
testNode.setAttribute("name", match[3]);
apf.xmldb.appendChild(fileNode, testNode);
}
//fileNode.addNode();
testpanel.setError(testNode, "Test Failed");
testpanel.setLog(fileNode, "completed test " + match[2] + " of " + match[1]);
var errorNode = testNode.ownerDocument
.createElement("error");
errorNode.setAttribute("name", match[4]);
apf.xmldb.appendChild(testNode, errorNode);
if (match[2] == match[1])
completed();
}
//PASS
//[32m[4/1] test basic addition OK[0m
else if (part.substr(0, 3) == "[32") {
match = part.match(/^\[32m\[(\d+)\/(\d+)\]\s+(.*?)\sOK[\s\S]{4,6}/);
if(!match)
continue;