Skip to content

Commit

Permalink
More scripty
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Mar 16, 2015
1 parent fe3056e commit ba1214a
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 87 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"devDependencies": {
"bower": "1.3.8",
"chai": "1.10.0",
"es6-promise": "1.0.0",
"jshint": "2.5.2",
"mocha-phantomjs": "3.5.2",
"mocha": "2.1.0",
Expand Down
12 changes: 11 additions & 1 deletion script/saucelabs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
set -e
set -x

port=8080

Expand All @@ -8,4 +9,13 @@ node ./test/server.js $port &>/dev/null &
server_pid=$!
trap "kill $server_pid" INT EXIT

node ./test/saucelabs.js "http://localhost:$port/test/test.html"
job=$(./script/saucelabs-start "http://localhost:$port/test/test.html")

while true
do
result=$(echo "$job" | ./script/saucelabs-status)
[[ $string == *"\"completed\": true"* ]] && break
sleep 1
done

echo "$result" | ./script/saucelabs-result
17 changes: 17 additions & 0 deletions script/saucelabs-result
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env ruby

require 'json'

obj = JSON.parse(ARGF.read)

test = obj['js tests'][0]

warn test['url']
warn test['platform']
warn test['result'].inspect

if test['result'] && test['result']['passed'] == test['result']['total']
exit 0
else
exit 1
end
22 changes: 22 additions & 0 deletions script/saucelabs-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash

set -e
set -x

url="https://saucelabs.com/rest/v1/$SAUCE_USERNAME/js-tests"
auth="$SAUCE_USERNAME:$SAUCE_ACCESS_KEY"
header="Content-Type: application/json"

data=$(cat <<JSON
{
"build": "$TRAVIS_BUILD_NUMBER",
"tags": ["$TRAVIS_PULL_REQUEST", "$TRAVIS_BRANCH"],
"tunnel-identifier": "$TRAVIS_JOB_NUMBER",
"platforms": [["$SAUCE_PLATFORM", "$SAUCE_BROWSER", "$SAUCE_VERSION"]],
"url": "$1",
"framework": "mocha"
}
JSON
)

curl -fs "$url" -X POST -u "$auth" -H "$header" -d "$data"
8 changes: 8 additions & 0 deletions script/saucelabs-status
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -e

url="https://saucelabs.com/rest/v1/$SAUCE_USERNAME/js-tests/status"
auth="$SAUCE_USERNAME:$SAUCE_ACCESS_KEY"
header="Content-Type: application/json"
curl -fs "$url" -X POST -u "$auth" -H "$header" -d "@-"
85 changes: 0 additions & 85 deletions test/saucelabs.js

This file was deleted.

0 comments on commit ba1214a

Please sign in to comment.