Sergey Shepelev | 0112eff | 2017-05-05 06:46:43 +0300 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | set -eux |
| 3 | # By default, run tests with pytest-forked plugin, |
| 4 | # disable in terminal for debugging, you may add --forked |
| 5 | flag_forked="--forked" |
| 6 | if [[ -z "${CONTINUOUS_INTEGRATION-}" ]] && [[ -t 1 ]] ; then |
| 7 | flag_forked="" |
| 8 | fi |
| 9 | test_flags=( |
| 10 | $@ |
| 11 | $flag_forked |
| 12 | tests/ |
| 13 | ) |
| 14 | |
Sergey Shepelev | 013682e | 2018-03-28 15:28:11 +0300 | [diff] [blame] | 15 | main() { |
| 16 | cd "$( dirname "${BASH_SOURCE[0]}" )/.." |
| 17 | if [[ -n "${CONTINUOUS_INTEGRATION-}" ]] ; then |
| 18 | case "${test_group-}" in |
| 19 | pep8) |
| 20 | if [[ "${TRAVIS_PYTHON_VERSION}" = "2.7" ]] ; then |
| 21 | flake8 python2/ |
| 22 | else |
| 23 | flake8 python3/ tests/ |
| 24 | fi |
| 25 | ;; |
| 26 | package) |
| 27 | # TODO: sdist bdist_wheel |
| 28 | # but wheels don't roll well with our 2/3 split code base |
| 29 | python setup.py sdist |
| 30 | install_check_version "pip" |
| 31 | ;; |
| 32 | *) |
| 33 | pip install -e . |
| 34 | httplib2_test_still_run_skipped=1 pytest --fulltrace -k test_303 $@ tests/ || true |
| 35 | httplib2_test_still_run_skipped=1 pytest --fulltrace -k test_head_301 $@ tests/ || true |
| 36 | pytest --fulltrace ${test_flags[@]} |
| 37 | ;; |
| 38 | esac |
| 39 | else |
| 40 | if [[ ! -d ./venv-27 ]] ; then |
| 41 | virtualenv --python=python2.7 ./venv-27 |
Sergey Shepelev | 0112eff | 2017-05-05 06:46:43 +0300 | [diff] [blame] | 42 | fi |
Sergey Shepelev | 013682e | 2018-03-28 15:28:11 +0300 | [diff] [blame] | 43 | if [[ ! -d ./venv-36 ]] ; then |
| 44 | virtualenv --python=python3.6 ./venv-36 |
| 45 | fi |
| 46 | |
Sergey Shepelev | 0112eff | 2017-05-05 06:46:43 +0300 | [diff] [blame] | 47 | ./venv-27/bin/pip install -e . -r requirements-test.txt |
Sergey Shepelev | 013682e | 2018-03-28 15:28:11 +0300 | [diff] [blame] | 48 | ./venv-27/bin/pytest ${test_flags[@]} |
Sergey Shepelev | 0112eff | 2017-05-05 06:46:43 +0300 | [diff] [blame] | 49 | ./venv-36/bin/pip install -e . -r requirements-test.txt |
Sergey Shepelev | 013682e | 2018-03-28 15:28:11 +0300 | [diff] [blame] | 50 | ./venv-36/bin/pytest ${test_flags[@]} |
| 51 | |
| 52 | # FIXME: too many errors |
| 53 | # ./venv-27/bin/flake8 python2/ |
| 54 | # ./venv-36/bin/flake8 python3/ tests/ |
| 55 | |
| 56 | # TODO: sdist bdist_wheel |
| 57 | # but wheels don't roll well with our 2/3 split code base |
| 58 | ./venv-36/bin/python setup.py sdist |
| 59 | install_check_version "./venv-27/bin/pip" |
| 60 | install_check_version "./venv-36/bin/pip" |
Sergey Shepelev | 0112eff | 2017-05-05 06:46:43 +0300 | [diff] [blame] | 61 | fi |
Sergey Shepelev | 013682e | 2018-03-28 15:28:11 +0300 | [diff] [blame] | 62 | rm -rf ./_httplib2_test_cache |
| 63 | } |
Sergey Shepelev | 55d8780 | 2018-03-17 02:33:19 +0300 | [diff] [blame] | 64 | |
Sergey Shepelev | 013682e | 2018-03-28 15:28:11 +0300 | [diff] [blame] | 65 | install_check_version() { |
| 66 | local pip="$1" |
| 67 | $pip install dist/httplib2* |
| 68 | version_source=$(cd python3 ; python3 -Es -c 'import httplib2;print(httplib2.__version__)') |
| 69 | version_installed=$($pip show httplib2 |fgrep Version |cut -d' ' -f2) |
| 70 | if [[ "$version_source" != "$version_installed" ]] ; then |
| 71 | echo "error: installed package version=$version_installed does not match source=$version_source" >&2 |
| 72 | exit 1 |
| 73 | fi |
| 74 | } |
Sergey Shepelev | 55d8780 | 2018-03-17 02:33:19 +0300 | [diff] [blame] | 75 | |
Sergey Shepelev | 013682e | 2018-03-28 15:28:11 +0300 | [diff] [blame] | 76 | main "$@" |