Commit 9aab127f by Mislav Marohnić

Install Rake and Bundler in isolation when missing

Some Rubies need Rake or Bundler for the installation process. However,
since the host Ruby version might not have those gems installed, install
them in a temporary GEM_HOME and add their executables to PATH.

Fixes #426
parent 730a8164
...@@ -703,10 +703,29 @@ rake() { ...@@ -703,10 +703,29 @@ rake() {
if [ -e "./Gemfile" ]; then if [ -e "./Gemfile" ]; then
bundle exec rake "$@" bundle exec rake "$@"
else else
isolated_gem_dependency "rake --version" rake -v '~> 10.1.0'
command rake "$@" command rake "$@"
fi fi
} }
bundle() {
isolated_gem_dependency "bundle --version" bundler -v '~> 1.3.5'
command bundle "$@"
}
isolated_gem_dependency() {
if ! command $1 &>/dev/null; then
shift 1
isolated_gem_install "$@"
fi
}
isolated_gem_install() {
export GEM_HOME="${PWD}/.gem"
export PATH="${GEM_HOME}/bin:${PATH}"
gem install "$@"
}
version() { version() {
echo "ruby-build ${RUBY_BUILD_VERSION}" echo "ruby-build ${RUBY_BUILD_VERSION}"
} }
......
...@@ -142,7 +142,8 @@ OUT ...@@ -142,7 +142,8 @@ OUT
install_package "mruby-1.0" "http://ruby-lang.org/pub/mruby-1.0.tar.gz" mruby install_package "mruby-1.0" "http://ruby-lang.org/pub/mruby-1.0.tar.gz" mruby
DEF DEF
stub rake true stub gem false
stub rake '--version : true' true
run ruby-build "definition" "$INSTALL_ROOT" run ruby-build "definition" "$INSTALL_ROOT"
assert_success assert_success
...@@ -162,8 +163,12 @@ DEF ...@@ -162,8 +163,12 @@ DEF
install_package "rubinius-2.0.0" "http://releases.rubini.us/rubinius-2.0.0.tar.gz" rbx install_package "rubinius-2.0.0" "http://releases.rubini.us/rubinius-2.0.0.tar.gz" rbx
DEF DEF
stub gem false
stub rake false stub rake false
stub bundle ' : echo bundle >> build.log' \ stub bundle \
'--version : true' \
' : echo bundle >> build.log' \
'--version : true' \
" exec rake install : { cat build.log; echo bundle \"\$@\"; } >> '$INSTALL_ROOT/build.log'" " exec rake install : { cat build.log; echo bundle \"\$@\"; } >> '$INSTALL_ROOT/build.log'"
run ruby-build "definition" "$INSTALL_ROOT" run ruby-build "definition" "$INSTALL_ROOT"
......
...@@ -3,8 +3,10 @@ export TMP="$BATS_TEST_DIRNAME/tmp" ...@@ -3,8 +3,10 @@ export TMP="$BATS_TEST_DIRNAME/tmp"
if [ "$FIXTURE_ROOT" != "$BATS_TEST_DIRNAME/fixtures" ]; then if [ "$FIXTURE_ROOT" != "$BATS_TEST_DIRNAME/fixtures" ]; then
export FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures" export FIXTURE_ROOT="$BATS_TEST_DIRNAME/fixtures"
export INSTALL_ROOT="$TMP/install" export INSTALL_ROOT="$TMP/install"
export PATH="$BATS_TEST_DIRNAME/../bin:$PATH" PATH=/usr/bin:/usr/sbin:/bin/:/sbin
export PATH="$TMP/bin:$PATH" PATH="$BATS_TEST_DIRNAME/../bin:$PATH"
PATH="$TMP/bin:$PATH"
export PATH
fi fi
teardown() { teardown() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment