Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit f1db20b

Browse files
authored
Clean up tox.ini (#8963)
... and disable coverage tracking for mypy and friends.
1 parent c9c1c9d commit f1db20b

File tree

3 files changed

+34
-19
lines changed

3 files changed

+34
-19
lines changed

changelog.d/8963.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Clean up tox.ini file; disable coverage checking for non-test runs.

mypy.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ show_error_codes = True
77
show_traceback = True
88
mypy_path = stubs
99
warn_unreachable = True
10+
11+
# To find all folders that pass mypy you run:
12+
#
13+
# find synapse/* -type d -not -name __pycache__ -exec bash -c "mypy '{}' > /dev/null" \; -print
14+
1015
files =
1116
scripts-dev/sign_json,
1217
synapse/api,

tox.ini

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ deps =
77
python-subunit
88
junitxml
99
coverage
10-
coverage-enable-subprocess
10+
11+
# this is pinned since it's a bit of an obscure package.
12+
coverage-enable-subprocess==1.0
1113

1214
# cyptography 2.2 requires setuptools >= 18.5
1315
#
@@ -23,29 +25,37 @@ deps =
2325
# install the "enum34" dependency of cryptography.
2426
pip>=10
2527

26-
setenv =
27-
PYTHONDONTWRITEBYTECODE = no_byte_code
28-
COVERAGE_PROCESS_START = {toxinidir}/.coveragerc
29-
3028
[testenv]
3129
deps =
3230
{[base]deps}
3331
extras = all, test
3432

35-
whitelist_externals =
36-
sh
37-
3833
setenv =
39-
{[base]setenv}
34+
# use a postgres db for tox environments with "-postgres" in the name
35+
# (see https://tox.readthedocs.io/en/3.20.1/config.html#factors-and-factor-conditional-settings)
4036
postgres: SYNAPSE_POSTGRES = 1
37+
38+
# this is used by .coveragerc to refer to the top of our tree.
4139
TOP={toxinidir}
4240

4341
passenv = *
4442

4543
commands =
46-
/usr/bin/find "{toxinidir}" -name '*.pyc' -delete
47-
# Add this so that coverage will run on subprocesses
48-
{envbindir}/coverage run "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
44+
# the "env" invocation enables coverage checking for sub-processes. This is
45+
# particularly important when running trial with `-j`, since that will make
46+
# it run tests in a subprocess, whose coverage would otherwise not be
47+
# tracked. (It also makes an explicit `coverage run` command redundant.)
48+
#
49+
# (See https://coverage.readthedocs.io/en/coverage-5.3/subprocess.html.
50+
# Note that the `coverage.process_startup()` call is done by
51+
# `coverage-enable-subprocess`.)
52+
#
53+
# we use "env" rather than putting a value in `setenv` so that it is not
54+
# inherited by other tox environments.
55+
#
56+
# keep this in sync with the copy in `testenv:py35-old`.
57+
#
58+
/usr/bin/env COVERAGE_PROCESS_START={toxinidir}/.coveragerc "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
4959

5060
# As of twisted 16.4, trial tries to import the tests as a package (previously
5161
# it loaded the files explicitly), which means they need to be on the
@@ -80,10 +90,9 @@ deps =
8090

8191
lxml
8292
coverage
83-
coverage-enable-subprocess
93+
coverage-enable-subprocess==1.0
8494

8595
commands =
86-
/usr/bin/find "{toxinidir}" -name '*.pyc' -delete
8796
# Make all greater-thans equals so we test the oldest version of our direct
8897
# dependencies, but make the pyopenssl 17.0, which can work against an
8998
# OpenSSL 1.1 compiled cryptography (as older ones don't compile on Travis).
@@ -92,7 +101,11 @@ commands =
92101
# Install Synapse itself. This won't update any libraries.
93102
pip install -e ".[test]"
94103

95-
{envbindir}/coverage run "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
104+
# we have to duplicate the command from `testenv` rather than refer to it
105+
# as `{[testenv]commands}`, because we run on ubuntu xenial, which has
106+
# tox 2.3.1, and https://github.com/tox-dev/tox/issues/208.
107+
#
108+
/usr/bin/env COVERAGE_PROCESS_START={toxinidir}/.coveragerc "{envbindir}/trial" {env:TRIAL_FLAGS:} {posargs:tests} {env:TOXSUFFIX:}
96109

97110
[testenv:benchmark]
98111
deps =
@@ -157,7 +170,3 @@ deps =
157170
{[base]deps}
158171
extras = all,mypy
159172
commands = mypy
160-
161-
# To find all folders that pass mypy you run:
162-
#
163-
# find synapse/* -type d -not -name __pycache__ -exec bash -c "mypy '{}' > /dev/null" \; -print

0 commit comments

Comments
 (0)