From 336cb631feabddbcc85d64df3145f559f6ddfb46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Frering?= Date: Thu, 24 May 2012 17:37:25 +0200 Subject: [PATCH] New Cucumber feature: testing a Ruby project with a given JDK version. --- .../test_ruby_with_given_jdk_version.feature | 152 ++++++++++++++++++ lib/travis/build/job/test/ruby.rb | 9 +- 2 files changed, 157 insertions(+), 4 deletions(-) create mode 100644 features/test_ruby_with_given_jdk_version.feature diff --git a/features/test_ruby_with_given_jdk_version.feature b/features/test_ruby_with_given_jdk_version.feature new file mode 100644 index 0000000000..c7d4438799 --- /dev/null +++ b/features/test_ruby_with_given_jdk_version.feature @@ -0,0 +1,152 @@ +Feature: Testing a Ruby project with a given JDK version + + Background: + Given the following test payload + | repository | travis-ci/travis-ci | + | commit | 1234567 | + | config | rvm: 1.9.2, jdk: openjdk6, env: FOO=foo, gemfile: gemfiles/Gemfile | + + Scenario: A successful build + When it starts a job + Then it exports the given environment variables + And it successfully clones the repository to the build dir with git + And it successfully checks out the commit with git to the repository directory + And it exports the line TRAVIS_JDK_VERSION=openjdk6 + And it exports the line TRAVIS_RUBY_VERSION=1.9.2 + And it successfully switches to the jdk version: openjdk6 + And it announces active jdk version + And it successfully switches to the ruby version: 1.9.2 + And it announces active ruby version + And it does not find the file gemfiles/Gemfile + And it successfully runs the script: rake + And it closes the ssh session + And it returns the result 0 + And it has captured the following events + | name | data | + | job:test:start | started_at: [now] | + | job:test:log | log: /Using worker/ | + | job:test:log | log: cd ~/builds | + | job:test:log | log: export FOO=foo | + | job:test:log | log: git clone | + | job:test:log | log: cd travis-ci/travis-ci | + | job:test:log | log: git checkout | + | job:test:log | log: /export TRAVIS_JDK_VERSION=openjdk6/ | + | job:test:log | log: /export TRAVIS_RUBY_VERSION=1.9.2/ | + | job:test:log | log: sudo jdk-switcher use openjdk6 | + | job:test:log | log: java -version | + | job:test:log | log: javac -version | + | job:test:log | log: rvm use 1.9.2 | + | job:test:log | log: ruby --version | + | job:test:log | log: gem --version | + | job:test:log | log: rake | + | job:test:log | log: /Done.* 0/ | + | job:test:finish | finished_at: [now], result: 0 | + + Scenario: A successful build with a Gemfile + When it starts a job + Then it exports the given environment variables + And it successfully clones the repository to the build dir with git + And it successfully checks out the commit with git to the repository directory + And it exports the line TRAVIS_JDK_VERSION=openjdk6 + And it exports the line TRAVIS_RUBY_VERSION=1.9.2 + And it successfully switches to the jdk version: openjdk6 + And it announces active jdk version + And it successfully switches to the ruby version: 1.9.2 + And it announces active ruby version + And it finds a file gemfiles/Gemfile and successfully installs dependencies with bundle + And it successfully runs the script: bundle exec rake + And it closes the ssh session + And it returns the result 0 + And it has captured the following events + | name | data | + | job:test:start | started_at: [now] | + | job:test:log | log: /Using worker/ | + | job:test:log | log: cd ~/builds | + | job:test:log | log: export FOO=foo | + | job:test:log | log: git clone | + | job:test:log | log: cd travis-ci/travis-ci | + | job:test:log | log: git checkout | + | job:test:log | log: /export TRAVIS_JDK_VERSION=openjdk6/ | + | job:test:log | log: /export TRAVIS_RUBY_VERSION=1.9.2/ | + | job:test:log | log: sudo jdk-switcher use openjdk6 | + | job:test:log | log: java -version | + | job:test:log | log: javac -version | + | job:test:log | log: rvm use 1.9.2 | + | job:test:log | log: ruby --version | + | job:test:log | log: gem --version | + | job:test:log | log: /export BUNDLE_GEMFILE=/ | + | job:test:log | log: bundle install | + | job:test:log | log: bundle exec rake | + | job:test:log | log: /Done.* 0/ | + | job:test:finish | finished_at: [now], result: 0 | + + Scenario: The repository can not be cloned + When it starts a job + Then it exports the given environment variables + And it fails to clone the repository to the build dir with git + And it closes the ssh session + And it returns the result 1 + + Scenario: The commit can not be checked out + When it starts a job + Then it exports the given environment variables + And it successfully clones the repository to the build dir with git + And it fails to check out the commit with git to the repository directory + And it closes the ssh session + And it returns the result 1 + + Scenario: The jdk version can not be activated + When it starts a job + Then it exports the given environment variables + And it successfully clones the repository to the build dir with git + And it successfully checks out the commit with git to the repository directory + And it exports the line TRAVIS_JDK_VERSION=openjdk6 + And it exports the line TRAVIS_RUBY_VERSION=1.9.2 + And it fails to switch to the jdk version: openjdk6 + And it closes the ssh session + And it returns the result 1 + + Scenario: The ruby version can not be activated + When it starts a job + Then it exports the given environment variables + And it successfully clones the repository to the build dir with git + And it successfully checks out the commit with git to the repository directory + And it exports the line TRAVIS_JDK_VERSION=openjdk6 + And it exports the line TRAVIS_RUBY_VERSION=1.9.2 + And it successfully switches to the jdk version: openjdk6 + And it announces active jdk version + And it fails to switch to the ruby version: 1.9.2 + And it closes the ssh session + And it returns the result 1 + + Scenario: The bundle can not be installed + When it starts a job + Then it exports the given environment variables + And it successfully clones the repository to the build dir with git + And it successfully checks out the commit with git to the repository directory + And it exports the line TRAVIS_JDK_VERSION=openjdk6 + And it exports the line TRAVIS_RUBY_VERSION=1.9.2 + And it successfully switches to the jdk version: openjdk6 + And it announces active jdk version + And it successfully switches to the ruby version: 1.9.2 + And it announces active ruby version + And it finds a file gemfiles/Gemfile but fails to install dependencies with bundle + And it closes the ssh session + And it returns the result 1 + + Scenario: The build fails + When it starts a job + Then it exports the given environment variables + And it successfully clones the repository to the build dir with git + And it successfully checks out the commit with git to the repository directory + And it exports the line TRAVIS_JDK_VERSION=openjdk6 + And it exports the line TRAVIS_RUBY_VERSION=1.9.2 + And it successfully switches to the jdk version: openjdk6 + And it announces active jdk version + And it successfully switches to the ruby version: 1.9.2 + And it announces active ruby version + And it does not find the file gemfiles/Gemfile + And it fails to run the script: rake + And it closes the ssh session + And it returns the result 1 + diff --git a/lib/travis/build/job/test/ruby.rb b/lib/travis/build/job/test/ruby.rb index a94454e629..9d78244d07 100644 --- a/lib/travis/build/job/test/ruby.rb +++ b/lib/travis/build/job/test/ruby.rb @@ -13,13 +13,14 @@ class Config < Hashr def setup super - setup_ruby - announce_ruby - setup_bundler if uses_bundler? if !!config[:jdk] setup_jdk end + + setup_ruby + announce_ruby + setup_bundler if uses_bundler? end def install @@ -51,8 +52,8 @@ def announce_ruby end def export_environment_variables - shell.export_line("TRAVIS_RUBY_VERSION=#{config.rvm}") export_jdk_environment_variables if !!config[:jdk] + shell.export_line("TRAVIS_RUBY_VERSION=#{config.rvm}") end end end