2014-01-17 07:14:30 -05:00
|
|
|
#!/usr/bin/env bats
|
|
|
|
|
|
|
|
load test_helper
|
|
|
|
export PYTHON_BUILD_SKIP_MIRROR=1
|
|
|
|
export PYTHON_BUILD_CACHE_PATH="$TMP/cache"
|
2016-02-12 22:49:28 -05:00
|
|
|
export PYTHON_BUILD_ARIA2_OPTS=
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
setup() {
|
|
|
|
mkdir "$PYTHON_BUILD_CACHE_PATH"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "packages are saved to download cache" {
|
2016-06-01 21:38:23 -04:00
|
|
|
stub aria2c "--allow-overwrite=true -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
install_fixture definitions/without-checksum
|
2016-02-07 19:01:02 -05:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
2014-01-17 07:14:30 -05:00
|
|
|
|
2016-02-08 07:27:46 -05:00
|
|
|
unstub aria2c
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "cached package without checksum" {
|
2016-02-08 07:27:46 -05:00
|
|
|
stub aria2c
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH"
|
|
|
|
|
|
|
|
install_fixture definitions/without-checksum
|
2016-02-07 19:01:02 -05:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
2014-01-17 07:14:30 -05:00
|
|
|
|
2016-02-08 07:27:46 -05:00
|
|
|
unstub aria2c
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "cached package with valid checksum" {
|
2014-06-02 22:41:47 -04:00
|
|
|
stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2016-02-08 07:27:46 -05:00
|
|
|
stub aria2c
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
cp "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_CACHE_PATH"
|
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
2016-02-07 19:01:02 -05:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
2014-01-17 07:14:30 -05:00
|
|
|
|
2016-02-08 07:27:46 -05:00
|
|
|
unstub aria2c
|
2014-06-02 22:41:47 -04:00
|
|
|
unstub shasum
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "cached package with invalid checksum falls back to mirror and updates cache" {
|
|
|
|
export PYTHON_BUILD_SKIP_MIRROR=
|
2014-06-02 22:41:47 -04:00
|
|
|
local checksum="ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
2014-06-02 22:41:47 -04:00
|
|
|
stub shasum true "echo invalid" "echo $checksum"
|
2016-02-12 02:08:59 -05:00
|
|
|
stub aria2c "--dry-run * : true" \
|
2016-06-01 21:38:23 -04:00
|
|
|
"--allow-overwrite=true -o * https://?*/$checksum : cp $FIXTURE_ROOT/package-1.0.0.tar.gz \$3"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
touch "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
|
|
|
|
|
|
|
|
install_fixture definitions/with-checksum
|
2016-02-07 19:01:02 -05:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
assert [ -e "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" ]
|
|
|
|
assert diff -q "${PYTHON_BUILD_CACHE_PATH}/package-1.0.0.tar.gz" "${FIXTURE_ROOT}/package-1.0.0.tar.gz"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
2016-02-08 07:27:46 -05:00
|
|
|
unstub aria2c
|
2014-06-02 22:41:47 -04:00
|
|
|
unstub shasum
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@test "nonexistent cache directory is ignored" {
|
2016-06-01 21:38:23 -04:00
|
|
|
stub aria2c "--allow-overwrite=true -o * http://example.com/* : cp $FIXTURE_ROOT/\${4##*/} \$3"
|
2014-01-17 07:14:30 -05:00
|
|
|
|
|
|
|
export PYTHON_BUILD_CACHE_PATH="${TMP}/nonexistent"
|
|
|
|
|
|
|
|
install_fixture definitions/without-checksum
|
2016-02-07 19:01:02 -05:00
|
|
|
|
|
|
|
assert_success
|
|
|
|
assert [ -x "${INSTALL_ROOT}/bin/package" ]
|
|
|
|
refute [ -d "$PYTHON_BUILD_CACHE_PATH" ]
|
2014-01-17 07:14:30 -05:00
|
|
|
|
2016-02-08 07:27:46 -05:00
|
|
|
unstub aria2c
|
2014-01-17 07:14:30 -05:00
|
|
|
}
|