Permalink
Browse files

update quint-runner with latest work from ember.js and add travis.yml

  • Loading branch information...
tchak committed Apr 1, 2012
1 parent 79cf874 commit 67b5b0d0c0365acba306bb7a982211b93dd79133
Showing with 45 additions and 36 deletions.
  1. +8 −0 .travis.yml
  2. +6 −2 Rakefile
  3. +31 −34 tests/qunit/run-qunit.js
View
@@ -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]"
View
@@ -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}"
View
@@ -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 = [];
@@ -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;
}

0 comments on commit 67b5b0d

Please sign in to comment.