Commit a9a274e6 by Mislav Marohnić

Fix broken test suite

Fixes breakage caused by curl arguments change in
d0912e4f
parent 9f77dfc4
...@@ -11,7 +11,7 @@ setup() { ...@@ -11,7 +11,7 @@ setup() {
@test "packages are saved to download cache" { @test "packages are saved to download cache" {
stub md5 true 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 install_fixture definitions/without-checksum
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
...@@ -58,7 +58,8 @@ setup() { ...@@ -58,7 +58,8 @@ setup() {
local checksum="83e6d7725e20166024a1eb74cde80677" local checksum="83e6d7725e20166024a1eb74cde80677"
stub md5 true "echo invalid" "echo $checksum" 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" touch "${RUBY_BUILD_CACHE_PATH}/package-1.0.0.tar.gz"
...@@ -75,7 +76,7 @@ setup() { ...@@ -75,7 +76,7 @@ setup() {
@test "nonexistent cache directory is ignored" { @test "nonexistent cache directory is ignored" {
stub md5 true 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" export RUBY_BUILD_CACHE_PATH="${TMP}/nonexistent"
......
...@@ -7,7 +7,7 @@ export RUBY_BUILD_CACHE_PATH= ...@@ -7,7 +7,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL without checksum" { @test "package URL without checksum" {
stub md5 true 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 install_fixture definitions/without-checksum
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
...@@ -20,7 +20,7 @@ export RUBY_BUILD_CACHE_PATH= ...@@ -20,7 +20,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL with valid checksum" { @test "package URL with valid checksum" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677" 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 install_fixture definitions/with-checksum
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
...@@ -33,7 +33,7 @@ export RUBY_BUILD_CACHE_PATH= ...@@ -33,7 +33,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL with invalid checksum" { @test "package URL with invalid checksum" {
stub md5 true "echo 83e6d7725e20166024a1eb74cde80677" 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 install_fixture definitions/with-invalid-checksum
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
...@@ -46,7 +46,7 @@ export RUBY_BUILD_CACHE_PATH= ...@@ -46,7 +46,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package URL with checksum but no MD5 support" { @test "package URL with checksum but no MD5 support" {
stub md5 false 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 install_fixture definitions/with-checksum
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
...@@ -59,7 +59,7 @@ export RUBY_BUILD_CACHE_PATH= ...@@ -59,7 +59,7 @@ export RUBY_BUILD_CACHE_PATH=
@test "package with invalid checksum" { @test "package with invalid checksum" {
stub md5 true "echo invalid" 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 install_fixture definitions/with-checksum
[ "$status" -eq 1 ] [ "$status" -eq 1 ]
......
...@@ -8,9 +8,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com ...@@ -8,9 +8,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
@test "package URL without checksum bypasses mirror" { @test "package URL without checksum bypasses mirror" {
stub md5 true 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 install_fixture definitions/without-checksum
echo "$output" >&2
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ -x "${INSTALL_ROOT}/bin/package" ] [ -x "${INSTALL_ROOT}/bin/package" ]
...@@ -21,7 +22,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com ...@@ -21,7 +22,7 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
@test "package URL with checksum but no MD5 support bypasses mirror" { @test "package URL with checksum but no MD5 support bypasses mirror" {
stub md5 false 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 install_fixture definitions/with-checksum
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
...@@ -37,7 +38,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com ...@@ -37,7 +38,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum" local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum"
stub md5 true "echo $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 install_fixture definitions/with-checksum
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
...@@ -51,10 +53,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com ...@@ -51,10 +53,10 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
@test "package is fetched from original URL if mirror download fails" { @test "package is fetched from original URL if mirror download fails" {
local checksum="83e6d7725e20166024a1eb74cde80677" local checksum="83e6d7725e20166024a1eb74cde80677"
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum" 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 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 install_fixture definitions/with-checksum
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
...@@ -68,12 +70,14 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com ...@@ -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" { @test "package is fetched from original URL if mirror download checksum is invalid" {
local checksum="83e6d7725e20166024a1eb74cde80677" local checksum="83e6d7725e20166024a1eb74cde80677"
local mirror_url="${RUBY_BUILD_MIRROR_URL}/$checksum" 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 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 install_fixture definitions/with-checksum
echo "$output" >&2
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
[ -x "${INSTALL_ROOT}/bin/package" ] [ -x "${INSTALL_ROOT}/bin/package" ]
...@@ -87,7 +91,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com ...@@ -87,7 +91,8 @@ export RUBY_BUILD_MIRROR_URL=http://mirror.example.com
local checksum="83e6d7725e20166024a1eb74cde80677" local checksum="83e6d7725e20166024a1eb74cde80677"
stub md5 true "echo $checksum" 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 install_fixture definitions/with-checksum
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
......
...@@ -8,7 +8,6 @@ PROGRAM="$(echo "$program" | tr a-z A-Z)" ...@@ -8,7 +8,6 @@ PROGRAM="$(echo "$program" | tr a-z A-Z)"
_STUB_PLAN="${PROGRAM}_STUB_PLAN" _STUB_PLAN="${PROGRAM}_STUB_PLAN"
_STUB_RUN="${PROGRAM}_STUB_RUN" _STUB_RUN="${PROGRAM}_STUB_RUN"
_STUB_DIR="${PROGRAM}_STUB_DIR"
_STUB_INDEX="${PROGRAM}_STUB_INDEX" _STUB_INDEX="${PROGRAM}_STUB_INDEX"
_STUB_RESULT="${PROGRAM}_STUB_RESULT" _STUB_RESULT="${PROGRAM}_STUB_RESULT"
_STUB_END="${PROGRAM}_STUB_END" _STUB_END="${PROGRAM}_STUB_END"
...@@ -62,10 +61,8 @@ while IFS= read -r line; do ...@@ -62,10 +61,8 @@ while IFS= read -r line; do
# If the arguments matched, evaluate the command # If the arguments matched, evaluate the command
# in a subshell. Otherwise, log the failure. # in a subshell. Otherwise, log the failure.
if [ $result -eq 0 ] ; then if [ $result -eq 0 ] ; then
dir="$(pwd)"
[ ! -d "${!_STUB_DIR}" ] || dir="${!_STUB_DIR}"
set +e set +e
( cd "$dir" ; eval "$command" ) ( eval "$command" )
status="$?" status="$?"
set -e set -e
else else
......
...@@ -14,7 +14,6 @@ stub() { ...@@ -14,7 +14,6 @@ stub() {
export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan" export "${prefix}_STUB_PLAN"="${TMP}/${program}-stub-plan"
export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run" export "${prefix}_STUB_RUN"="${TMP}/${program}-stub-run"
export "${prefix}_STUB_DIR"="$FIXTURE_ROOT"
export "${prefix}_STUB_END"= export "${prefix}_STUB_END"=
export PATH="${BATS_TEST_DIRNAME}/stubs/${program}:$PATH" export PATH="${BATS_TEST_DIRNAME}/stubs/${program}:$PATH"
...@@ -28,7 +27,6 @@ unstub() { ...@@ -28,7 +27,6 @@ unstub() {
local program="$1" local program="$1"
local prefix="$(echo "$program" | tr a-z A-Z)" local prefix="$(echo "$program" | tr a-z A-Z)"
export "${prefix}_STUB_DIR"=
export "${prefix}_STUB_END"=1 export "${prefix}_STUB_END"=1
local path="${BATS_TEST_DIRNAME}/stubs/$program" local path="${BATS_TEST_DIRNAME}/stubs/$program"
......
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