diff --git a/.travis.yml b/.travis.yml index b97b954663..26c2eab1a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,31 @@ python: - "3.4" - "3.5" - "3.6" + +matrix: + include: + - node_js: "lts/*" + language: node_js + python: "" + addons: + firefox: "45.0" + env: TEST_SUITE=js_unittests + - node_js: "lts/*" + language: node_js + python: "" + addons: + firefox: latest-esr + env: TEST_SUITE=js_unittests + +before_install: + - . src/ci_scripts/travis_before_install.sh + +before_script: + - . src/ci_scripts/travis_before_script.sh + script: - src/ci_scripts/travis.sh sqlite3 django$DJANGO_VERSION unittest + branches: - only: - - develop + only: + - develop diff --git a/src/.eslintrc b/src/.eslintrc index 2a15798a95..1e450ddbed 100644 --- a/src/.eslintrc +++ b/src/.eslintrc @@ -48,6 +48,7 @@ { "newIsCap": true, "capIsNew": true, + "capIsNewExceptions": ["URLify"], "properties": true } ], diff --git a/src/GruntFile.js b/src/GruntFile.js index 6c749c851d..66eacc6aeb 100644 --- a/src/GruntFile.js +++ b/src/GruntFile.js @@ -1,5 +1,6 @@ /* * Copyright (c) 2016-2017 CoNWeT Lab., Universidad Politécnica de Madrid + * Copyright (c) 2018 Future Internet Consulting and Development Solutions S.L. * * This file is part of Wirecloud Platform. * @@ -156,14 +157,17 @@ module.exports = function (grunt) { options: { frameworks: ['jasmine'], reporters: ['progress', 'coverage'], - browsers: ['Chrome', 'Firefox'], + browsers: ['Firefox'], singleRun: true }, styledelements: { options: { coverageReporter: { - type : 'html', - dir : 'build/coverage/styledelements' + reporters: [ + {type: 'html', dir: 'build/coverage/styledelements', subdir: 'html'}, + {type: 'cobertura', dir: 'build/coverage/styledelements', subdir: 'xml'}, + {type: 'lcov', dir: 'build/coverage/styledelements', subdir: 'lcov'}, + ] }, files: dependencies.concat(styledElementsFiles).concat(['js_tests/styledelements/*Spec.js']), preprocessors: { @@ -174,8 +178,11 @@ module.exports = function (grunt) { wirecloud: { options: { coverageReporter: { - type : 'html', - dir : 'build/coverage/wirecloud' + reporters: [ + {type: 'html', dir: 'build/coverage/wirecloud', subdir: 'html'}, + {type: 'cobertura', dir: 'build/coverage/wirecloud', subdir: 'xml'}, + {type: 'lcov', dir: 'build/coverage/wirecloud', subdir: 'lcov'}, + ] }, files: dependencies.concat(styledElementsFiles).concat(wc_dependencies).concat(WirecloudFiles).concat(['js_tests/wirecloud/**/*Spec.js']), preprocessors: { @@ -224,6 +231,8 @@ module.exports = function (grunt) { 'karma' ]); + grunt.registerTask('ci', ['test']); + grunt.registerTask('default', [ 'test', 'uglify', diff --git a/src/ci_scripts/travis.sh b/src/ci_scripts/travis.sh index f009d5419b..081f6b9a72 100755 --- a/src/ci_scripts/travis.sh +++ b/src/ci_scripts/travis.sh @@ -1,5 +1,12 @@ #!/usr/bin/env bash +if [ "${TEST_SUITE}" == "js_unittests" ]; then + cd $TRAVIS_BUILD_DIR/src + grunt ci + exit +fi + + export WC_INSTANCE_NAME=test_instance [ -n "${IP_ADDR}" ] || IP_ADDR="localhost" diff --git a/src/ci_scripts/travis_before_install.sh b/src/ci_scripts/travis_before_install.sh new file mode 100755 index 0000000000..060c33fb39 --- /dev/null +++ b/src/ci_scripts/travis_before_install.sh @@ -0,0 +1,6 @@ +if [ "${TEST_SUITE}" == "js_unittests" ]; then + cd $TRAVIS_BUILD_DIR/src + npm install grunt-cli -g + npm install + cd $TRAVIS_BUILD_DIR +fi diff --git a/src/ci_scripts/travis_before_script.sh b/src/ci_scripts/travis_before_script.sh new file mode 100755 index 0000000000..6c603c4850 --- /dev/null +++ b/src/ci_scripts/travis_before_script.sh @@ -0,0 +1,5 @@ +if [ "${TEST_SUITE}" == "js_unittests" ]; then + export DISPLAY=:99.0 + sh -e /etc/init.d/xvfb start + sleep 3 # give xvfb some time to start +fi diff --git a/src/js_tests/styledelements/GUIBuilderSpec.js b/src/js_tests/styledelements/GUIBuilderSpec.js index 5b6af30a9a..4e0876f28a 100644 --- a/src/js_tests/styledelements/GUIBuilderSpec.js +++ b/src/js_tests/styledelements/GUIBuilderSpec.js @@ -205,24 +205,25 @@ check_template_context_type("function returning elements", function (options) { var element = document.createElement('div'); + element.textContent = 'a'; if (options != null && 'class' in options) { element.className = options.class; } return element; }, - '
', - '' + '