Skip to content
Browse files

more phantomjs goo

  • Loading branch information...
1 parent b9c285a commit 613987bc847b9f8aab772722193114d3a2f0b6cc @zzo committed Nov 9, 2011
View
2 backend/nodejute/jute/actions/common.js
@@ -138,6 +138,8 @@ module.exports = {
output = '',
format;
+ if (!test) return;
+
format = now.getFullYear() + '/' + (now.getMonth() + 1) + '/' + now.getDate() + ' ' + now.getHours() + ':' + now.getMinutes() + ':' + now.getSeconds();
lines.forEach(function(line) {
output += '[' + format + '] ' + line + "\n";
View
2 backend/nodejute/jute/actions/getTest.js
@@ -83,6 +83,7 @@ module.exports = {
// Otherwise start running this test in capture mode!!
common.addTestOutput(test, "To browser " + bName);
test.running = now;
+ cache.currentTest[browser] = test;
testURL = test.url;
break;
}
@@ -92,6 +93,7 @@ module.exports = {
res.end(JSON.stringify({ testLocation: testURL }));
hub.emit(hub.LOG, hub.INFO, "Sent test url: " + testURL + ' to ' + bName);
} else {
+ delete cache.currentTest[browser];
// find all local tests
var find = require('npm/lib/utils/find'),
prefix = hub.config.testDir,
View
10 backend/nodejute/jute/actions/runTest.js
@@ -106,7 +106,7 @@ module.exports = {
// Generate Selenium IDs
if (obj.sel_host || obj.phantomjs) {
- var seleniums = parseInt(obj.seleniums, 10) || 1;
+ var seleniums = parseInt(obj.seleniums, 10) || parseInt(obj.parallel, 10) || 1;
for (var i = 0; i < seleniums; i++) {
seleniumIDs.push(uuid());
}
@@ -157,6 +157,12 @@ module.exports = {
cache.tests_to_run.push(test_obj);
pushed = true;
} else if (obj.phantomjs) {
+ if (obj.phantomjs == 1) {
+ obj.phantomjs = hub.config.phantomjs;
+ if (!obj.screen) {
+ obj.screen = hub.config.screen;
+ }
+ }
test_obj.phantomjs = obj.phantomjs;
if (obj.send_output) {
test_obj.sendOutput = 1;
@@ -175,7 +181,7 @@ module.exports = {
cache.tests_to_run.push(test_obj);
pushed = true;
- }else {
+ } else {
if (multipleFromUI) {
// Only run these tests in THIS browser from the UI
View
11 backend/nodejute/jute/actions/startPhantomjs.js
@@ -35,7 +35,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
module.exports = {
- Create: function(hub) {
+ Create: function(hub, common) {
// Javascript is single threaded! We don't have to worry about concurrency!
var path = require('path'),
sys = require('sys'),
@@ -55,12 +55,17 @@ module.exports = {
try {
hub.emit(hub.LOG, hub.INFO, "DISPLAY=:" + screen + ' ' + phantomjs + ' ' + path.join(__dirname, '..', "phantomJUTE.js") + ' ' + url);
process.env.DISPLAY = ':' + screen;
- phantom = child.spawn(phantomjs, [ path.join(__dirname, '..', "phantomJUTE.js"), url]);
+ phantom = child.spawn(phantomjs, [ path.join(__dirname, '..', "phantomJUTE.js"), url, hub.config.outputDir]);
phantom.stdout.on('data', function(data) {
+ if (data === 'snapshot') {
+ hub.emit(hub.LOG, hub.INFO, "SNAPSHOT!");
+ }
hub.emit(hub.LOG, hub.INFO, "PhantomJS sez: " + data);
+ common.addTestOutput(cache.currentTest[selID], 'PhantomJS console: ' + data);
});
phantom.stderr.on('data', function(data) {
- hub.emit(hub.LOG, hub.INFO, "PhantomJS stderr: " + data);
+ hub.emit(hub.LOG, hub.ERROR, "PhantomJS stderr: " + data);
+ common.addTestOutput(cache.currentTest[selID], 'PhantomJS error: ' + data);
});
phantom.on('exit', function() {
if (!phantom.done) {
View
2 backend/nodejute/jute/configure.js
@@ -52,6 +52,8 @@ Create: function(hub) {
logFormat: '',
testRegex: '.html$',
inject: 1,
+ screen: 0,
+ phantomjs: '/usr/local/bin/phantomjs',
host: ''
},
exec = require('child_process').exec,
View
4 backend/nodejute/jute/jute_docs/jute_client.js
@@ -5,6 +5,10 @@ YUI().add('jute', function(Y) {
var cover_out = Y.Test.Runner.getCoverage(Y.Coverage.Format.JSON),
report_data = Y.Test.Format.JUnitXML(data.results);
+ Y.Global.fire('testDone', data);
+ if (typeof(console) == 'object') {
+ console.log("JUTE TestDone " + data.results.name);
+ }
Y.io('/jute/_test_report',
{
method: 'PUT',
View
20 backend/nodejute/jute/phantomJUTE.js
@@ -34,14 +34,24 @@ function waitFor(testFx, onReady, timeOutMillis) {
};
-var page = new WebPage();
+var page = new WebPage(), outputDir = phantom.args[1];
page.onAlert = function(msg) { console.log("ALERT: " + msg); };
-page.onConsoleMessage = function (msg) { console.log("CONSOLE: " + msg); };
-#page.onResourceRequested = function (msg) { console.log("Request: " + msg.url); };
-#page.onResourceReceived = function (msg) { console.log("Received: " + msg.url); };
+page.onConsoleMessage = function (msg) {
+ var matches = msg.match(/JUTE TestDone (.+)/);
+ if (matches != null) {
+ setTimeout(function() {
+ page.render(outputDir + '/' + matches[1] + '/phantomjs_snap.png');
+ }, 100);
+ } else {
+ console.log(msg);
+ }
+};
+
+//page.onResourceRequested = function (msg) { console.log("Request: " + msg.url); };
+//page.onResourceReceived = function (msg) { console.log("Received: " + msg.url); };
-// Open Twitter on 'sencha' profile and, onPageLoad, do...
+// Open to JUTE & wait - JUTE will kill us when we're done
page.open(phantom.args[0], function (status) {
// Check for page load success
if (status !== "success") {
View
2 backend/nodejute/jute_backend.js
@@ -53,7 +53,7 @@ sys.inherits(eventHubF, events.EventEmitter);
var eventHub = new eventHubF();
// Prime cache
-eventHub.cache = { browsers: {}, tests_to_run: [], connections: {} };
+eventHub.cache = { browsers: {}, tests_to_run: [], connections: {}, currentTest: {} };
configure.Create(eventHub);
actions.Create(eventHub, common.Create(eventHub));

0 comments on commit 613987b

Please sign in to comment.
Something went wrong with that request. Please try again.