From d00241e65c9e7599d15cbaf47ff34630da6461cd Mon Sep 17 00:00:00 2001 From: Masood Malekghassemi <soltanmm@users.noreply.github.com> Date: Thu, 3 Dec 2015 16:42:36 -0800 Subject: [PATCH] Use tox --- src/python/grpcio/.gitignore | 1 + src/python/grpcio/tox.ini | 21 +++++++++++ tools/jenkins/grpc_jenkins_slave/Dockerfile | 2 +- tools/run_tests/build_python.sh | 42 +++++---------------- tools/run_tests/run_python.sh | 18 +-------- 5 files changed, 34 insertions(+), 50 deletions(-) create mode 100644 src/python/grpcio/tox.ini diff --git a/src/python/grpcio/.gitignore b/src/python/grpcio/.gitignore index b5db3b3cfb..6f3d8673e7 100644 --- a/src/python/grpcio/.gitignore +++ b/src/python/grpcio/.gitignore @@ -9,6 +9,7 @@ dist/ .coverage .coverage.* .cache/ +.tox/ nosetests.xml doc/ _grpcio_metadata.py diff --git a/src/python/grpcio/tox.ini b/src/python/grpcio/tox.ini new file mode 100644 index 0000000000..9acc4d65d8 --- /dev/null +++ b/src/python/grpcio/tox.ini @@ -0,0 +1,21 @@ +# Tox (http://tox.testrun.org/) is a tool for running tests +# in multiple virtualenvs. This configuration file will run the +# test suite on all supported python versions. To use it, "pip install tox" +# and then run "tox" from this directory. + +[tox] +skipsdist = true +envlist = py27 + +[testenv] +commands = + {envpython} setup.py build_py + {envpython} setup.py test + coverage combine + coverage report --include='grpc/*' --omit='grpc/framework/alpha/*','grpc/early_adopter/*','grpc/framework/base/*','grpc/framework/face/*' +deps = + cython + coverage + oauth2client + protobuf +passenv = * diff --git a/tools/jenkins/grpc_jenkins_slave/Dockerfile b/tools/jenkins/grpc_jenkins_slave/Dockerfile index 5b8c24c076..916e5e83fb 100644 --- a/tools/jenkins/grpc_jenkins_slave/Dockerfile +++ b/tools/jenkins/grpc_jenkins_slave/Dockerfile @@ -131,7 +131,7 @@ RUN apt-get update && apt-get install -y \ # Install Python packages from PyPI RUN pip install pip --upgrade RUN pip install virtualenv -RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.0.0a2 +RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.0.0a2 tox # For sanity test RUN pip install simplejson mako diff --git a/tools/run_tests/build_python.sh b/tools/run_tests/build_python.sh index c6396c85b1..7db14ce9d1 100755 --- a/tools/run_tests/build_python.sh +++ b/tools/run_tests/build_python.sh @@ -35,35 +35,13 @@ cd $(dirname $0)/../.. ROOT=`pwd` GRPCIO=$ROOT/src/python/grpcio - -# Builds the testing environment. -make_virtualenv() { - virtualenv_name="python"$1"_virtual_environment" - if [ ! -d $virtualenv_name ] - then - # Build the entire virtual environment - virtualenv -p `which "python"$1` $virtualenv_name - source $virtualenv_name/bin/activate - - cd $GRPCIO - pip install -r requirements.txt - else - source $virtualenv_name/bin/activate - - cd $GRPCIO - pip install -U -r requirements.txt - fi - - export LD_LIBRARY_PATH=$ROOT/libs/$CONFIG - export DYLD_LIBRARY_PATH=$ROOT/libs/$CONFIG - export PATH=$ROOT/bins/$CONFIG:$ROOT/bins/$CONFIG/protobuf:$PATH - export CFLAGS="-I$ROOT/include -std=c89" - export LDFLAGS="-L$ROOT/libs/$CONFIG" - export GRPC_PYTHON_BUILD_WITH_CYTHON=1 - export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1 - python $GRPCIO/setup.py gather --test --install - python $GRPCIO/setup.py build_ext --inplace - python $GRPCIO/setup.py build_py -} - -make_virtualenv $1 +export LD_LIBRARY_PATH=$ROOT/libs/$CONFIG +export DYLD_LIBRARY_PATH=$ROOT/libs/$CONFIG +export PATH=$ROOT/bins/$CONFIG:$ROOT/bins/$CONFIG/protobuf:$PATH +export CFLAGS="-I$ROOT/include -std=c89" +export LDFLAGS="-L$ROOT/libs/$CONFIG" +export GRPC_PYTHON_BUILD_WITH_CYTHON=1 +export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1 + +cd $GRPCIO +tox --notest diff --git a/tools/run_tests/run_python.sh b/tools/run_tests/run_python.sh index 9bdfbfc60c..cc44a433bb 100755 --- a/tools/run_tests/run_python.sh +++ b/tools/run_tests/run_python.sh @@ -43,22 +43,6 @@ export LDFLAGS="-L$ROOT/libs/$CONFIG" export GRPC_PYTHON_BUILD_WITH_CYTHON=1 export GRPC_PYTHON_ENABLE_CYTHON_TRACING=1 -VIRTUALENV=python"$PYVER"_virtual_environment -source $VIRTUALENV/bin/activate - -(rm $GRPCIO/.coverage) || true -(rm $GRPCIO/.coverage.*) || true - -if python -u $GRPCIO/setup.py test; then - EXIT_CODE=0 -else - EXIT_CODE=$? -fi - -cp $GRPCIO/report.xml $ROOT - cd $GRPCIO -(coverage combine) || true -(coverage report --include='grpc/*' --omit='grpc/framework/alpha/*','grpc/early_adopter/*','grpc/framework/base/*''grpc/framework/face/*') || true +tox -exit $EXIT_CODE -- GitLab