# ============================================================================
# TOX CONFIGURATION: behave
# ============================================================================
# DESCRIPTION:
#
#   Use tox to run tasks (tests, ...) in a clean virtual environment.
#   Afterwards you can run tox in offline mode, like:
#
#       tox -e py27
#
#   Tox can be configured for offline usage.
#   Initialize local workspace once (download packages, create PyPI index):
#
#       tox -e init1
#       tox -e init2    (alternative)
#
#   NOTE:
#   You can either use "local1" or "local2" as local "tox.indexserver.default":
#
#     * $HOME/.pip/downloads/       (local1, default)
#     * downloads/                  (local2, alternative)
#
# SEE ALSO:
#   * http://tox.testrun.org/latest/config.html
# ============================================================================
# -- ONLINE USAGE:
# PIP_INDEX_URL = http://pypi.python.org/simple

[tox]
minversion   = 2.3
envlist      = py26, py27, py33, py34, py35, py36, pypy, docs
skip_missing_interpreters = True
sitepackages = False
indexserver =
    default  = https://pypi.python.org/simple
    default2 = file://{homedir}/.pip/downloads/simple
    local1   = file://{toxinidir}/downloads/simple
    local2   = file://{homedir}/.pip/downloads/simple
    pypi     = https://pypi.python.org/simple

# -----------------------------------------------------------------------------
# TOX PREPARE/BOOTSTRAP: Initialize local workspace for tox off-line usage
# -----------------------------------------------------------------------------
[testenv:init1]
install_command = pip install -i https://pypi.python.org/simple --find-links downloads --no-index {packages}
changedir = {toxinidir}
skipsdist = True
commands=
    {toxinidir}/bin/toxcmd.py mkdir {toxinidir}/downloads
    pip install --download={toxinidir}/downloads -r py.requirements/all.txt
    {toxinidir}/bin/make_localpi.py {toxinidir}/downloads
deps=


[testenv:init2]
install_command = pip install -i https://pypi.python.org/simple --find-links {homedir}/.pip/downloads --no-index {packages}
changedir = {toxinidir}
skipsdist = True
commands=
    {toxinidir}/bin/toxcmd.py mkdir {homedir}/.pip/downloads
    pip install --download={homedir}/.pip/downloads -r py.requirements/all.txt
    {toxinidir}/bin/make_localpi.py {homedir}/.pip/downloads
deps=

# setenv =
#     PIP_INDEX_URL = https://pypi.python.org/simple
# -----------------------------------------------------------------------------
# TEST ENVIRONMENTS:
# -----------------------------------------------------------------------------
[testenv]
install_command = pip install -U {opts} {packages}
changedir = {toxinidir}
commands=
    py.test {posargs:test tests}
    behave --format=progress {posargs:features}
    behave --format=progress {posargs:tools/test-features}
    behave --format=progress {posargs:issue.features}
deps=
    pytest>=2.8
    nose>=1.1
    mock>=1.0
    PyHamcrest>=1.8
setenv =
     PYTHONPATH = {toxinidir}


[testenv:docs]
basepython= python2
changedir = docs
commands=
    sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
deps=
    -r{toxinidir}/py.requirements/docs.txt


[testenv:cleanroom]
changedir = {envdir}
commands=
    behave --version
    {toxinidir}/bin/toxcmd.py copytree ../../behave4cmd0 .
    {toxinidir}/bin/toxcmd.py copytree ../../test .
    {toxinidir}/bin/toxcmd.py copytree ../../tests .
    {toxinidir}/bin/toxcmd.py copytree ../../features .
    {toxinidir}/bin/toxcmd.py copytree ../../tools  .
    {toxinidir}/bin/toxcmd.py copytree ../../issue.features .
    {toxinidir}/bin/toxcmd.py copy ../../behave.ini .
    py.test {posargs:test tests}
    behave --format=progress {posargs:features}
    behave --format=progress {posargs:tools/test-features}
    behave --format=progress {posargs:issue.features}
deps=
    {[testenv]deps}
setenv =
     PYTHONPATH = .:{envdir}


[testenv:cleanroom3]
basepython = python3
changedir = {envdir}
commands=
    behave --version
    {toxinidir}/bin/toxcmd.py copytree ../../behave4cmd0 .
    {toxinidir}/bin/toxcmd.py copytree ../../test .
    {toxinidir}/bin/toxcmd.py copytree ../../tests .
    {toxinidir}/bin/toxcmd.py copytree ../../features .
    {toxinidir}/bin/toxcmd.py copytree ../../tools  .
    {toxinidir}/bin/toxcmd.py copytree ../../issue.features .
    {toxinidir}/bin/toxcmd.py copy ../../behave.ini .
    {toxinidir}/bin/toxcmd.py 2to3 -w -n --no-diffs behave4cmd0
    {toxinidir}/bin/toxcmd.py 2to3 -w -n --no-diffs test
    {toxinidir}/bin/toxcmd.py 2to3 -w -n --no-diffs tools
    {toxinidir}/bin/toxcmd.py 2to3 -w -n --no-diffs features
    {toxinidir}/bin/toxcmd.py 2to3 -w -n --no-diffs issue.features
    py.test {posargs:test tests}
    behave --format=progress {posargs:features}
    behave --format=progress {posargs:tools/test-features}
    behave --format=progress {posargs:issue.features}
deps=
    {[testenv]deps}
setenv =
     PYTHONPATH = .:{envdir}

# ---------------------------------------------------------------------------
# SELDOM-USED: OPTIONAL TEST ENVIRONMENTS:
# ---------------------------------------------------------------------------
# -- SELDOM-USED, TESTED-WITH: jython2.7
# JYTHON INSTALL RELATED (jit):
#   http://sikulix-2014.readthedocs.org/en/latest/scenarios.html
[testenv:jy27]
basepython= jython
commands=
    py.test {posargs:test tests}
    behave --format=progress {posargs:features}
    behave --format=progress {posargs:tools/test-features}
    behave --format=progress {posargs:issue.features}
deps=
    jit
    {[testenv]deps}