6377: Don't try to uninstall arvados* gems if they are not installed.
authorTom Clegg <tom@curoverse.com>
Tue, 30 Jun 2015 18:53:47 +0000 (14:53 -0400)
committerTom Clegg <tom@curoverse.com>
Tue, 30 Jun 2015 18:56:00 +0000 (14:56 -0400)
Fixes run-tests failure when no Ruby SDK is installed on the test host
and tmpdirs are new/empty. refs #6377

jenkins/run-tests.sh

index fe33948bf369ec93bd376617fbfa2fa975722bdd..a646e361f5f0d4ab0b08a00e787c6e627e559a87 100755 (executable)
@@ -359,7 +359,13 @@ with_test_gemset() {
     if [[ "$using_rvm" == true ]]; then
         "$@"
     else
-        GEM_HOME="$tmpdir_gem_home" "$@"
+        GEM_HOME="$tmpdir_gem_home" GEM_PATH="$tmpdir_gem_home" "$@"
+    fi
+}
+
+gem_uninstall_if_exists() {
+    if gem list "$1\$" | egrep '^\w'; then
+        gem uninstall --force --all --executables "$1"
     fi
 }
 
@@ -535,7 +541,7 @@ install_doc() {
 do_install doc
 
 install_ruby_sdk() {
-    with_test_gemset gem uninstall --force --all --executables arvados \
+    with_test_gemset gem_uninstall_if_exists arvados \
         && cd "$WORKSPACE/sdk/ruby" \
         && bundle_install_trylocal \
         && gem build arvados.gemspec \
@@ -544,7 +550,7 @@ install_ruby_sdk() {
 do_install sdk/ruby ruby_sdk
 
 install_cli() {
-    with_test_gemset gem uninstall --force --all --executables arvados-cli \
+    with_test_gemset gem_uninstall_if_exists arvados-cli \
         && cd "$WORKSPACE/sdk/cli" \
         && bundle_install_trylocal \
         && gem build arvados-cli.gemspec \