[tox]
envlist = linters,flake8,pylint,unittests
minversion = 2.3
skipsdist = True

[testenv]
deps = -r{toxinidir}/requirements/test-requirements.txt
allowlist_externals = reno

[testenv:linters]
basepython = python3
# bashate ignore:
#  E006 - accept long lines
#  E040 - false positive on |& syntax (new in bash 4)
allowlist_externals = bash
commands =
  bash -c "find {toxinidir}                              \
            \( -name .tox -prune \)                      \
            -o -type f -name '*.yaml'                    \
            -not \( -type f -path *template* -prune \)   \
            -print0 | xargs -0 yamllint"
  bash -c "find {toxinidir}          \
         -not \( -type d -name .?\* -prune \) \
         -type f                              \
         -not -name \*~                       \
         -not -name \*.md                     \
         -name \*.sh                          \
         -print0 | xargs -0 bashate -v -iE006,E040,E042"

[flake8]
ignore =
exclude = regression
max-line-length=80

[testenv:flake8]
commands =
  flake8 {posargs} libvirt/

[testenv:pylint]
basepython = python3
sitepackages = False
setenv =
    BASEPATH = {toxinidir}/virtualbox/pybox
    PYTHONPATH= {env:BASEPATH}:{env:BASEPATH}/helper:{env:BASEPATH}/consts:{env:BASEPATH}/utils
deps =
    -r{env:BASEPATH}/requirements.txt
    {[testenv]deps}
allowlist_externals = pylint
commands = pylint {posargs} --rcfile=./pylint.rc virtualbox/pybox libvirt

[testenv:unittests]
basepython = python3
setenv =
    BASEPATH = {toxinidir}/virtualbox/pybox
    PYTHONPATH= {env:BASEPATH}:{env:BASEPATH}/helper:{env:BASEPATH}/consts:{env:BASEPATH}/utils
deps =
    -r{toxinidir}/virtualbox/pybox/requirements.txt
    coverage
change_dir = {env:BASEPATH}
commands =
    coverage run -m unittest discover
    coverage report -m