Reduce duration unit testing implementing their parallelization

Starting from two pull requests by @tanx and @Mithgol this commit implement the following:
- add testing of node version 4.2 LTS;
- move testing to the new TravisCI environment that is expected to be more fast;
- parallelize tests making possible to end first and to test more lasting less;
- make possible for browsertests to fail without impacting on the overall result.
This commit is contained in:
evilaliv3 2015-11-30 02:07:04 +01:00
parent e02bc7c2f5
commit 46d2b6e66d
3 changed files with 94 additions and 26 deletions

View File

@ -1,9 +1,54 @@
language: node_js
node_js:
- "0.12.2"
matrix:
include:
- node_js: "0.12.2"
env: OPENPGPJSTEST='unit'
- node_js: "4.2"
env: OPENPGPJSTEST='unit'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-0' BROWSER='firefox 38'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-1' BROWSER='firefox 42'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-2' BROWSER='firefox beta'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-3' BROWSER='chrome 38'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-4' BROWSER='chrome 46'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-5' BROWSER='chrome beta'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-6' BROWSER='internet explorer 11'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-7' BROWSER='microsoft edge 20.10240'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-8' BROWSER='safari 8'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-9' BROWSER='safari 9'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-10' BROWSER='android 4.4'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-11' BROWSER='android 5.1'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-12' BROWSER='iphoee 7.0'
- node_js: "0.12.2"
env: OPENPGPJSTEST='end2end-13' BROWSER='iphone 9.1'
allow_failures:
- env: OPENPGPJSTEST='end2end-0'
- env: OPENPGPJSTEST='end2end-1'
- env: OPENPGPJSTEST='end2end-2'
- env: OPENPGPJSTEST='end2end-3'
- env: OPENPGPJSTEST='end2end-4'
- env: OPENPGPJSTEST='end2end-5'
- env: OPENPGPJSTEST='end2end-6'
- env: OPENPGPJSTEST='end2end-7'
- env: OPENPGPJSTEST='end2end-8'
- env: OPENPGPJSTEST='end2end-9'
- env: OPENPGPJSTEST='end2end-10'
- env: OPENPGPJSTEST='end2end-11'
- env: OPENPGPJSTEST='end2end-12'
- env: OPENPGPJSTEST='end2end-13'
before_script:
- npm install -g grunt-cli
script:
- grunt
- grunt test_travis_mocha_coveralls
- grunt test_travis_mocha_saucelabs || true
- $TRAVIS_BUILD_DIR/travis.sh

View File

@ -2,6 +2,10 @@ module.exports = function(grunt) {
var version = grunt.option('release');
if (process.env.SELENIUM_BROWSER_CAPABILITIES != undefined) {
var browser_capabilities = JSON.parse(process.env.SELENIUM_BROWSER_CAPABILITIES);
}
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
@ -111,14 +115,14 @@ module.exports = function(grunt) {
src: 'test',
options: {
root: 'node_modules/openpgp',
timeout: 120000,
timeout: 240000,
}
},
coveralls: {
src: ['test'],
options: {
root: 'node_modules/openpgp',
timeout: 120000,
timeout: 240000,
coverage: true,
reportFormats: ['cobertura','lcovonly']
}
@ -172,22 +176,7 @@ module.exports = function(grunt) {
urls: ['http://127.0.0.1:9000/test/unittests.html'],
build: process.env.TRAVIS_JOB_ID,
testname: 'Sauce Unit Test for openpgpjs',
browsers: [
{ browserName:"firefox", version:"38.0", platform:"Linux" },
{ browserName:"firefox", version:"42.0", platform:"OS X 10.10" },
{ browserName:"firefox", version:"beta", platform:"Windows 10" },
{ browserName:"chrome", version:"38.0", platform:"Linux" },
{ browserName:"chrome", version:"46.0", platform:"OS X 10.10" },
{ browserName:"chrome", version:"beta", platform:"Windows 10" },
{ browserName:"internet explorer", version:"11", platform:"Windows 10" },
{ browserName:"microsoftEdge", version:"20.10240", platform:"Windows 10" },
{ browserName:"safari", version:"8", platform:"OS X 10.10" },
{ browserName:"safari", version:"9", platform:"OS X 10.11" },
{ browserName:"android", version:"4.4", deviceName: "Android Emulator", platform: "Linux" },
{ browserName:"android", version:"5.1", deviceName: "Android Emulator", platform: "Linux" },
{ browserName: "iphone", version:"7.0", deviceName: "iPad Simulator", "device-orientation": "portrait", platform:"OS X 10.10" },
{ browserName: "iphone", version:"9.1", deviceName: "iPad Simulator", "device-orientation": "portrait", platform:"OS X 10.10" }
],
browsers: [browser_capabilities],
public: "public",
'max-duration': 360,
maxRetries: 1,
@ -282,7 +271,4 @@ module.exports = function(grunt) {
grunt.registerTask('coverage', ['default', 'copy:npm', 'copy:unittests', 'mocha_istanbul:coverage']);
grunt.registerTask('coveralls', ['default', 'copy:npm', 'copy:unittests', 'mocha_istanbul:coveralls']);
grunt.registerTask('saucelabs', ['default', 'copy:npm', 'copy:unittests', 'connect', 'saucelabs-mocha']);
grunt.registerTask('test_travis_mocha_coveralls', ['copy:npm', 'copy:unittests', 'mocha_istanbul:coveralls']);
grunt.registerTask('test_travis_mocha_saucelabs', ['copy:npm', 'copy:unittests', 'connect', 'saucelabs-mocha']);
};

37
travis.sh Executable file
View File

@ -0,0 +1,37 @@
#!/bin/bash
set -e
if [ $OPENPGPJSTEST = "unit" ]; then
echo "Running OpenPGP.js unit-tests"
grunt coveralls
elif [[ $OPENPGPJSTEST =~ ^end2end-.* ]]; then
echo "Running browser-testing on Saucelabs"
declare -a capabilities=(
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"firefox\", \"version\":\"38.0\", \"platform\":\"Linux\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"firefox\", \"version\":\"42.0\", \"platform\":\"OS X 10.10\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"firefox\", \"version\":\"beta\", \"platform\":\"Windows 10\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"chrome\", \"version\":\"38.0\", \"platform\":\"Linux\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"chrome\", \"version\":\"46.0\", \"platform\":\"OS X 10.10\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"chrome\", \"version\":\"beta\", \"platform\":\"Windows 10\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"internet explorer\", \"version\":\"11\", \"platform\":\"Windows 10\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"microsoftEdge\", \"version\":\"20.10240\", \"platform\":\"Windows 10\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"safari\", \"version\":\"8\", \"platform\":\"OS X 10.10\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"safari\", \"version\":\"9\", \"platform\":\"OS X 10.11\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"android\", \"version\": \"4.4\", \"deviceName\": \"Android Emulator\", \"platform\": \"Linux\"}'."
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\":\"android\", \"version\": \"5.1\", \"deviceName\": \"Android Emulator\", \"platform\": \"Linux\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\": \"iPhone\", \"version\": \"7.1\", \"deviceName\": \"iPad Simulator\", \"device-orientation\": \"portrait\", \"platform\":\"OS X 10.10\"}'"
"export SELENIUM_BROWSER_CAPABILITIES='{\"browserName\": \"iPhone\", \"version\": \"9.1\", \"deviceName\": \"iPad Simulator\", \"device-orientation\": \"portrait\", \"platform\":\"OS X 10.10\"}'"
)
testkey=$(echo $OPENPGPJSTEST | cut -f2 -d-)
## now loop through the above array
capability=${capabilities[${testkey}]}
echo "Testing Configuration: ${testkey}"
eval $capability
grunt saucelabs
fi