[tox]
envlist = mypy,pycodestyle,ruff,pytest
isolated_build = True
labels =
  venv = py312-{mypy,pycodestyle,ruff,pytest}, py3{6,7,8,9,10,11,12}-pytest
  toxbox = py312-{mypy,pycodestyle,ruff,pytest}, py3{7,8,9,10,11,12}-pytest

# The default test environments use system packages and never PyPI.
[testenv:{mypy,pycodestyle,ruff,pytest,pkg}]
sitepackages = True
install_command = python3 -m pip install --no-index --no-build-isolation {opts} {packages}
wheel_build_env = pkg

# All other environments (names like py312-mypy, py36-pytest, etc) are isolated
# from the system and get their packages from PyPI, according to the specific
# test environment being requested.  We build the wheel in a common environment.
[testenv]
package = wheel
wheel_build_env = venv-pkg
skip_install = mypy,pycodestyle,ruff: True
install_command = python3 -m pip install {opts} {packages}
deps =
  pytest,mypy: asyncssh
  pytest,mypy: pytest-timeout
  pytest,mypy: pytest-asyncio
  pytest,mypy: pytest-cov
  mypy: mypy
  pycodestyle: pycodestyle
  ruff: ruff
commands =
  pytest: python3 -m pytest -opythonpath= {posargs:--cov}
  ruff: ruff {posargs:src test}
  mypy: python3 -m mypy {posargs:src test}
  pycodestyle: python3 -m pycodestyle --max-line-length=118 {posargs:src test}
allowlist_externals = ruff,bash
passenv = FORCE_COLOR,COVERAGE_FILE,RUFF_CACHE_DIR,MYPY_CACHE_DIR
