Commit c1bd4134 by Mislav Marohnić

Merge branch 'failed-download'

parents 85f54709 51d8e512
......@@ -244,13 +244,12 @@ fetch_tarball() {
tar_args="${tar_args/z/j}"
fi
symlink_tarball_from_cache "$package_filename" "$checksum" || {
if ! symlink_tarball_from_cache "$package_filename" "$checksum"; then
echo "Downloading ${package_filename}..." >&2
{ http head "$mirror_url" &&
download_tarball "$mirror_url" "$package_filename" "$checksum"
} ||
http head "$mirror_url" &&
download_tarball "$mirror_url" "$package_filename" "$checksum" ||
download_tarball "$package_url" "$package_filename" "$checksum"
}
fi
{ if tar $tar_args "$package_filename"; then
if [ -z "$KEEP_BUILD_PATH" ]; then
......@@ -283,9 +282,12 @@ download_tarball() {
echo "-> $package_url" >&2
{ http get "$package_url" "$package_filename"
verify_checksum "$package_filename" "$checksum"
} >&4 2>&1 || return 1
if http get "$package_url" "$package_filename" >&4 2>&1; then
verify_checksum "$package_filename" "$checksum" >&4 2>&1 || return 1
else
echo "error: failed to download $package_filename" >&2
return 1
fi
if [ -n "$RUBY_BUILD_CACHE_PATH" ]; then
local cached_package_filename="${RUBY_BUILD_CACHE_PATH}/$package_filename"
......
#!/usr/bin/env bats
load test_helper
export RUBY_BUILD_SKIP_MIRROR=1
export RUBY_BUILD_CACHE_PATH=
@test "failed download displays error message" {
stub curl false
install_fixture definitions/without-checksum
assert_failure
assert_output_contains "> http://example.com/packages/package-1.0.0.tar.gz"
assert_output_contains "error: failed to download package-1.0.0.tar.gz"
}
......@@ -94,3 +94,12 @@ assert_output() {
fi
assert_equal "$expected" "$output"
}
assert_output_contains() {
local expected="$1"
echo "$output" | grep -F "$expected" >/dev/null || {
{ echo "expected output to contain $expected"
echo "actual: $output"
} | flunk
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment