Skip to content

Commit

Permalink
Run phantomjs seperately
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Mar 16, 2015
1 parent ba1214a commit 419d7b2
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
language: node_js
before_script: make
script: make travis
script: make test
env:
global:
- SAUCE_USERNAME=github-fetch
- SAUCE_ACCESS_KEY=c3d37f93-0c2e-4834-9da5-eddc0d8c6299
matrix:
- PHANTOMJS=1
- SAUCE_PLATFORM="Windows 7" SAUCE_BROWSER="googlechrome" SAUCE_VERSION=""
addons:
sauce_connect: true
Expand Down
5 changes: 0 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ build: node_modules/ bower_components/
test: node_modules/ build lint
./script/test

saucelabs: build
./script/saucelabs

travis: lint test saucelabs

lint: node_modules/
./node_modules/.bin/jshint *.js test/*.js

Expand Down
16 changes: 16 additions & 0 deletions script/phantomjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -e

port=3900

# Find next available port
while lsof -i :$((++port)) >/dev/null; do true; done

# Spin a test server in the background
node ./test/server.js $port &>/dev/null &
server_pid=$!
trap "kill $server_pid" INT EXIT

node ./node_modules/.bin/mocha-phantomjs -s localToRemoteUrlAccessEnabled=true -s webSecurityEnabled=false "http://localhost:$port/test/test.html"
node ./node_modules/.bin/mocha-phantomjs -s localToRemoteUrlAccessEnabled=true -s webSecurityEnabled=false "http://localhost:$port/test/test-worker.html"
3 changes: 2 additions & 1 deletion script/saucelabs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash

set -e
set -x

Expand All @@ -14,7 +15,7 @@ job=$(./script/saucelabs-start "http://localhost:$port/test/test.html")
while true
do
result=$(echo "$job" | ./script/saucelabs-status)
[[ $string == *"\"completed\": true"* ]] && break
[[ $result == *"\"completed\": true"* ]] && break
sleep 1
done

Expand Down
18 changes: 6 additions & 12 deletions script/test
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
#!/bin/bash
set -e

port=3900

# Find next available port
while lsof -i :$((++port)) >/dev/null; do true; done

# Spin a test server in the background
node ./test/server.js $port &>/dev/null &
server_pid=$!
trap "kill $server_pid" INT EXIT
set -e

node ./node_modules/.bin/mocha-phantomjs -s localToRemoteUrlAccessEnabled=true -s webSecurityEnabled=false "http://localhost:$port/test/test.html"
node ./node_modules/.bin/mocha-phantomjs -s localToRemoteUrlAccessEnabled=true -s webSecurityEnabled=false "http://localhost:$port/test/test-worker.html"
if [ -n "$SAUCE_BROWSER" ]; then
./script/saucelabs
else
./script/phantomjs
fi

0 comments on commit 419d7b2

Please sign in to comment.