From e51532937aaf85664a4e6c7ea5d1dc0276c149c7 Mon Sep 17 00:00:00 2001
From: Adar Nimrod <nimrod@shore.co.il>
Date: Fri, 14 Apr 2017 21:37:58 +0300
Subject: [PATCH] - Cleaner Tox usage.

---
 .travis.yml | 19 ++++++++++---------
 README.rst  | 18 +++---------------
 tox.ini     | 11 +++++++----
 3 files changed, 20 insertions(+), 28 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 211dd1b..d3f3c0d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -9,14 +9,14 @@ env:
         - VBOX_MEMORY=2048
     matrix:
         - TOXENV=pre-commit
-        - TOXENV=openbsd60
-        - &openbsd59 TOXENV=openbsd59
-        - TOXENV=xenial
-        - TOXENV=trusty
-        - TOXENV=precise
-        - &stretch TOXENV=stretch
-        - TOXENV=jessie
-        - TOXENV=wheezy
+        - tox_switches="--platform openbsd60"
+        - &openbsd59 tox_switches="--platform openbsd59"
+        - tox_switches="--platform xenial"
+        - tox_switches="--platform trusty"
+        - tox_switches="--platform precise"
+        - &stretch tox_switches="--platform stretch"
+        - tox_switches="--platform jessie"
+        - tox_switches="--platform wheezy"
 matrix:
     fast_finish: True
     allow_failures:
@@ -27,6 +27,7 @@ cache:
   - pip
   - directories:
       - $HOME/.pre-commit
+      - .tox
 
 install:
   - sudo apt-get update
@@ -36,7 +37,7 @@ install:
   - pip install tox | cat
 
 script:
-  - travis_wait 45 tox
+  - travis_wait 45 tox -- $tox_switches
 
 notifications:
   webhooks: https://galaxy.ansible.com/api/v1/notifications/
diff --git a/README.rst b/README.rst
index 9336623..d50fb09 100644
--- a/README.rst
+++ b/README.rst
@@ -31,21 +31,9 @@ See :code:`tests/playbook.yml`.
 Testing
 -------
 
-Testing requires Python 2.7, Vagrant and Virtualbox. Install the Python
-dependencies, dependent roles and roles required for testing:
-
-.. code:: shell
-
-    pip install -r tests/requirements.txt
-    ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles
-    molecule dependency
-
-To run the full test suite:
-
-.. code:: shell
-
-    pre-commit run --all-files
-    molecule test --platform all
+Testing requires Python 2.7, Tox, Vagrant and Virtualbox. To test simply run
+:code:`tox`. `Pre-commit <http://pre-commit.com/>`_ is also setup for this
+project.
 
 License
 -------
diff --git a/tox.ini b/tox.ini
index 9f02b87..9c3bf74 100644
--- a/tox.ini
+++ b/tox.ini
@@ -1,10 +1,12 @@
 [tox]
 skip_install = True
 skipsdist = True
-envlist = openbsd60,openbsd59,xenial,trusty,precise,stretch,jessie,wheezy
+envlist = molecule
 
 [testenv:pre-commit]
+envdir = {toxinidir}/.tox
 deps = -rtests/requirements.txt
+passenv = HOME VBOX* ANSIBLE_*
 whitelist_externals =
     sh
 commands =
@@ -12,11 +14,12 @@ commands =
     molecule dependency
     pre-commit run --all-files
 
-[testenv]
+[testenv:molecule]
+envdir = {toxinidir}/.tox
 deps = -rtests/requirements.txt
-passenv = HOME
+passenv = HOME VBOX* ANSIBLE_*
 whitelist_externals =
     sh
 commands =
     sh -c "ansible-galaxy install git+file://$(pwd),$(git rev-parse --abbrev-ref HEAD) -p .molecule/roles"
-    molecule test --platform {envname}
+    molecule test {posargs}
-- 
GitLab