mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Run tests from tox, wether runtests or pytest
This commit is contained in:
parent
f62cc11d78
commit
78c6d68008
4 changed files with 233 additions and 7 deletions
7
Gemfile
7
Gemfile
|
@ -2,9 +2,8 @@
|
|||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
# Point this back at the test-kitchen package after 1.23.3 is relased
|
||||
gem 'test-kitchen', :git => 'https://github.com/dwoz/test-kitchen.git', :branch => 'winrm_opts'
|
||||
gem 'kitchen-salt', '~>0.2'
|
||||
gem 'test-kitchen', '~>1.23.3'
|
||||
gem 'kitchen-salt', '~>0.4.1'
|
||||
gem 'kitchen-sync'
|
||||
gem 'git'
|
||||
|
||||
|
@ -14,7 +13,7 @@ end
|
|||
|
||||
group :windows do
|
||||
gem 'winrm', '~>2.0'
|
||||
gem 'winrm-fs', '~>1.3.1'
|
||||
gem 'winrm-fs', '~>1.3.1'
|
||||
end
|
||||
|
||||
group :ec2 do
|
||||
|
|
44
tests/tox-helper.py
Normal file
44
tests/tox-helper.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# This script exists so that path handling when running tox works for both Linux and Windows
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
import argparse
|
||||
import tempfile
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
'--rootdir',
|
||||
default=os.path.abspath(os.path.dirname(os.path.dirname(__file__)))
|
||||
)
|
||||
subparsers = parser.add_subparsers(help='sub-command help', dest='subparser')
|
||||
|
||||
subparsers.add_parser('create-dirs')
|
||||
subparsers.add_parser('move-artifacts')
|
||||
|
||||
options = parser.parse_args()
|
||||
if options.subparser == 'create-dirs':
|
||||
for dirname in ('logs', 'coverage', 'xml-unittests-output'):
|
||||
path = os.path.join(options.rootdir, 'artifacts', dirname)
|
||||
if not os.path.exists(path):
|
||||
os.makedirs(path)
|
||||
|
||||
if options.subparser == 'move-artifacts':
|
||||
tmp_artifacts_dir = os.path.join(tempfile.gettempdir(), 'artifacts')
|
||||
if not os.path.exists(tmp_artifacts_dir):
|
||||
os.makedirs(tmp_artifacts_dir)
|
||||
|
||||
for dirname in ('logs', 'coverage', 'xml-unittests-output'):
|
||||
src = os.path.join(options.rootdir, 'artifacts', dirname)
|
||||
dst = os.path.join(tmp_artifacts_dir, dirname)
|
||||
shutil.copytree(src, dst)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
|
@ -47,6 +47,7 @@ EXCLUDED_FILES = [
|
|||
os.path.join('tests', 'modparser.py'),
|
||||
os.path.join('tests', 'committer_parser.py'),
|
||||
os.path.join('tests', 'zypp_plugin.py'),
|
||||
os.path.join('tests', 'tox-helper.py'),
|
||||
os.path.join('tests', 'unit', 'transport', 'mixins.py'),
|
||||
os.path.join('tests', 'integration', 'utils', 'testprogram.py'),
|
||||
]
|
||||
|
|
188
tox.ini
188
tox.ini
|
@ -1,13 +1,194 @@
|
|||
[tox]
|
||||
envlist = py27,py34,py35,py36,pylint-salt,pylint-tests
|
||||
envlist =
|
||||
py{27,34,35,36},
|
||||
py{27,34,35,36}-coverage,
|
||||
py{27,34,35,36}-pytest,
|
||||
py{27,34,35,36}-runtests,
|
||||
py{27,34,35,36}-pytest-coverage,
|
||||
py{27,34,35,36}-runtests-coverage,
|
||||
pylint-salt,
|
||||
pylint-tests
|
||||
skip_missing_interpreters = True
|
||||
skipsdist = True
|
||||
|
||||
[testenv]
|
||||
deps = -Ur{toxinidir}/requirements/tests.txt
|
||||
commands = pytest --rootdir {toxinidir} {posargs}
|
||||
changedir = {toxinidir}
|
||||
commands_pre = {envpython} tests/tox-helper.py create-dirs
|
||||
passenv = LANG HOME
|
||||
sitepackages = True
|
||||
commands = {[testenv:runtests]commands}
|
||||
|
||||
[testenv:runtests]
|
||||
deps =
|
||||
{[testenv]deps}
|
||||
unittest-xml-reporting
|
||||
commands = {envpython} {toxinidir}/tests/runtests.py --tests-logfile={toxinidir}/artifacts/logs/runtests.log {posargs}
|
||||
|
||||
[testenv:pytest]
|
||||
commands = pytest --rootdir {toxinidir} --log-file={toxinidir}/artifacts/logs/runtests.log {posargs}
|
||||
|
||||
[testenv:runtests-coverage]
|
||||
commands_pre =
|
||||
- coverage erase
|
||||
commands =
|
||||
coverage run -m tests.runtests {posargs}
|
||||
commands_post =
|
||||
- coverage combine
|
||||
- coverage xml -o {toxinidir}/artifacts/coverage/coverage.xml
|
||||
|
||||
[testenv:pytest-coverage]
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands = coverage run -m py.test --rootdir {toxinidir} {posargs}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py2-pytest]
|
||||
commands = {[testenv:pytest]commands}
|
||||
|
||||
[testenv:py2-runtests]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests]commands}
|
||||
|
||||
[testenv:py2-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py2-runtests-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py2-pytest-coverage]
|
||||
commands = {[testenv:pytest-coverage]commands}
|
||||
commands_pre = {[testenv:pytest-coverage]commands_pre}
|
||||
commands_post = {[testenv:pytest-coverage]commands_post}
|
||||
|
||||
[testenv:py27-pytest]
|
||||
commands = {[testenv:pytest]commands}
|
||||
|
||||
[testenv:py27-runtests]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests]commands}
|
||||
|
||||
[testenv:py27-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py27-runtests-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py27-pytest-coverage]
|
||||
commands = {[testenv:pytest-coverage]commands}
|
||||
commands_pre = {[testenv:pytest-coverage]commands_pre}
|
||||
commands_post = {[testenv:pytest-coverage]commands_post}
|
||||
|
||||
[testenv:py3-pytest]
|
||||
commands = {[testenv:pytest]commands}
|
||||
|
||||
[testenv:py3-runtests]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests]commands}
|
||||
|
||||
[testenv:py3-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py3-runtests-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py3-pytest-coverage]
|
||||
commands = {[testenv:pytest-coverage]commands}
|
||||
commands_pre = {[testenv:pytest-coverage]commands_pre}
|
||||
commands_post = {[testenv:pytest-coverage]commands_post}
|
||||
|
||||
|
||||
[testenv:py34-pytest]
|
||||
commands = {[testenv:pytest]commands}
|
||||
|
||||
[testenv:py34-runtests]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests]commands}
|
||||
|
||||
[testenv:py34-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py34-runtests-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py34-pytest-coverage]
|
||||
commands = {[testenv:pytest-coverage]commands}
|
||||
commands_pre = {[testenv:pytest-coverage]commands_pre}
|
||||
commands_post = {[testenv:pytest-coverage]commands_post}
|
||||
|
||||
|
||||
[testenv:py35-pytest]
|
||||
commands = {[testenv:pytest]commands}
|
||||
|
||||
[testenv:py35-runtests]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests]commands}
|
||||
|
||||
[testenv:py35-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py35-runtests-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py35-pytest-coverage]
|
||||
commands = {[testenv:pytest-coverage]commands}
|
||||
commands_pre = {[testenv:pytest-coverage]commands_pre}
|
||||
commands_post = {[testenv:pytest-coverage]commands_post}
|
||||
|
||||
|
||||
[testenv:py36-pytest]
|
||||
commands = {[testenv:pytest]commands}
|
||||
|
||||
[testenv:py36-runtests]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests]commands}
|
||||
|
||||
[testenv:py36-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py36-runtests-coverage]
|
||||
deps = {[testenv:runtests]deps}
|
||||
commands = {[testenv:runtests-coverage]commands}
|
||||
commands_pre = {[testenv:runtests-coverage]commands_pre}
|
||||
commands_post = {[testenv:runtests-coverage]commands_post}
|
||||
|
||||
[testenv:py36-pytest-coverage]
|
||||
commands = {[testenv:pytest-coverage]commands}
|
||||
commands_pre = {[testenv:pytest-coverage]commands_pre}
|
||||
commands_post = {[testenv:pytest-coverage]commands_post}
|
||||
|
||||
|
||||
[testenv:pylint-salt]
|
||||
basepython = python2.7
|
||||
|
@ -17,6 +198,7 @@ commands =
|
|||
pylint --rcfile=.testing.pylintrc --disable=I,W1307,C0411,C0413,W8410,str-format-in-logging {posargs:setup.py salt/}
|
||||
sitepackages = False
|
||||
|
||||
|
||||
[testenv:pylint-tests]
|
||||
basepython = python2.7
|
||||
deps = -r{toxinidir}/requirements/dev.txt
|
||||
|
@ -26,6 +208,6 @@ commands =
|
|||
sitepackages = False
|
||||
|
||||
[pytest]
|
||||
addopts = --log-file /tmp/salt-runtests.log --no-print-logs --ssh-tests -ra -sv
|
||||
addopts = --no-print-logs --ssh-tests -ra -sv
|
||||
testpaths = tests
|
||||
norecursedirs = tests/kitchen
|
||||
|
|
Loading…
Add table
Reference in a new issue