Skip to content

Commit

Permalink
Added Travis CI config, and also supporting package.json.
Browse files Browse the repository at this point in the history
Removed flwplayer folder.
Added phantomjs for Travis CI test running, including temp makefile.
  • Loading branch information
heff committed Dec 11, 2012
1 parent 0a8d967 commit be0feba
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 168 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@
dist/*
dev.html
projects
.zenflow-log
.zenflow-log

node_modules
14 changes: 9 additions & 5 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
{
"validthis": true,
"laxcomma" : true,
"laxbreak" : true,
"browser" : true,
"eqnull" : true,
"debug" : true,
"devel" : true,
"boss" : true,
"expr" : true,
"asi" : true
"eqnull" : true,
"quotmark" : "double",
"sub" : true,
"trailing" : true,
"undef" : true,
"predef" : [ // Extra globals.
"_V_",
"VideoJS"
]
}
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
language: node_js
node_js:
- 0.8
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Using makefile temporarily to run tests on Travis CI

test:
# jshint src/*.js --config .jshintrc
node test/server.js &
phantomjs test/phantom.js "http://localhost:3000/test/unit.html"
kill -9 `cat test/pid.txt`
rm test/pid.txt

.PHONY: test
8 changes: 0 additions & 8 deletions decisions.txt

This file was deleted.

18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "Video.js"
, "description": "An HTML5 and Flash video player with a common API and skin for both."
, "version": "3.2.3"
, "keywords": ["html5", "flash", "video", "player"]
, "homepage": "http://videojs.com"
, "author": "Steve Heffernan"
, "scripts": { "test": "make test" }
, "repository": {
"type": "git"
, "url": "https://github.com/zencoder/video-js.git"
}
, "devDependencies": {
, "jshint": "0.6.1"
, "connect": "2.1.3"
, "phantomjs": "1.7.0"
}
}
154 changes: 0 additions & 154 deletions tech/flowplayer/flowplayer.js

This file was deleted.

63 changes: 63 additions & 0 deletions test/phantom.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Simple phantom.js integration script
// Adapted from Modernizr & Bootstrap

function waitFor(testFx, onReady, timeOutMillis) {
var maxtimeOutMillis = timeOutMillis ? timeOutMillis : 5001 //< Default Max Timout is 5s
, start = new Date().getTime()
, condition = false
, interval = setInterval(function () {
if ((new Date().getTime() - start < maxtimeOutMillis) && !condition) {
// If not time-out yet and condition not yet fulfilled
condition = (typeof(testFx) === "string" ? eval(testFx) : testFx()) //< defensive code
} else {
if (!condition) {
// If condition still not fulfilled (timeout but condition is 'false')
console.log("'waitFor()' timeout")
phantom.exit(1)
} else {
// Condition fulfilled (timeout and/or condition is 'true')
typeof(onReady) === "string" ? eval(onReady) : onReady() //< Do what it's supposed to do once the condition is fulfilled
clearInterval(interval) //< Stop this interval
}
}
}, 100) //< repeat check every 100ms
}


if (phantom.args.length === 0 || phantom.args.length > 2) {
console.log('Usage: phantom.js URL')
phantom.exit()
}

var page = new WebPage()

// Route "console.log()" calls from within the Page context to the main Phantom context (i.e. current "this")
page.onConsoleMessage = function(msg) {
console.log(msg)
};

page.open(phantom.args[0], function(status){
if (status !== "success") {
console.log("Unable to access network")
phantom.exit()
} else {
waitFor(function(){
return page.evaluate(function(){
var el = document.getElementById('qunit-testresult')
if (el && el.innerText.match('completed')) {
return true
}
return false
})
}, function(){
var failedNum = page.evaluate(function(){
var el = document.getElementById('qunit-testresult')
try {
return el.getElementsByClassName('failed')[0].innerHTML
} catch (e) { }
return 10000
});
phantom.exit((parseInt(failedNum, 10) > 0) ? 1 : 0)
})
}
})
14 changes: 14 additions & 0 deletions test/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Simple connect server for phantom.js
* Adapted from Modernizr & Bootstrap
*/

var connect = require('connect')
, http = require('http')
, fs = require('fs')
, app = connect()
.use(connect.static(__dirname + '/../'));

http.createServer(app).listen(3000);

fs.writeFileSync(__dirname + '/pid.txt', process.pid, 'utf-8')
3 changes: 3 additions & 0 deletions test/unit.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<link rel="stylesheet" href="vendor/qunit/qunit/qunit.css" />
<script src="vendor/qunit/qunit/qunit.js"></script>

<!-- phantomjs logging script-->
<script src="unit/phantom-logging.js"></script>

<!-- Video.js CSS -->
<link rel="stylesheet" href="../design/video-js.css" type="text/css">

Expand Down
21 changes: 21 additions & 0 deletions test/unit/phantom-logging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Logging setup for phantom integration
// adapted from Modernizr & Bootstrap

QUnit.begin = function () {
console.log("Starting test suite")
console.log("================================================\n")
}

QUnit.moduleDone = function (opts) {
if (opts.failed === 0) {
console.log("\u2714 All tests passed in '" + opts.name + "' module")
} else {
console.log("\u2716 " + opts.failed + " tests failed in '" + opts.name + "' module")
}
}

QUnit.done = function (opts) {
console.log("\n================================================")
console.log("Tests completed in " + opts.runtime + " milliseconds")
console.log(opts.passed + " tests of " + opts.total + " passed, " + opts.failed + " failed.")
}

0 comments on commit be0feba

Please sign in to comment.