[tox]
minversion=2.0
isolated_build = true
skip_missing_interpreters = True
envlist = py{39,310,311,312,313}-{Linux,Windows,macOS}, docs, lint

[testenv]
platform =
    Windows: win32
    Linux: linux
    macOS: darwin
allowlist_externals = sh
extras = dev
commands =
    pip check
    Linux: sh -ec "if ! getcap $(realpath {envpython}) | grep -q cap_net_admin,cap_net_raw+eip; then sudo setcap cap_net_admin,cap_net_raw+eip $(realpath {envpython}); fi"
    pytest --cov --cov-report=xml
commands_post =
    - python -c "import shutil; shutil.rmtree('./boofuzz-results/')"

[testenv:docs]
basepython = python3
extras = docs
commands =
    sphinx-build -TW -b dummy ./docs ./docs/_build
    sphinx-build -TW -b linkcheck ./docs ./docs/_build
commands_post =
    - python -c "import shutil; shutil.rmtree('./docs/_build')"

[testenv:lint]
basepython = python3
skip_install = true
deps =
    black
    flake8
commands =
    # Fail if there are Python syntax errors or undefined names.
    flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
    black --check .
    # Code-Style check. exit-zero treats all errors as warnings.
    flake8 . --count --exit-zero --statistics
commands_post =
