mirror of
https://github.com/rbenv/ruby-build.git
synced 2024-12-28 20:55:31 +01:00
Support changing RUBY_BUILD_ROOT
This is to allow specifying an alternate path where `share/ruby-build/*` definitions reside. Useful in tests as well.
This commit is contained in:
parent
4e2177d5c2
commit
ff75ca7204
3 changed files with 23 additions and 1 deletions
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
RUBY_BUILD_ROOT="$(abs_dirname "$0")/.."
|
||||
|
||||
if [ -z "$RUBY_BUILD_ROOT" ]; then
|
||||
RUBY_BUILD_ROOT="$(abs_dirname "$0")/.."
|
||||
fi
|
||||
|
||||
parse_options "$@"
|
||||
|
||||
|
|
|
@ -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 ]
|
||||
|
|
Loading…
Reference in a new issue