Skip to content

Commit

Permalink
Merge pull request #237 from tchak/update-build-tools
Browse files Browse the repository at this point in the history
Backport some fixes for qunit runner from Ember.js
  • Loading branch information
wycats committed May 2, 2012
2 parents de04663 + 7016bc9 commit 474c0ca
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions tests/qunit/run-qunit.js
@@ -1,5 +1,7 @@
// PhantomJS QUnit Test Runner

/*globals QUnit phantom*/

var args = phantom.args;
if (args.length < 1 || args.length > 2) {
console.log("Usage: " + phantom.scriptName + " <URL> <timeout>");
Expand All @@ -8,24 +10,24 @@ if (args.length < 1 || args.length > 2) {

var page = require('webpage').create();

var depRe = /^DEPRECATION:/;
page.onConsoleMessage = function(msg) {
if (!depRe.test(msg)) console.log(msg);
if (msg.slice(0,8) === 'WARNING:') { return; }
console.log(msg);
};

page.open(args[0], function(status) {
if (status !== 'success') {
console.error("Unable to access network");
phantom.exit(1);
} else {
page.evaluate(addLogging);
page.evaluate(logQUnit);

var timeout = parseInt(args[1] || 30000, 10);
var timeout = parseInt(args[1] || 60000, 10);
var start = Date.now();
var interval = setInterval(function() {
if (Date.now() > start + timeout) {
console.error("Tests timed out");
phantom.exit(1);
phantom.exit(124);
} else {
var qunitDone = page.evaluate(function() {
return window.qunitDone;
Expand All @@ -44,10 +46,12 @@ page.open(args[0], function(status) {
}
});

function addLogging() {
function logQUnit() {
var testErrors = [];
var assertionErrors = [];

console.log("Running: " + JSON.stringify(QUnit.urlParams));

QUnit.moduleDone(function(context) {
if (context.failed) {
var msg = "Module Failed: " + context.name + "\n" + testErrors.join("\n");
Expand Down

0 comments on commit 474c0ca

Please sign in to comment.