mirror of
https://github.com/rbenv/ruby-build.git
synced 2026-05-15 00:46:53 -04:00
37signals are dropping AWS, which means goodbye to S3 and CloudFront. The CloudFront mirror (dqw8nmjcqpjn7.cloudfront.net) was introduced ages ago to address intermittent unavailability from some upstream sources. These days, it mainly serves non-MRI packages like OpenSSL and libyaml. Ruby releases are now served by Fastly (cache.ruby-lang.org) which has bypassed the ruby-build mirror since 2015. Other sources (GitHub, RubyGems, Maven) have their own CDNs. This change removes the default `RUBY_BUILD_MIRROR_URL` and S3 release mirroring. Custom mirror support remains.
88 lines
2.3 KiB
Bash
88 lines
2.3 KiB
Bash
#!/usr/bin/env bats
|
|
|
|
load test_helper
|
|
export RUBY_BUILD_SKIP_MIRROR=1
|
|
export RUBY_BUILD_CACHE_PATH="$TMP/cache"
|
|
|
|
@test "packages are saved to download cache" {
|
|
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
|
|
|
|
mkdir -p "$RUBY_BUILD_CACHE_PATH"
|
|
install_fixture definitions/without-checksum
|
|
|
|
assert_success
|
|
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
|
|
|
unstub curl
|
|
}
|
|
|
|
|
|
@test "cached package without checksum" {
|
|
stub curl
|
|
|
|
mkdir -p "$RUBY_BUILD_CACHE_PATH"
|
|
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH"
|
|
|
|
install_fixture definitions/without-checksum
|
|
|
|
assert_success
|
|
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
|
|
|
unstub curl
|
|
}
|
|
|
|
|
|
@test "cached package with valid checksum" {
|
|
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
|
stub curl
|
|
|
|
mkdir -p "$RUBY_BUILD_CACHE_PATH"
|
|
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$RUBY_BUILD_CACHE_PATH"
|
|
|
|
install_fixture definitions/with-checksum
|
|
|
|
assert_success
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
|
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
|
|
|
unstub curl
|
|
unstub shasum
|
|
}
|
|
|
|
|
|
@test "cached package with invalid checksum falls back to original URL and updates cache" {
|
|
export RUBY_BUILD_SKIP_MIRROR=
|
|
export RUBY_BUILD_MIRROR_URL=
|
|
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
|
|
|
stub shasum true "echo invalid" "echo $checksum"
|
|
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
|
|
|
|
mkdir -p "$RUBY_BUILD_CACHE_PATH"
|
|
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
|
|
|
|
install_fixture definitions/with-checksum
|
|
|
|
assert_success
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
|
assert [ -e "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
|
assert diff -q "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz"
|
|
|
|
unstub curl
|
|
unstub shasum
|
|
}
|
|
|
|
|
|
@test "nonexistent cache directory is ignored" {
|
|
stub curl "-q -fL -o * http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$4"
|
|
|
|
export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"
|
|
|
|
install_fixture definitions/without-checksum
|
|
|
|
assert_success
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
|
refute [ -d "$RUBY_BUILD_CACHE_PATH" ]
|
|
|
|
unstub curl
|
|
}
|