2013-10-26 06:32:03 +02:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
export RUBY_BUILD_SKIP_MIRROR=1
|
|
|
|
export RUBY_BUILD_CACHE_PATH=
|
|
|
|
|
2014-04-16 17:35:38 +02:00
|
|
|
setup() {
|
|
|
|
export RUBY_BUILD_BUILD_PATH="${TMP}/source"
|
|
|
|
mkdir -p "${RUBY_BUILD_BUILD_PATH}"
|
|
|
|
}
|
|
|
|
|
2013-10-26 06:32:03 +02:00
|
|
|
@test "failed download displays error message" {
|
2016-06-10 07:11:26 +02:00
|
|
|
stub curl false
|
2013-10-26 06:32:03 +02:00
|
|
|
|
|
|
|
install_fixture definitions/without-checksum
|
|
|
|
assert_failure
|
|
|
|
assert_output_contains "error: failed to download package-1.0.0.tar.gz"
|
|
|
|
}
|
2014-04-13 11:29:40 +02:00
|
|
|
|
2019-11-04 14:44:03 +01:00
|
|
|
@test "no download tool" {
|
|
|
|
export -n RUBY_BUILD_HTTP_CLIENT
|
|
|
|
clean_path="$(remove_commands_from_path curl wget aria2c)"
|
|
|
|
|
|
|
|
PATH="$clean_path" install_fixture definitions/without-checksum
|
|
|
|
assert_failure
|
|
|
|
assert_output_contains 'error: install `curl`, `wget`, or `aria2c` to download packages'
|
|
|
|
}
|
|
|
|
|
2016-06-10 08:02:57 +02:00
|
|
|
@test "using aria2c if available" {
|
2018-04-26 04:07:32 +02:00
|
|
|
export RUBY_BUILD_ARIA2_OPTS=
|
2018-08-22 12:50:02 +02:00
|
|
|
export -n RUBY_BUILD_HTTP_CLIENT
|
2023-11-07 10:17:54 +01:00
|
|
|
stub aria2c "--allow-overwrite=true --no-conf=true --console-log-level=warn --stderr -o * http://example.com/* : cp $FIXTURE_ROOT/\${7##*/} \$6"
|
2016-06-10 08:02:57 +02:00
|
|
|
|
|
|
|
install_fixture definitions/without-checksum
|
|
|
|
assert_success
|
2023-11-07 10:17:54 +01:00
|
|
|
assert_output_contains "Downloading package-1.0.0.tar.gz..."
|
2016-06-10 08:02:57 +02:00
|
|
|
unstub aria2c
|
|
|
|
}
|
|
|
|
|
2014-04-13 11:29:40 +02:00
|
|
|
@test "fetching from git repository" {
|
|
|
|
stub git "clone --depth 1 --branch master http://example.com/packages/package.git package-dev : mkdir package-dev"
|
|
|
|
|
|
|
|
run_inline_definition <<DEF
|
|
|
|
install_git "package-dev" "http://example.com/packages/package.git" master copy
|
|
|
|
DEF
|
|
|
|
assert_success
|
2023-11-07 10:17:54 +01:00
|
|
|
assert_output_contains "Cloning http://example.com/packages/package.git..."
|
2014-04-13 11:29:40 +02:00
|
|
|
unstub git
|
|
|
|
}
|
|
|
|
|
|
|
|
@test "updating existing git repository" {
|
2014-04-16 17:35:38 +02:00
|
|
|
mkdir -p "${RUBY_BUILD_BUILD_PATH}/package-dev"
|
|
|
|
stub git \
|
2023-10-16 14:40:04 +02:00
|
|
|
"-C package-dev fetch --depth 1 origin +master : true" \
|
|
|
|
"-C package-dev checkout -q -B master origin/master : true"
|
2014-04-13 11:29:40 +02:00
|
|
|
|
|
|
|
run_inline_definition <<DEF
|
|
|
|
install_git "package-dev" "http://example.com/packages/package.git" master copy
|
|
|
|
DEF
|
|
|
|
assert_success
|
2023-11-07 10:17:54 +01:00
|
|
|
assert_output_contains "Cloning http://example.com/packages/package.git..."
|
2014-04-13 11:29:40 +02:00
|
|
|
unstub git
|
|
|
|
}
|