| 1 | # Tox (http://tox.testrun.org/) is a tool for running tests |
|---|
| 2 | # in multiple virtualenvs. This configuration file will run the |
|---|
| 3 | # test suite on all supported python versions. To use it, "pip install tox" |
|---|
| 4 | # and then run "tox" from this directory. |
|---|
| 5 | |
|---|
| 6 | # Map Python versions in GitHub Actions to tox environments to run, for use by |
|---|
| 7 | # the tox-gh-actions package. |
|---|
| 8 | [gh-actions] |
|---|
| 9 | python = |
|---|
| 10 | 3.9: py39-coverage |
|---|
| 11 | 3.10: py310-coverage |
|---|
| 12 | 3.11: py311-coverage |
|---|
| 13 | 3.12: py312-coverage |
|---|
| 14 | pypy-3.9: pypy39 |
|---|
| 15 | |
|---|
| 16 | [pytest] |
|---|
| 17 | twisted = 1 |
|---|
| 18 | |
|---|
| 19 | [tox] |
|---|
| 20 | envlist = typechecks,codechecks,py{39,310,311,312}-{coverage},pypy39,integration |
|---|
| 21 | minversion = 4 |
|---|
| 22 | |
|---|
| 23 | [testenv] |
|---|
| 24 | # Install code the real way, for maximum realism. |
|---|
| 25 | usedevelop = False |
|---|
| 26 | |
|---|
| 27 | passenv = TAHOE_LAFS_*,PIP_*,SUBUNITREPORTER_*,USERPROFILE,HOMEDRIVE,HOMEPATH,COLUMNS |
|---|
| 28 | deps = |
|---|
| 29 | # We pull in certify *here* to avoid bug #2913. Basically if a |
|---|
| 30 | # `setup_requires=...` causes a package to be installed (with setuptools) |
|---|
| 31 | # then it'll fail on certain platforms (travis's OX-X 10.12, Slackware |
|---|
| 32 | # 14.2) because PyPI's TLS requirements (TLS >= 1.2) are incompatible with |
|---|
| 33 | # the old TLS clients available to those systems. Installing it ahead of |
|---|
| 34 | # time (with pip) avoids this problem. |
|---|
| 35 | # |
|---|
| 36 | # We don't pin an exact version of it because it contains CA certificates |
|---|
| 37 | # which necessarily change over time. Pinning this is guaranteed to cause |
|---|
| 38 | # things to break eventually as old certificates expire and as new ones |
|---|
| 39 | # are used in the wild that aren't present in whatever version we pin. |
|---|
| 40 | # Hopefully there won't be functionality regressions in new releases of |
|---|
| 41 | # this package that cause us the kind of suffering we're trying to avoid |
|---|
| 42 | # with the above pins. |
|---|
| 43 | certifi |
|---|
| 44 | |
|---|
| 45 | extras = |
|---|
| 46 | # Get general testing environment dependencies so we can run the tests |
|---|
| 47 | # how we like. |
|---|
| 48 | testenv |
|---|
| 49 | |
|---|
| 50 | # And get all of the test suite's actual direct Python dependencies. |
|---|
| 51 | test |
|---|
| 52 | |
|---|
| 53 | setenv = |
|---|
| 54 | # Define TEST_SUITE in the environment as an aid to constructing the |
|---|
| 55 | # correct test command below. |
|---|
| 56 | TEST_SUITE = allmydata |
|---|
| 57 | COLUMNS = 80 |
|---|
| 58 | |
|---|
| 59 | commands = |
|---|
| 60 | # As an aid to debugging, dump all of the Python packages and their |
|---|
| 61 | # versions that are installed in the test environment. This is |
|---|
| 62 | # particularly useful to get from CI runs - though hopefully the |
|---|
| 63 | # version pinning we do limits the variability of this output |
|---|
| 64 | pip freeze |
|---|
| 65 | |
|---|
| 66 | tahoe --version |
|---|
| 67 | |
|---|
| 68 | python -c "import sys; print('sys.stdout.encoding:', sys.stdout.encoding)" |
|---|
| 69 | |
|---|
| 70 | # Run tests with -b to catch bugs like `"%s" % (some_bytes,)`. -b makes |
|---|
| 71 | # Python emit BytesWarnings, and warnings configuration in |
|---|
| 72 | # src/allmydata/tests/__init__.py turns allmydata's BytesWarnings into |
|---|
| 73 | # exceptions. |
|---|
| 74 | !coverage: python -b -m twisted.trial {env:TAHOE_LAFS_TRIAL_ARGS:--rterrors} {posargs:{env:TEST_SUITE}} |
|---|
| 75 | |
|---|
| 76 | # measuring coverage is somewhat slower than not measuring coverage |
|---|
| 77 | # so only do it on request. |
|---|
| 78 | coverage: python -b -m coverage run -m twisted.trial {env:TAHOE_LAFS_TRIAL_ARGS:--rterrors --reporter=timing} {posargs:{env:TEST_SUITE}} |
|---|
| 79 | coverage: coverage combine |
|---|
| 80 | coverage: coverage xml |
|---|
| 81 | |
|---|
| 82 | [testenv:integration] |
|---|
| 83 | usedevelop = False |
|---|
| 84 | basepython = python3 |
|---|
| 85 | platform = mylinux: linux |
|---|
| 86 | mymacos: darwin |
|---|
| 87 | mywindows: win32 |
|---|
| 88 | setenv = |
|---|
| 89 | COVERAGE_PROCESS_START=.coveragerc |
|---|
| 90 | CHUTNEY_ENABLE_CONTROLSOCKET=false |
|---|
| 91 | deps = |
|---|
| 92 | # Get Chutney for Tor integration tests |
|---|
| 93 | git+https://gitlab.torproject.org/tpo/core/chutney@f25094db31fbbec7e88ae5801dd2dcf2d6d9ae5d |
|---|
| 94 | commands = |
|---|
| 95 | # NOTE: 'run with "py.test --keep-tempdir -s -v integration/" to debug failures' |
|---|
| 96 | py.test --timeout=1800 --coverage -s -v {posargs:integration} |
|---|
| 97 | coverage combine |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | [testenv:codechecks] |
|---|
| 101 | basepython = python3 |
|---|
| 102 | skip_install = true |
|---|
| 103 | deps = |
|---|
| 104 | # Pin a specific version so we get consistent outcomes; update this |
|---|
| 105 | # occasionally: |
|---|
| 106 | ruff == 0.1.6 |
|---|
| 107 | towncrier |
|---|
| 108 | # On macOS, git inside of towncrier needs $HOME. |
|---|
| 109 | passenv = HOME |
|---|
| 110 | setenv = |
|---|
| 111 | # If no positional arguments are given, try to run the checks on the |
|---|
| 112 | # entire codebase, including various pieces of supporting code. |
|---|
| 113 | DEFAULT_FILES=src integration benchmarks static misc setup.py |
|---|
| 114 | commands = |
|---|
| 115 | ruff check {posargs:{env:DEFAULT_FILES}} |
|---|
| 116 | python misc/coding_tools/check-umids.py {posargs:{env:DEFAULT_FILES}} |
|---|
| 117 | python misc/coding_tools/check-debugging.py {posargs:{env:DEFAULT_FILES}} |
|---|
| 118 | |
|---|
| 119 | # If towncrier.check fails, you forgot to add a towncrier news |
|---|
| 120 | # fragment explaining the change in this branch. Create one at |
|---|
| 121 | # `newsfragments/<ticket>.<change type>` with some text for the news |
|---|
| 122 | # file. See towncrier.toml for legal <change type> values. |
|---|
| 123 | python -m towncrier.check --config towncrier.toml |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | [testenv:typechecks] |
|---|
| 127 | basepython = python3 |
|---|
| 128 | deps = |
|---|
| 129 | mypy==1.8.0 |
|---|
| 130 | mypy-zope |
|---|
| 131 | types-mock |
|---|
| 132 | types-six |
|---|
| 133 | types-PyYAML |
|---|
| 134 | types-setuptools |
|---|
| 135 | types-pyOpenSSL |
|---|
| 136 | foolscap |
|---|
| 137 | # Upgrade when new releases come out: |
|---|
| 138 | Twisted==23.10.0 |
|---|
| 139 | commands = |
|---|
| 140 | # Different versions of Python have a different standard library, and we |
|---|
| 141 | # want to be compatible with all the variations. For speed's sake we only do |
|---|
| 142 | # the earliest and latest versions. |
|---|
| 143 | mypy --python-version=3.9 src |
|---|
| 144 | mypy --python-version=3.12 src |
|---|
| 145 | |
|---|
| 146 | |
|---|
| 147 | [testenv:draftnews] |
|---|
| 148 | passenv = TAHOE_LAFS_*,PIP_*,SUBUNITREPORTER_*,USERPROFILE,HOMEDRIVE,HOMEPATH,COLUMNS |
|---|
| 149 | deps = |
|---|
| 150 | # see comment in [testenv] about "certifi" |
|---|
| 151 | certifi |
|---|
| 152 | towncrier==23.11.0 |
|---|
| 153 | commands = |
|---|
| 154 | python -m towncrier --draft --config towncrier.toml |
|---|
| 155 | |
|---|
| 156 | [testenv:news] |
|---|
| 157 | # On macOS, git invoked from Tox needs $HOME. |
|---|
| 158 | passenv = TAHOE_LAFS_*,PIP_*,SUBUNITREPORTER_*,USERPROFILE,HOMEDRIVE,HOMEPATH,COLUMNS |
|---|
| 159 | allowlist_externals = |
|---|
| 160 | git |
|---|
| 161 | deps = |
|---|
| 162 | # see comment in [testenv] about "certifi" |
|---|
| 163 | certifi |
|---|
| 164 | towncrier==23.11.0 |
|---|
| 165 | commands = |
|---|
| 166 | python -m towncrier --yes --config towncrier.toml |
|---|
| 167 | # commit the changes |
|---|
| 168 | git commit -m "update NEWS.txt for release" |
|---|
| 169 | |
|---|
| 170 | [testenv:deprecations] |
|---|
| 171 | commands = |
|---|
| 172 | python misc/build_helpers/run-deprecations.py --package allmydata --warnings={env:TAHOE_LAFS_WARNINGS_LOG:_trial_temp/deprecation-warnings.log} trial {env:TAHOE_LAFS_TRIAL_ARGS:--rterrors} {posargs:allmydata} |
|---|
| 173 | |
|---|
| 174 | [testenv:upcoming-deprecations] |
|---|
| 175 | deps = |
|---|
| 176 | # Take the base deps as well! |
|---|
| 177 | {[testenv]deps} |
|---|
| 178 | git+https://github.com/warner/foolscap |
|---|
| 179 | commands = |
|---|
| 180 | flogtool --version |
|---|
| 181 | python misc/build_helpers/run-deprecations.py --package allmydata --warnings={env:TAHOE_LAFS_WARNINGS_LOG:_trial_temp/deprecation-warnings.log} trial {env:TAHOE_LAFS_TRIAL_ARGS:--rterrors} {posargs:allmydata} |
|---|
| 182 | |
|---|
| 183 | # Use 'tox -e docs' to check formatting and cross-references in docs .rst |
|---|
| 184 | # files. The published docs are built by code run over at readthedocs.org, |
|---|
| 185 | # which does not use this target (but does something similar). |
|---|
| 186 | # |
|---|
| 187 | # If you have "sphinx" installed in your virtualenv, you can just do "make -C |
|---|
| 188 | # docs html", or "cd docs; make html". |
|---|
| 189 | # |
|---|
| 190 | # You can also open docs/_build/html/index.html to see the rendered docs in |
|---|
| 191 | # your web browser. |
|---|
| 192 | |
|---|
| 193 | [testenv:docs] |
|---|
| 194 | deps = |
|---|
| 195 | -r docs/requirements.txt |
|---|
| 196 | # normal install is not needed for docs, and slows things down |
|---|
| 197 | skip_install = True |
|---|
| 198 | commands = |
|---|
| 199 | sphinx-build -W -b html -d {toxinidir}/docs/_build/doctrees {toxinidir}/docs {toxinidir}/docs/_build/html |
|---|
| 200 | |
|---|
| 201 | [testenv:pyinstaller] |
|---|
| 202 | extras = |
|---|
| 203 | deps = |
|---|
| 204 | {[testenv]deps} |
|---|
| 205 | packaging |
|---|
| 206 | pyinstaller |
|---|
| 207 | pefile ; platform_system == "Windows" |
|---|
| 208 | # Setting PYTHONHASHSEED to a known value assists with reproducible builds. |
|---|
| 209 | # See https://pyinstaller.readthedocs.io/en/stable/advanced-topics.html#creating-a-reproducible-build |
|---|
| 210 | setenv=PYTHONHASHSEED=1 |
|---|
| 211 | commands= |
|---|
| 212 | pip freeze |
|---|
| 213 | pyinstaller -y --clean pyinstaller.spec |
|---|
| 214 | |
|---|
| 215 | [testenv:tarballs] |
|---|
| 216 | basepython = python3 |
|---|
| 217 | deps = |
|---|
| 218 | commands = |
|---|
| 219 | python setup.py update_version |
|---|
| 220 | python setup.py sdist --formats=gztar bdist_wheel --universal |
|---|