From 53c8d31ad2e0e86439e3f4fdac933a892b90def7 Mon Sep 17 00:00:00 2001 From: Ben Langfeld Date: Fri, 28 Aug 2015 10:52:16 -0300 Subject: [PATCH 1/2] Upgrade Intern for better ES6 compat --- Vagrantfile | 2 +- devbox/provisioning.sh | 7 ++++++- package.json | 2 +- tests/intern.js | 11 ++--------- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 8682f53e..996df52b 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -17,6 +17,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.provider "virtualbox" do |v| v.name = "candy" - v.customize ["modifyvm", :id, "--memory", 768] + v.customize ["modifyvm", :id, "--memory", 2048] end end diff --git a/devbox/provisioning.sh b/devbox/provisioning.sh index aa8cd255..9636cf2d 100644 --- a/devbox/provisioning.sh +++ b/devbox/provisioning.sh @@ -59,4 +59,9 @@ cp /vagrant/devbox/selenium.init.sh /etc/init.d/selenium chmod 755 /etc/init.d/selenium /etc/init.d/selenium start update-rc.d selenium defaults -apt-get install -y phantomjs +sudo apt-get install build-essential g++ flex bison gperf ruby perl libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev libpng-dev libjpeg-dev python libx11-dev libxext-dev +git clone git://github.com/ariya/phantomjs.git +cd phantomjs +git checkout 2.0 +./build.sh --confirm +sudo cp bin/* /usr/local/bin diff --git a/package.json b/package.json index 5103e4ef..f769158f 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "grunt-prompt": "^1.3.0", "grunt-sync-pkg": "^0.1.2", "grunt-todo": "~0.4.0", - "intern": "^2.0.1", + "intern": "^3.0.0", "jshint-stylish": "^0.2.0", "lolex": "^1.2.0", "sinon": "^1.10.3", diff --git a/tests/intern.js b/tests/intern.js index 52d41405..ef703b46 100644 --- a/tests/intern.js +++ b/tests/intern.js @@ -38,16 +38,9 @@ define({ // Name of the tunnel class to use for WebDriver tests tunnel: 'SauceLabsTunnel', - // The desired AMD loader to use when running unit tests (client.html/client.js). Omit to use the default Dojo - // loader - useLoader: { - 'host-node': 'dojo/dojo', - 'host-browser': 'node_modules/dojo/dojo.js' - }, - // Configuration options for the module loader; any AMD configuration options supported by the specified AMD loader // can be used here - loader: { + loaderOptions: { // Packages that should be registered with the loader in each testing environment packages: [ { name: 'candy', location: '.' } @@ -67,5 +60,5 @@ define({ // A regular expression matching URLs to files that should not be included in code coverage analysis excludeInstrumentation: /^(?:tests\/|node_modules\/|bower_components\/|libs\.[^.]+\.js)/, - reporters: ['runner', 'lcov'] + reporters: ['Runner', {"id":"Lcov","filename":"lcov.info"}] }); From 4c9ae9c4604b009b6e8e0493ae0bd682a7f709d2 Mon Sep 17 00:00:00 2001 From: Ben Langfeld Date: Mon, 31 Aug 2015 15:36:30 -0300 Subject: [PATCH 2/2] Replace Vagrant with Docker Selenium w/ phantomjs can't cope with https://github.com/theintern/intern-examples/pull/25#issuecomment-136440975. This docker image gives us headless Chrome, and switching to Docker gives us a more modern dev environment anyway. --- .editorconfig | 4 ++++ Gruntfile.js | 6 ++--- Vagrantfile | 6 ++--- devbox/provisioning.sh | 37 +++++++---------------------- devbox/selenium.init.sh | 52 ----------------------------------------- docker-compose.yml | 14 +++++++++++ tests/intern.local.js | 10 +++++++- tests/intern.vagrant.js | 9 ------- 8 files changed, 40 insertions(+), 98 deletions(-) delete mode 100644 devbox/selenium.init.sh create mode 100644 docker-compose.yml delete mode 100644 tests/intern.vagrant.js diff --git a/.editorconfig b/.editorconfig index f02c9f24..7fe93499 100644 --- a/.editorconfig +++ b/.editorconfig @@ -9,3 +9,7 @@ indent_style = tab indent_size = 4 charset = utf-8 trim_trailing_whitespace = true + +[docker-compose.yml] +indent_style = space +indent_size = 2 diff --git a/Gruntfile.js b/Gruntfile.js index d8a253e5..4d4befc9 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,7 +1,5 @@ 'use strict'; -var localInternConfig = process.env.CANDY_VAGRANT === 'false' ? 'tests/intern.local' : 'tests/intern.vagrant'; - module.exports = function(grunt) { // Project configuration. @@ -160,14 +158,14 @@ module.exports = function(grunt) { unit: { options: { runType: 'runner', - config: localInternConfig, + config: 'tests/intern.local', functionalSuites: [] } }, functional: { options: { runType: 'runner', - config: localInternConfig, + config: 'tests/intern.local', suites: [] } } diff --git a/Vagrantfile b/Vagrantfile index 996df52b..3d59fbfd 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,18 +5,18 @@ VAGRANTFILE_API_VERSION = "2" Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| - config.vm.box = "ubuntu/trusty64" + config.vm.box = "spartan/docker" config.vm.network :forwarded_port, guest: 80, host: 8080 config.vm.network :forwarded_port, guest: 5280, host: 5280 - config.vm.network :forwarded_port, guest: 4444, host: 4444 config.vm.network :private_network, ip: '192.168.88.4' config.vm.provision :shell, :path => "devbox/provisioning.sh" + #config.vm.provision :shell, inline: "docker-compose run grunt npm install && docker-compose run grunt bower install" config.vm.synced_folder ".", "/vagrant", type: "nfs" config.vm.provider "virtualbox" do |v| v.name = "candy" - v.customize ["modifyvm", :id, "--memory", 2048] + v.customize ["modifyvm", :id, "--memory", 1024] end end diff --git a/devbox/provisioning.sh b/devbox/provisioning.sh index 9636cf2d..95c9503a 100644 --- a/devbox/provisioning.sh +++ b/devbox/provisioning.sh @@ -34,34 +34,13 @@ cp /vagrant/devbox/nginx-default.conf /etc/nginx/sites-available/default sed --in-place 's|{{ROOT_DIR}}|/vagrant|g' /etc/nginx/sites-available/default/nginx-default.conf /etc/init.d/nginx restart -# -# Candy development dependencies -# -sudo add-apt-repository ppa:chris-lea/node.js -sudo apt-get update -sudo apt-get install -y nodejs git -npm install -g grunt-cli -npm install -g bower +# Set it up to cd to /vagrant on login. +profile='/home/vagrant/.profile'; +if [ "$(tail -n 1 $profile)" != 'cd /vagrant' ]; then + echo 'cd /vagrant' >> $profile; +fi -cd /vagrant -su -u vagrant npm install -su -u vagrant bower install +cd /vagrant; -# -# Selenium & PhantomJS for testing -# -apt-get install -y openjdk-7-jre -mkdir /usr/lib/selenium/ -wget --no-verbose --output-document=/usr/lib/selenium/selenium-server-standalone-2.42.2.jar -- http://selenium-release.storage.googleapis.com/2.42/selenium-server-standalone-2.42.2.jar -mkdir -p /var/log/selenium/ -chmod a+w /var/log/selenium/ -cp /vagrant/devbox/selenium.init.sh /etc/init.d/selenium -chmod 755 /etc/init.d/selenium -/etc/init.d/selenium start -update-rc.d selenium defaults -sudo apt-get install build-essential g++ flex bison gperf ruby perl libsqlite3-dev libfontconfig1-dev libicu-dev libfreetype6 libssl-dev libpng-dev libjpeg-dev python libx11-dev libxext-dev -git clone git://github.com/ariya/phantomjs.git -cd phantomjs -git checkout 2.0 -./build.sh --confirm -sudo cp bin/* /usr/local/bin +docker-compose run grunt npm install +docker-compose run grunt bower install diff --git a/devbox/selenium.init.sh b/devbox/selenium.init.sh deleted file mode 100644 index e9841ca4..00000000 --- a/devbox/selenium.init.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash - -case "${1:-''}" in - 'start') - if test -f /tmp/selenium.pid - then - echo "Selenium is already running." - else - java -jar /usr/lib/selenium/selenium-server-standalone-2.42.2.jar -port 4444 > /var/log/selenium/selenium-output.log 2> /var/log/selenium/selenium-error.log & echo $! > /tmp/selenium.pid - echo "Starting Selenium..." - - error=$? - if test $error -gt 0 - then - echo "${bon}Error $error! Couldn't start Selenium!${boff}" - fi - fi - ;; - 'stop') - if test -f /tmp/selenium.pid - then - echo "Stopping Selenium..." - PID=`cat /tmp/selenium.pid` - kill -3 $PID - if kill -9 $PID ; - then - sleep 2 - test -f /tmp/selenium.pid && rm -f /tmp/selenium.pid - else - echo "Selenium could not be stopped..." - fi - else - echo "Selenium is not running." - fi - ;; - 'restart') - if test -f /tmp/selenium.pid - then - kill -HUP `cat /tmp/selenium.pid` - test -f /tmp/selenium.pid && rm -f /tmp/selenium.pid - sleep 1 - java -jar /usr/lib/selenium/selenium-server-standalone-2.42.2.jar -port 4444 > /var/log/selenium/selenium-output.log 2> /var/log/selenium/selenium-error.log & echo $! > /tmp/selenium.pid - echo "Reload Selenium..." - else - echo "Selenium isn't running..." - fi - ;; - *) # no parameter specified - echo "Usage: $SELF start|stop|restart|reload|force-reload|status" - exit 1 - ;; -esac diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..e7d63ad6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +selenium: + image: selenium/standalone-chrome:2.47.1 + expose: + - 4444 + +grunt: + image: digitallyseamless/nodejs-bower-grunt + expose: + - 9000 + links: + - selenium + volumes: + - /vagrant:/data + command: grunt watch diff --git a/tests/intern.local.js b/tests/intern.local.js index 3ca4ac48..9ce40790 100644 --- a/tests/intern.local.js +++ b/tests/intern.local.js @@ -5,7 +5,15 @@ define([ ], function (intern) { intern.tunnel = 'NullTunnel'; - intern.environments = [ { browserName: 'phantomjs' } ]; + intern.environments = [ { browserName: 'chrome', version: '43', platform: [ 'Linux' ] } ]; + + intern.tunnelOptions = { + hostname: 'selenium', + port: '4444', + verbose: true + }; + + intern.proxyUrl = 'http://grunt:9000/'; return intern; }); diff --git a/tests/intern.vagrant.js b/tests/intern.vagrant.js deleted file mode 100644 index eb4b1cf6..00000000 --- a/tests/intern.vagrant.js +++ /dev/null @@ -1,9 +0,0 @@ -/*global define */ - -define([ - './intern.local' -], function (intern) { - intern.proxyUrl = 'http://192.168.88.1:9000/'; - - return intern; -});