#!/usr/bin/env bats load test_helper export PYTHON_BUILD_SKIP_MIRROR=1 export PYTHON_BUILD_CACHE_PATH= export PYTHON_BUILD_CURL_OPTS= setup() { ensure_not_found_in_path aria2c } @test "package URL without checksum" { stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/without-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl } @test "package URL with valid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } @test "package URL with invalid checksum" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-invalid-checksum assert_failure refute [ -f "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } @test "package URL with checksum but no shasum support" { stub shasum false stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } @test "package URL with valid md5 checksum" { stub md5 true "echo 83e6d7725e20166024a1eb74cde80677" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-md5-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub md5 } @test "package URL with md5 checksum but no md5 support" { stub md5 false stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-md5-checksum assert_success assert [ -x "${INSTALL_ROOT}/bin/package" ] unstub curl unstub md5 } @test "package with invalid checksum" { stub shasum true "echo invalid" stub curl "-q -o * -*S* http://example.com/* : cp $FIXTURE_ROOT/\${5##*/} \$3" install_fixture definitions/with-checksum assert_failure refute [ -f "${INSTALL_ROOT}/bin/package" ] unstub curl unstub shasum } @test "existing tarball in build location is reused" { stub shasum true "echo ba988b1bb4250dee0b9dd3d4d722f9c64b2bacfc805d1b6eba7426bda72dd3c5" stub curl false stub curl false stub wget false export -n PYTHON_BUILD_CACHE_PATH export PYTHON_BUILD_BUILD_PATH="${TMP}/build" mkdir -p "$PYTHON_BUILD_BUILD_PATH" ln -s "${FIXTURE_ROOT}/package-1.0.0.tar.gz" "$PYTHON_BUILD_BUILD_PATH" run_inline_definition <