Permalink
Browse files

near working travis integration

  • Loading branch information...
1 parent 82214a1 commit d0f172a24509098eb529aaf1f1874298d7f4a8ec @ded committed Feb 16, 2014
Showing with 59 additions and 5 deletions.
  1. +10 −0 .travis.yml
  2. +0 −4 make/tests.js
  3. +1 −1 package.json
  4. +33 −0 phantom.js
  5. +15 −0 test.js
  6. BIN vendor/phantomjs
View
@@ -0,0 +1,10 @@
+language: node_js
+node_js:
+ - "0.10"
+notifications:
+ email:
+ - dustin@dustindiaz.com
+before_script:
+ - node make/tests.js &
+
+script: phantomjs ./phantom.js
View
@@ -83,7 +83,3 @@ var otherOriginRoutes = {
}
Connect.createServer(Connect.query(), dispatch(otherOriginRoutes)).listen(5678)
-
-exec('open http://localhost:1234', function () {
- console.log('opening tests at http://localhost:1234')
-})
View
@@ -31,6 +31,6 @@
},
"scripts": {
"boosh": "smoosh make ./build.json",
- "test": "node make/tests.js"
+ "test": "node ./test.js"
}
}
View
@@ -0,0 +1,33 @@
+var page = require('webpage').create()
+page.open('http://localhost:1234', function() {
+
+ function f() {
+ setTimeout(function () {
+ var clsName = page.evaluate(function() {
+ var el = document.getElementById('tests')
+ return el.className
+ })
+ if (!clsName.match(/sink-done/)) f()
+ else {
+ var count = 0
+ var fail = page.evaluate(function () {
+ var t = ''
+ var els = document.querySelectorAll('ol#tests .fail .fail')
+ for (var i = 0; i < els.length; i++) {
+ t += els[i].textContent + '\n'
+ }
+ return {text: t, count: els.length}
+ })
+ var pass = !!clsName.match(/sink-pass/)
+ if (pass) console.log('All tests have passed!')
+ else {
+ console.log(fail.count + ' test(s) failed')
+ console.log(fail.text.trim())
+ }
+
+ phantom.exit(pass ? 0 : 1)
+ }
+ }, 10)
+ }
+ f()
+})
View
15 test.js
@@ -0,0 +1,15 @@
+var spawn = require('child_process').spawn
+ , server = spawn('node', ['make/tests.js'])
+ , phantom = spawn('./vendor/phantomjs', ['./phantom.js'])
+
+
+phantom.stdout.on('data', function (data) {
+ console.log('stdout: ' + data);
+})
+
+phantom.on('exit', function (code, signal) {
+ var outcome = code == 0 ? 'passed' : 'failed'
+ console.log('Reqwest tests have %s', outcome, code)
+ server.kill('SIGHUP')
+ process.exit(code)
+})
View
Binary file not shown.

0 comments on commit d0f172a

Please sign in to comment.