|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +set -e |
| 4 | +set -x |
| 5 | + |
| 6 | +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." >/dev/null && pwd )" |
| 7 | + |
| 8 | +export LC_ALL=C |
| 9 | +export TEST_MYPYC=1 |
| 10 | +export MYPY_USE_MYPYC=1 |
| 11 | +export CC=clang MYPYC_OPT_LEVEL=0 |
| 12 | +export MYPY_TEST_PREFIX=${DIR} # not good, should be part of the mypy module, |
| 13 | + # like the mypyc test data is part of the mypyc module |
| 14 | + |
| 15 | +package=mypy |
| 16 | +module=mypy |
| 17 | +module2=mypyc |
| 18 | +slug=${TRAVIS_PULL_REQUEST_SLUG:=python/mypy} |
| 19 | +repo=https://github.com/${slug}.git |
| 20 | +run_tests() { # synchronize with pytest.ini |
| 21 | + py.test -o testpaths=${module}/test \ |
| 22 | + -o python_files=test*.py -o python_classes= \ |
| 23 | + -o python_functions= -nauto --pyargs ${module} |
| 24 | + py.test -o testpaths=${module2}/test \ |
| 25 | + -o python_files=test*.py -o python_classes= \ |
| 26 | + -o python_functions= -k 'not test_c_unit_test' -nauto --pyargs ${module2} |
| 27 | + |
| 28 | +} |
| 29 | +pipver=10.0.0 # minimum required version of pip given python3.6+ and --no-build-isolation |
| 30 | +setuptoolsver=24.2.0 # required to generate correct metadata for |
| 31 | + # python_requires |
| 32 | + |
| 33 | +rm -Rf testenv? || /bin/true |
| 34 | + |
| 35 | +export HEAD=${TRAVIS_PULL_REQUEST_SHA:-$(git rev-parse HEAD)} |
| 36 | + |
| 37 | +if [ "${RELEASE_SKIP}" != "head" ] |
| 38 | +then |
| 39 | + testenv1=$(mktemp -d -t "${package}_env1-XXXXXXXXXX") |
| 40 | + virtualenv "${testenv1}" -p python3 |
| 41 | + # First we test the head |
| 42 | + # shellcheck source=/dev/null |
| 43 | + source "${testenv1}/bin/activate" |
| 44 | + rm -Rf "${testenv1}/local" |
| 45 | + rm -f "${testenv1}/lib/python-wheels/setuptools"* \ |
| 46 | + && pip install --force-reinstall -U pip==${pipver} \ |
| 47 | + && pip install setuptools==${setuptoolsver} wheel |
| 48 | + pip install -rmypy-requirements.txt |
| 49 | + pip install -rtest-requirements.txt |
| 50 | + python setup.py build_ext |
| 51 | + ./runtests.py |
| 52 | + pip uninstall -y ${package} || true; pip install --no-build-isolation . |
| 53 | + post_install1_test=$(mktemp -d -t ${package}_env1_test-XXXXXXXXXX) |
| 54 | + # if there is a subdir named '${module}' py.test will execute tests |
| 55 | + # there instead of the installed module's tests |
| 56 | + pushd "${post_install1_test}" |
| 57 | + # shellcheck disable=SC2086 |
| 58 | + run_tests; popd |
| 59 | +fi |
| 60 | + |
| 61 | +testenv2=$(mktemp -d -t ${package}_env2-XXXXXXXXXX) |
| 62 | +testenv3=$(mktemp -d -t ${package}_env3-XXXXXXXXXX) |
| 63 | +testenv4=$(mktemp -d -t ${package}_env4-XXXXXXXXXX) |
| 64 | + |
| 65 | +virtualenv "${testenv2}" -p python3 |
| 66 | +virtualenv "${testenv3}" -p python3 |
| 67 | +virtualenv "${testenv4}" -p python3 |
| 68 | +rm -Rf "${testenv2}/local" "${testenv3}/local" "${testenv4}/local" |
| 69 | + |
| 70 | +# Secondly we test via pip |
| 71 | + |
| 72 | +cd "${testenv2}" |
| 73 | +# shellcheck source=/dev/null |
| 74 | +source bin/activate |
| 75 | +rm -f lib/python-wheels/setuptools* \ |
| 76 | + && pip install --force-reinstall -U pip==${pipver} \ |
| 77 | + && pip install setuptools==${setuptoolsver} wheel typing_extensions mypy_extensions typed_ast |
| 78 | +pip install --no-build-isolation -e "git+${repo}@${HEAD}#egg=${package}" |
| 79 | +cd src/${package} |
| 80 | +pip install -rmypy-requirements.txt |
| 81 | +pip install -rtest-requirements.txt |
| 82 | +python setup.py sdist bdist_wheel |
| 83 | +./runtests.py |
| 84 | +cp dist/${package}*tar.gz "${testenv3}/" |
| 85 | +pip uninstall -y ${package} || true; pip install --no-build-isolation . |
| 86 | +post_install2_test=$(mktemp -d -t "${package}_env2_test-XXXXXXXXXX") |
| 87 | +cd "${post_install2_test}" # no subdir named ${package} here, safe for py.testing the installed module |
| 88 | +# shellcheck disable=SC2086 |
| 89 | +run_tests |
| 90 | + |
| 91 | +# Is the distribution in testenv2 complete enough to build another |
| 92 | +# functional distribution? |
| 93 | + |
| 94 | +cd "${testenv3}" |
| 95 | +# shellcheck source=/dev/null |
| 96 | +source bin/activate |
| 97 | +rm -f lib/python-wheels/setuptools* \ |
| 98 | + && pip install --force-reinstall -U pip==${pipver} \ |
| 99 | + && pip install setuptools==${setuptoolsver} wheel |
| 100 | +pip install "-r${DIR}/mypy-requirements.txt" |
| 101 | +pip install "-r${DIR}/test-requirements.txt" |
| 102 | +mkdir out |
| 103 | +tar --extract --directory=out -z -f ${package}*.tar.gz |
| 104 | +cd out/${package}* |
| 105 | +python setup.py sdist bdist_wheel |
| 106 | +./runtests.py |
| 107 | +pip uninstall -y ${package} || true; pip install --no-build-isolation . |
| 108 | +post_install3_test=$(mktemp -d -t "${package}_env3_test-XXXXXXXXXX") |
| 109 | +pushd "${post_install3_test}" |
| 110 | +# shellcheck disable=SC2086 |
| 111 | +run_tests; popd |
0 commit comments