Merge "Run inventory test during Jenkins lint check"

This commit is contained in:
Jenkins 2016-03-08 23:48:30 +00:00 committed by Gerrit Code Review
commit 11495d2ae7
2 changed files with 10 additions and 11 deletions

View File

@ -8,12 +8,11 @@ import subprocess
import unittest
INV_DIR = '../playbooks/inventory'
INV_DIR = 'playbooks/inventory'
SCRIPT_FILENAME = 'dynamic_inventory.py'
INV_SCRIPT = path.join(INV_DIR, SCRIPT_FILENAME)
INV_SCRIPT = path.join(os.getcwd(), INV_DIR, SCRIPT_FILENAME)
# We'll use the test directory, and have tox do the cd command for us.
TARGET_DIR = path.join(os.getcwd(), 'inventory')
TARGET_DIR = path.join(os.getcwd(), 'tests', 'inventory')
# These files will be placed in TARGET_DIR by INV_SCRIPT.
# They should be cleaned up between each test.
@ -34,7 +33,7 @@ def cleanup():
def get_inventory():
"Return the inventory mapping in a dict."
try:
cmd = [INV_SCRIPT, '--file', TARGET_DIR]
cmd = [INV_SCRIPT, '--config', TARGET_DIR]
inventory_string = subprocess.check_output(cmd)
inventory = json.loads(inventory_string)
return inventory

12
tox.ini
View File

@ -1,7 +1,7 @@
[tox]
minversion = 1.6
skipsdist = True
envlist = docs,linters,releasenotes,inventory
envlist = docs,linters,releasenotes
[testenv]
usedevelop = True
@ -89,14 +89,14 @@ commands =
--list-tasks \
{toxinidir}/playbooks/*.yml"
[testenv:inventory]
commands =
python {toxinidir}/tests/test_inventory.py
[testenv:linters]
commands =
{[testenv:pep8]commands}
{[testenv:bashate]commands}
{[testenv:ansible-lint]commands}
{[testenv:ansible-syntax]commands}
[testenv:inventory]
changedir = {toxinidir}/tests
commands =
python test_inventory.py
{[testenv:inventory]commands}