diff --git a/.travis.yml b/.travis.yml index b370eb809..d2f147c39 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,14 +13,9 @@ matrix: node_js: stable osx_image: xcode8.3 -before_install: -- npm install google-closure-library -- npm install google-closure-compiler -- npm install webdriverio -# Symlink closure library -- ln -s $(npm root)/google-closure-library ../closure-library - before_script: + # Symlink closure library used by test/jsunit + - ln -s $(npm root)/google-closure-library ../closure-library - export DISPLAY=:99.0 - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then ( tests/scripts/setup_linux_env.sh ) fi - if [ "${TRAVIS_OS_NAME}" == "osx" ]; then ( tests/scripts/setup_osx_env.sh ) fi @@ -30,4 +25,4 @@ script: - set -x - npm run lint - npm test - - cd tests/compile; compile.sh; cd .. + - tests/compile/compile.sh diff --git a/package.json b/package.json index 6d5a792fb..0637984c5 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "private": true, "devDependencies": { "eslint": "^4.16", + "google-closure-compiler": "^20180506.0.0", "google-closure-library": "^20180506.0.0", "gulp": "^3.9.1", "gulp-concat": "^2.6.1", diff --git a/tests/compile/compile.sh b/tests/compile/compile.sh index 9ddd44f35..eb59b3af9 100755 --- a/tests/compile/compile.sh +++ b/tests/compile/compile.sh @@ -1,8 +1,12 @@ +echo "Executing compile.sh from $(pwd)" + +# TODO: Find relative path to Blockly root. For now, assume it is pwd. + # Find the Closure Compiler. if [ -f "$(npm root)/google-closure-compiler/compiler.jar" ]; then COMPILER="$(npm root)/google-closure-compiler/compiler.jar" -elif [ -f *compiler*.jar ]; then - COMPILER="*compiler*.jar" +elif [ -f tests/compile/*compiler*.jar ]; then + COMPILER="tests/compile/*compiler*.jar" # TODO: Check whether multiple files were found. else echo "ERROR: Closure Compiler not found." @@ -12,21 +16,25 @@ else fi echo Using $COMPILER as the compiler. -rm main_compressed.js 2> /dev/null +rm tests/compile/main_compressed.js 2> /dev/null echo Compiling Blockly... -java -jar $COMPILER --js='main.js' \ - --js='../../core/**.js' \ - --js='../../blocks/**.js' \ - --js='../../generators/**.js' \ - --js='../../msg/js/**.js' \ - --js='../../../closure-library/closure/goog/**.js' \ - --js='../../../closure-library/third_party/closure/goog/**.js' \ +COMPILATION_COMMAND="java -jar $COMPILER --js='tests/compile/main.js' \ + --js='core/**.js' \ + --js='blocks/**.js' \ + --js='generators/**.js' \ + --js='msg/js/**.js' \ + --js='../closure-library/closure/goog/**.js' \ + --js='../closure-library/third_party/closure/goog/**.js' \ --generate_exports \ - --externs ../../externs/svg-externs.js \ + --externs externs/svg-externs.js \ --compilation_level ADVANCED_OPTIMIZATIONS \ --dependency_mode=STRICT --entry_point=Main \ - --js_output_file main_compressed.js -if [ -s main_compressed.js ]; then + --js_output_file tests/compile/main_compressed.js" +echo $COMPILATION_COMMAND +$COMPILATION_COMMAND +EXIT_CODE=$? +echo "Compiler exit code: $EXIT_CODE" +if [ "$EXIT_CODE" -eq 0 ] && [ -s tests/compile/main_compressed.js ]; then echo Compilation OK. else echo Compilation FAIL. diff --git a/tests/compile/main.js b/tests/compile/main.js index 3fd1115a3..da19885e9 100644 --- a/tests/compile/main.js +++ b/tests/compile/main.js @@ -8,6 +8,12 @@ goog.require('Blockly.Constants.Logic'); goog.require('Blockly.Constants.Loops'); goog.require('Blockly.Constants.Math'); goog.require('Blockly.Constants.Text'); +// TODO: Add the following. Expecting additional warnings. +//goog.require('Blockly.Constants.Lists'); +//goog.require('Blockly.Constants.Colour'); +//goog.require('Blockly.Constants.Variables'); +//goog.require('Blockly.Constants.VariablesDynamic'); +//goog.require('Blockly.Constants.procedures'); Main.init = function() { Blockly.inject('blocklyDiv', {