Commit 955dbc61 authored by Jason Madden's avatar Jason Madden

Add Tox environments for running linters and include one in the default env...

Add Tox environments for running linters and include one in the default env list. Add a Tox environment for running leak tests and one for doing both, but do not run them by default. Unify the Travis and Tox configurations, and make Travis run both leak and lint tests. Switch the leak test from using gettotalrefcount (only available in debug builds) to using len(gc.get_objects()); while this is not exactly the same thing, it make be close enough, and it's avaialble to every Python developer unlike gettotalrefcount.
parent 3b8e9544
[pep8] [pep8]
ignore=E702,E265,E402,E731,E266 ignore=E702,E265,E402,E731,E266,E261
max_line_length=160 max_line_length=160
exclude=.git,build,2.6,2.7,2.7pypy,3.3,test_support.py,test_queue.py,patched_tests_setup.py,test_threading_2.py,lock_tests.py,_sslgte279.py exclude=.tox,.git,build,2.6,2.7,2.7pypy,3.3,test_support.py,test_queue.py,patched_tests_setup.py,test_threading_2.py,lock_tests.py,_sslgte279.py
language: python language: python
sudo: false sudo: false
python: python:
- "2.6" - TOXENV=py26
- "2.7" - TOXENV=py27
- "3.3" - TOXENV=py33
- "3.4" - TOXENV=py34
- "pypy" - TOXENV=pypy
- TOXENV=travis-lint
install:
- travis_retry pip install tox
script: script:
- if [[ $TRAVIS_PYTHON_VERSION == 'pypy' ]]; then NWORKERS=4 PYTHON=pypy make travis_pypy; fi - tox
- if [[ $TRAVIS_PYTHON_VERSION != 'pypy' ]]; then NWORKERS=4 PYTHON=python$TRAVIS_PYTHON_VERSION make travis_cpython; fi
notifications: notifications:
email: false email: false
...@@ -35,7 +35,7 @@ doc: ...@@ -35,7 +35,7 @@ doc:
cd doc && PYTHONPATH=.. make html cd doc && PYTHONPATH=.. make html
whitespace: whitespace:
! find . -not -path "./.git/*" -not -path "./build/*" -not -path "./libev/*" -not -path "./c-ares/*" -not -path "./doc/_build/*" -not -path "./doc/mytheme/static/*" -type f | xargs egrep -l " $$" ! find . -not -path "./.tox/*" -not -path "*/__pycache__/*" -not -path "*.pyc" -not -path "./.git/*" -not -path "./build/*" -not -path "./libev/*" -not -path "./gevent/libev/*" -not -path "./gevent.egg-info/*" -not -path "./dist/*" -not -path "./.DS_Store" -not -path "./c-ares/*" -not -path "./gevent/gevent.*.[ch]" -not -path "./gevent/core.pyx" -not -path "./doc/_build/*" -not -path "./doc/mytheme/static/*" -type f | xargs egrep -l " $$"
pep8: pep8:
${PYTHON} `which pep8` . ${PYTHON} `which pep8` .
...@@ -43,7 +43,7 @@ pep8: ...@@ -43,7 +43,7 @@ pep8:
pyflakes: pyflakes:
${PYTHON} util/pyflakes.py ${PYTHON} util/pyflakes.py
lint: whitespace pep8 pyflakes lint: whitespace pyflakes pep8
travistest: travistest:
which ${PYTHON} which ${PYTHON}
...@@ -66,11 +66,13 @@ fulltoxtest: ...@@ -66,11 +66,13 @@ fulltoxtest:
cd greentest && GEVENT_RESOLVER=ares GEVENTARES_SERVERS=8.8.8.8 python testrunner.py --config ../known_failures.py --ignore tests_that_dont_use_resolver.txt cd greentest && GEVENT_RESOLVER=ares GEVENTARES_SERVERS=8.8.8.8 python testrunner.py --config ../known_failures.py --ignore tests_that_dont_use_resolver.txt
cd greentest && GEVENT_FILE=thread python testrunner.py --config ../known_failures.py `grep -l subprocess test_*.py` cd greentest && GEVENT_FILE=thread python testrunner.py --config ../known_failures.py `grep -l subprocess test_*.py`
leaktest:
GEVENTSETUP_EV_VERIFY=3 GEVENTTEST_LEAKCHECK=1 make travistest
bench: bench:
${PYTHON} greentest/bench_sendall.py ${PYTHON} greentest/bench_sendall.py
travis_pypy: travis_pypy:
# no need to repeat linters here
which ${PYTHON} which ${PYTHON}
${PYTHON} --version ${PYTHON} --version
${PYTHON} setup.py install ${PYTHON} setup.py install
...@@ -82,6 +84,9 @@ travis_cpython: ...@@ -82,6 +84,9 @@ travis_cpython:
make travistest make travistest
travis_test_linters:
make lint
make leaktest
.PHONY: clean all doc pep8 whitespace pyflakes lint travistest travis .PHONY: clean all doc pep8 whitespace pyflakes lint travistest travis
...@@ -85,7 +85,7 @@ def wrap_timeout(timeout, method): ...@@ -85,7 +85,7 @@ def wrap_timeout(timeout, method):
def wrap_refcount(method): def wrap_refcount(method):
if gettotalrefcount is None: if not os.getenv('GEVENTTEST_LEAKCHECK'):
return method return method
@wraps(method) @wraps(method)
...@@ -98,7 +98,7 @@ def wrap_refcount(method): ...@@ -98,7 +98,7 @@ def wrap_refcount(method):
gc.disable() gc.disable()
try: try:
while True: while True:
d = gettotalrefcount() d = len(gc.get_objects())
self.setUp() self.setUp()
method(self, *args, **kwargs) method(self, *args, **kwargs)
self.tearDown() self.tearDown()
...@@ -106,7 +106,7 @@ def wrap_refcount(method): ...@@ -106,7 +106,7 @@ def wrap_refcount(method):
sys.modules['urlparse'].clear_cache() sys.modules['urlparse'].clear_cache()
if 'urllib.parse' in sys.modules: if 'urllib.parse' in sys.modules:
sys.modules['urllib.parse'].clear_cache() sys.modules['urllib.parse'].clear_cache()
d = gettotalrefcount() - d d = len(gc.get_objects()) - d
deltas.append(d) deltas.append(d)
# the following configurations are classified as "no leak" # the following configurations are classified as "no leak"
# [0, 0] # [0, 0]
......
[tox] [tox]
envlist = envlist =
py26,py27,pypy,py33,py34 py26,py27,pypy,py33,py34,lint
[testenv] [testenv]
deps = deps =
...@@ -17,3 +17,27 @@ commands = ...@@ -17,3 +17,27 @@ commands =
[testenv:pypy] [testenv:pypy]
deps = deps =
[testenv:lint]
basepython =
python2.7
deps =
{[testenv]deps}
pep8
pyflakes
commands =
make lint
[testenv:travis-lint]
basepython =
python2.7
deps =
{[testenv:lint]deps}
commands =
make travis_test_linters
[testenv:leak]
basepython =
python2.7
commonds =
make leaktest
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment