From e31c97b3e9a40eb50fdaeb6fe16ce000c0d002dd Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sun, 13 Dec 2015 13:12:17 +0000 Subject: [PATCH] Run JavaScript tests on Travis Using Sauce Labs and Grunt. Also install runtime dependencies using Bower to get the Jed package that's used in testing, and save the Bower version resolutions for Travis so that step can be automated. --- .travis.yml | 20 ++++++++++++++++- bower.json | 17 ++++++++++++++ gruntfile.js | 39 +++++++++++++++++++++++++++++++++ package.json | 8 +++++++ src/tests/gui/html/js/test.html | 23 +++++++++++++++++-- 5 files changed, 104 insertions(+), 3 deletions(-) create mode 100644 gruntfile.js diff --git a/.travis.yml b/.travis.yml index 4b10c77c..7e9dab43 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ addons: - libssl-dev - gcc-5 - g++-5 + sauce_connect: true install: # Use GCC 5. @@ -27,6 +28,16 @@ install: # Run install step script to download and build dependencies. - chmod +x scripts/install-step.travis.sh - ./scripts/install-step.travis.sh + # Install the latest stable Node.js. The default Node.js version is too old + # for some of the JavaScript syntax used. + - npm install -g nvm + - nvm install node + # Install Node.js dependencies + - npm install + # Add local binary path to PATH + - export PATH="./node_modules/.bin:$PATH" + # Install runtime dependencies using Bower + - bower install before_script: # Build Google Test @@ -46,7 +57,9 @@ before_script: # Travis machines are 64 bit, and the dependencies use dynamic linking. - cmake .. -DPROJECT_ARCH=64 -DPROJECT_STATIC_RUNTIME=OFF -DBUILD_SHARED_LIBS=OFF -DGTEST_ROOT=../../googletest-release-1.7.0 -script: make tests && ./tests +script: + - npm test + - make tests && ./tests before_deploy: # Build the metadata validator @@ -69,3 +82,8 @@ notifications: - "chat.freenode.net#loot" use_notice: true skip_join: true + +env: + global: + - secure: OWgDkff/b+0eKk/P75rBnecaPDv1E/gMkCzsTUUtofmzj+sttpMUsh8VOVUvckGs5m3fRwRhc/t99gR4FuDtMOVE5JZ8CqZn7tcv2wNAspQ613pS0nWyIX/IUbyF+gjtPW2dWy81hKVtTP4yFvUn1Gk+JRjJLSyxM53Xt6oTOlY= + - secure: XpGbqizjWfaGiWDkrcW4UhSW8ijm00jgSo2qkthza3QmHQ3C0Vye3gQjjITCq+y6izQTPa46fxaI+Ozligyh4aQ1G8SpCa77tXMBfvo31led+s81FlAOSVGDJ/2eDOoawFuj5dTKTPR1zLniDYH8AqG8EDZuLoK6fhx7CchU2Yw= diff --git a/bower.json b/bower.json index 1a57f4da..6895c6a3 100644 --- a/bower.json +++ b/bower.json @@ -37,5 +37,22 @@ "jed-gettext-parser": "~1.0.0", "paper-toggle-button": "Polymer/paper-toggle-button#~0.5.4", "core-overlay": "WrinklyNinja/core-overlay#fix-focus-self-as-next" + }, + "resolutions": { + "polymer": "^0.5", + "core-icons": "^0.5", + "core-icon": "^0.5", + "core-collapse": "^0.5", + "core-focusable": "^0.5", + "core-icon-button": "^0.5", + "core-resizable": "^0.5", + "core-iconset-svg": "^0.5", + "core-dropdown": "null-dimensions-positions-fix", + "core-transition": "^0.5", + "core-overlay": "fix-focus-self-as-next", + "webcomponentsjs": "^0.7.18", + "core-iconset": "^0.5", + "core-selection": "^0.5", + "core-meta": "^0.5" } } diff --git a/gruntfile.js b/gruntfile.js new file mode 100644 index 00000000..137560c0 --- /dev/null +++ b/gruntfile.js @@ -0,0 +1,39 @@ +'use strict'; +module.exports = (grunt) => { + grunt.initConfig({ + connect: { + server: { + options: { + base: '', + port: 9999, + }, + }, + }, + 'saucelabs-mocha': { + all: { + options: { + urls: ['http://127.0.0.1:9999/src/tests/gui/html/js/test.html'], + build: process.env.TRAVIS_JOB_ID, + throttled: 3, + browsers: [{ + browserName: 'chrome', + platform: 'Windows 10', + version: '47', + }], + testname: 'LOOT UI JS tests', + }, + }, + }, + watch: {}, + }); + + // Loading dependencies + for (const key in grunt.file.readJSON('package.json').devDependencies) { + if (key !== 'grunt' && key.indexOf('grunt') === 0) { + grunt.loadNpmTasks(key); + } + } + + grunt.registerTask('dev', ['connect', 'watch']); + grunt.registerTask('test', ['connect', 'saucelabs-mocha']); +}; diff --git a/package.json b/package.json index c7133252..609731bb 100644 --- a/package.json +++ b/package.json @@ -17,8 +17,16 @@ "eslint": "^1.10.3", "eslint-config-airbnb": "^2.0.0", "fs-extra": "^0.26.2", + "grunt": "^0.4.5", + "grunt-cli": "^0.1.13", + "grunt-contrib-connect": "^0.11.2", + "grunt-contrib-watch": "^0.6.1", + "grunt-saucelabs": "^8.6.2", "mocha": "^2.3.4", "should": "^8.0.1", "vulcanize": "^0.7.11" + }, + "scripts": { + "test": "grunt test" } } diff --git a/src/tests/gui/html/js/test.html b/src/tests/gui/html/js/test.html index a5d71d3c..7d52378c 100644 --- a/src/tests/gui/html/js/test.html +++ b/src/tests/gui/html/js/test.html @@ -11,8 +11,27 @@