blob: a3dca92a19ec1d8dfc6d391c5d2d43f7cbfb2ccf [file] [log] [blame]
Sergey Shepelev0112eff2017-05-05 06:46:43 +03001#!/bin/bash
2set -eux
3# By default, run tests with pytest-forked plugin,
4# disable in terminal for debugging, you may add --forked
5flag_forked="--forked"
6if [[ -z "${CONTINUOUS_INTEGRATION-}" ]] && [[ -t 1 ]] ; then
7 flag_forked=""
8fi
9test_flags=(
10 $@
11 $flag_forked
12 tests/
13)
14
Sergey Shepelev013682e2018-03-28 15:28:11 +030015main() {
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 Shepelev0112eff2017-05-05 06:46:43 +030042 fi
Sergey Shepelev013682e2018-03-28 15:28:11 +030043 if [[ ! -d ./venv-36 ]] ; then
44 virtualenv --python=python3.6 ./venv-36
45 fi
46
Sergey Shepelev0112eff2017-05-05 06:46:43 +030047 ./venv-27/bin/pip install -e . -r requirements-test.txt
Sergey Shepelev013682e2018-03-28 15:28:11 +030048 ./venv-27/bin/pytest ${test_flags[@]}
Sergey Shepelev0112eff2017-05-05 06:46:43 +030049 ./venv-36/bin/pip install -e . -r requirements-test.txt
Sergey Shepelev013682e2018-03-28 15:28:11 +030050 ./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 Shepelev0112eff2017-05-05 06:46:43 +030061 fi
Sergey Shepelev013682e2018-03-28 15:28:11 +030062 rm -rf ./_httplib2_test_cache
63}
Sergey Shepelev55d87802018-03-17 02:33:19 +030064
Sergey Shepelev013682e2018-03-28 15:28:11 +030065install_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 Shepelev55d87802018-03-17 02:33:19 +030075
Sergey Shepelev013682e2018-03-28 15:28:11 +030076main "$@"