Skip to content

Commit

Permalink
update quint-runner with latest work from ember.js and add travis.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tchak committed Apr 1, 2012
1 parent 79cf874 commit 67b5b0d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 36 deletions.
8 changes: 8 additions & 0 deletions .travis.yml
@@ -0,0 +1,8 @@
rvm:
- 1.9.3
bundler_args: --without development
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
- "rake clean"
script: "rake test[all]"
8 changes: 6 additions & 2 deletions Rakefile
Expand Up @@ -49,8 +49,12 @@ task :test, [:suite] => :dist do |t, args|
"package=all&dist=build&nojshint=true"]
}

suite = args[:suite] || :default
opts = suites[suite.to_sym]
if ENV['TEST']
opts = [ENV['TEST']]
else
suite = args[:suite] || :default
opts = suites[suite.to_sym]
end

unless opts
abort "No suite named: #{suite}"
Expand Down
65 changes: 31 additions & 34 deletions tests/qunit/run-qunit.js
@@ -1,56 +1,49 @@
// PhantomJS QUnit Test Runner

var args = phantom.args;

if (args.length < 1 || args.length > 2) {
console.log("Usage: " + phantom.scriptName + " <URL> <timeout>");
phantom.exit(1);
}

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

var depRe = /^DEPRECATION:/;
page.onConsoleMessage = function(msg) {
if (!/^DEPRECATION:/.test(msg)) console.log(msg);
if (!depRe.test(msg)) 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);

var timeout = parseInt(args[1] || 30000, 10);
var start = Date.now();
var interval = setInterval(function() {
if (Date.now() > start + timeout) {
console.error("Tests timed out");
phantom.exit(1);
} else {
var qunitDone = page.evaluate(function() {
return window.qunitDone;
});

if (qunitDone) {
clearInterval(interval);
if (qunitDone.failed > 0) {
phantom.exit(1);
} else {
phantom.exit();
}
}
}
}, 500);
}

page.evaluate(addLogging);

var timeout = parseInt(args[1] || 30000);
var start = Date.now();

var interval = setInterval(function() {
if (Date.now() > start + timeout) {
console.error("Tests timed out");
phantom.exit(1);
}

if (isDone()) {
clearInterval(interval);
if (didFail()) phantom.exit(1);
phantom.exit();
}
}, 500);
});

function isDone() {
return page.evaluate(function() {
return !!window.qunitDone;
});
}

function didFail() {
var output = page.evaluate(function() {
return window.qunitDone;
});
return output && output.failed > 0;
}

function addLogging() {
var testErrors = [];
var assertionErrors = [];
Expand All @@ -74,7 +67,11 @@ function addLogging() {
QUnit.log(function(context) {
if (context.result) return;

var msg = "\n Assertion Failed: " + (context.message || "");
var msg = "\n Assertion Failed:";
if (context.message) {
msg += " " + context.message;
}

if (context.expected) {
msg += "\n Expected: " + context.expected + ", Actual: " + context.actual;
}
Expand Down

0 comments on commit 67b5b0d

Please sign in to comment.