Commit ff75ca72 authored by Mislav Marohnić's avatar Mislav Marohnić
Browse files

Support changing RUBY_BUILD_ROOT

This is to allow specifying an alternate path where `share/ruby-build/*`
definitions reside. Useful in tests as well.
parent 4e2177d5
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -118,6 +118,8 @@ You can set certain environment variables to control the build process.
  choosing.
* `RUBY_BUILD_SKIP_MIRROR`, if set, forces ruby-build to download packages from
  their original source URLs instead of using a mirror.
* `RUBY_BUILD_ROOT` overrides the default location from where build definitions
  in `share/ruby-build/` are looked up.
* `CC` sets the path to the C compiler.
* `RUBY_CFLAGS` lets you pass additional options to the default `CFLAGS`. Use
  this to override, for instance, the `-O3` option.
+6 −1
Original line number Diff line number Diff line
@@ -907,10 +907,12 @@ usage() {
}

list_definitions() {
  shopt -s nullglob
  { for definition in "${RUBY_BUILD_ROOT}/share/ruby-build/"*; do
      echo "${definition##*/}"
    done
  } | sort
  shopt -u nullglob
}


@@ -918,7 +920,10 @@ list_definitions() {
unset VERBOSE
unset KEEP_BUILD_PATH
unset HAS_PATCH

if [ -z "$RUBY_BUILD_ROOT" ]; then
  RUBY_BUILD_ROOT="$(abs_dirname "$0")/.."
fi

parse_options "$@"

+15 −0
Original line number Diff line number Diff line
@@ -11,6 +11,21 @@ NUM_DEFINITIONS="$(ls "$BATS_TEST_DIRNAME"/../share/ruby-build | wc -l)"
  assert [ "${#lines[*]}" -eq "$NUM_DEFINITIONS" ]
}

@test "custom RUBY_BUILD_ROOT: nonexistent" {
  export RUBY_BUILD_ROOT="$TMP"
  assert [ ! -e "${RUBY_BUILD_ROOT}/share/ruby-build" ]
  run ruby-build --definitions
  assert_success ""
}

@test "custom RUBY_BUILD_ROOT: single definition" {
  export RUBY_BUILD_ROOT="$TMP"
  mkdir -p "${RUBY_BUILD_ROOT}/share/ruby-build"
  touch "${RUBY_BUILD_ROOT}/share/ruby-build/1.9.3-test"
  run ruby-build --definitions
  assert_success "1.9.3-test"
}

@test "installing nonexistent definition" {
  run ruby-build "nonexistent" "${TMP}/install"
  assert [ "$status" -eq 2 ]