mirror of
https://github.com/rbenv/ruby-build.git
synced 2025-09-03 15:51:32 +02:00
Fix broken test suite
Fixes breakage caused by curl arguments change in
d0912e4fb5
This commit is contained in:
parent
9f77dfc4d5
commit
a9a274e624
5 changed files with 23 additions and 22 deletions
|
@ -11,7 +11,7 @@ setup() {
|
|||
|
||||
@test "packages are saved to download cache" {
|
||||
stub md5 true
|
||||
stub curl "-*S* : cat package-1.0.0.tar.gz"
|
||||
stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
|
@ -58,7 +58,8 @@ setup() {
|
|||
local checksum="83e6d7725e20166024a1eb74cde80677"
|
||||
|
||||
stub md5 true "echo invalid" "echo $checksum"
|
||||
stub curl "-*I* : true" "-*S* http://?*/$checksum : cat package-1.0.0.tar.gz"
|
||||
stub curl "-*I* : true" \
|
||||
"-C - -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4"
|
||||
|
||||
touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
|
||||
|
||||
|
@ -75,7 +76,7 @@ setup() {
|
|||
|
||||
@test "nonexistent cache directory is ignored" {
|
||||
stub md5 true
|
||||
stub curl "-*S* : cat package-1.0.0.tar.gz"
|
||||
stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ export RUBY_BUILD_CACHE_PATH=
|
|||
|
||||
@test "package URL without checksum" {
|
||||
stub md5 true
|
||||
stub curl "-*S* : cat package-1.0.0.tar.gz"
|
||||
stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
|
@ -20,7 +20,7 @@ export RUBY_BUILD_CACHE_PATH=
|
|||
|
||||
@test "package URL with valid checksum" {
|
||||
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
|
||||
stub curl "-*S* : cat package-1.0.0.tar.gz"
|
||||
stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
|
@ -33,7 +33,7 @@ export RUBY_BUILD_CACHE_PATH=
|
|||
|
||||
@test "package URL with invalid checksum" {
|
||||
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677"
|
||||
stub curl "-*S* : cat package-1.0.0.tar.gz"
|
||||
stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/with-invalid-checksum
|
||||
[ "$status" -eq 1 ]
|
||||
|
@ -46,7 +46,7 @@ export RUBY_BUILD_CACHE_PATH=
|
|||
|
||||
@test "package URL with checksum but no MD5 support" {
|
||||
stub md5 false
|
||||
stub curl "-*S* : cat package-1.0.0.tar.gz"
|
||||
stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
|
@ -59,7 +59,7 @@ export RUBY_BUILD_CACHE_PATH=
|
|||
|
||||
@test "package with invalid checksum" {
|
||||
stub md5 true "echo invalid"
|
||||
stub curl "-*S* : cat package-1.0.0.tar.gz"
|
||||
stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 1 ]
|
||||
|
|
|
@ -8,9 +8,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
|
||||
@test "package URL without checksum bypasses mirror" {
|
||||
stub md5 true
|
||||
stub curl "-*S* http://example.com/* : cat package-1.0.0.tar.gz"
|
||||
stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/without-checksum
|
||||
echo "$output" >&2
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
|
@ -21,7 +22,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
|
||||
@test "package URL with checksum but no MD5 support bypasses mirror" {
|
||||
stub md5 false
|
||||
stub curl "-*S* http://example.com/* : cat package-1.0.0.tar.gz"
|
||||
stub curl "-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
|
@ -37,7 +38,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
|
||||
|
||||
stub md5 true "echo $checksum"
|
||||
stub curl "-*I* $mirror_url : true" "-*S* $mirror_url : cat package-1.0.0.tar.gz"
|
||||
stub curl "-*I* $mirror_url : true" \
|
||||
"-C - -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
|
@ -51,10 +53,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
@test "package is fetched from original URL if mirror download fails" {
|
||||
local checksum="83e6d7725e20166024a1eb74cde80677"
|
||||
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
|
||||
local original_url="http://example.com/packages/package-1.0.0.tar.gz"
|
||||
|
||||
stub md5 true "echo $checksum"
|
||||
stub curl "-*I* $mirror_url : false" "-*S* $original_url : cat package-1.0.0.tar.gz"
|
||||
stub curl "-*I* $mirror_url : false" \
|
||||
"-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
|
@ -68,12 +70,14 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
@test "package is fetched from original URL if mirror download checksum is invalid" {
|
||||
local checksum="83e6d7725e20166024a1eb74cde80677"
|
||||
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
|
||||
local original_url="http://example.com/packages/package-1.0.0.tar.gz"
|
||||
|
||||
stub md5 true "echo invalid" "echo $checksum"
|
||||
stub curl "-*I* $mirror_url : true" "-*S* $mirror_url : cat package-1.0.0.tar.gz" "-*S* $original_url : cat package-1.0.0.tar.gz"
|
||||
stub curl "-*I* $mirror_url : true" \
|
||||
"-C - -o * -*S* $mirror_url : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \
|
||||
"-C - -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${6##*/} \$4"
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
echo "$output" >&2
|
||||
[ "$status" -eq 0 ]
|
||||
[ -x "${INSTALL_ROOT}/bin/package" ]
|
||||
|
||||
|
@ -87,7 +91,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
|
|||
local checksum="83e6d7725e20166024a1eb74cde80677"
|
||||
|
||||
stub md5 true "echo $checksum"
|
||||
stub curl "-*I* : true" "-*S* http://?*/$checksum : cat package-1.0.0.tar.gz"
|
||||
stub curl "-*I* : true" \
|
||||
"-C - -o * -*S* http://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$4" \
|
||||
|
||||
install_fixture definitions/with-checksum
|
||||
[ "$status" -eq 0 ]
|
||||
|
|
|
@ -8,7 +8,6 @@ PROGRAM="$(echo "$program" | tr a-z A-Z)"
|
|||
|
||||
_STUB_PLAN="${PROGRAM}_STUB_PLAN"
|
||||
_STUB_RUN="${PROGRAM}_STUB_RUN"
|
||||
_STUB_DIR="${PROGRAM}_STUB_DIR"
|
||||
_STUB_INDEX="${PROGRAM}_STUB_INDEX"
|
||||
_STUB_RESULT="${PROGRAM}_STUB_RESULT"
|
||||
_STUB_END="${PROGRAM}_STUB_END"
|
||||
|
@ -62,10 +61,8 @@ while IFS= read -r line; do
|
|||
# If the arguments matched, evaluate the command
|
||||
# in a subshell. Otherwise, log the failure.
|
||||
if [ $result -eq 0 ] ; then
|
||||
dir="$(pwd)"
|
||||
[ ! -d "${!_STUB_DIR}" ] || dir="${!_STUB_DIR}"
|
||||
set +e
|
||||
( cd "$dir" ; eval "$command" )
|
||||
( eval "$command" )
|
||||
status="$?"
|
||||
set -e
|
||||
else
|
||||
|
|
|
@ -14,7 +14,6 @@ stub() {
|
|||
|
||||
export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan"
|
||||
export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run"
|
||||
export "${prefix}_STUB_DIR"="$FIXTURE_ROOT"
|
||||
export "${prefix}_STUB_END"=
|
||||
|
||||
export PATH="${BATS_TEST_DIRNAME}/stubs/${program}:$PATH"
|
||||
|
@ -28,7 +27,6 @@ unstub() {
|
|||
local program="$1"
|
||||
local prefix="$(echo "$program" | tr a-z A-Z)"
|
||||
|
||||
export "${prefix}_STUB_DIR"=
|
||||
export "${prefix}_STUB_END"=1
|
||||
|
||||
local path="${BATS_TEST_DIRNAME}/stubs/$program"
|
||||
|
|
Loading…
Reference in a new issue