2018-07-11 12:50:42 +00:00
|
|
|
"""Syntax checks"""
|
|
|
|
|
|
|
|
import os
|
|
|
|
import pytest
|
|
|
|
|
|
|
|
|
|
|
|
def test_yadm_syntax(runner, yadm):
|
|
|
|
"""Is syntactically valid"""
|
|
|
|
run = runner(command=['bash', '-n', yadm])
|
|
|
|
assert run.success
|
|
|
|
|
|
|
|
|
2019-12-03 13:54:59 +00:00
|
|
|
def test_shellcheck(pytestconfig, runner, yadm, shellcheck_version):
|
2018-07-11 12:50:42 +00:00
|
|
|
"""Passes shellcheck"""
|
2019-12-03 13:54:59 +00:00
|
|
|
if not pytestconfig.getoption("--force-linters"):
|
|
|
|
run = runner(command=['shellcheck', '-V'], report=False)
|
|
|
|
if f'version: {shellcheck_version}' not in run.out:
|
|
|
|
pytest.skip('Unsupported shellcheck version')
|
2018-07-11 12:50:42 +00:00
|
|
|
run = runner(command=['shellcheck', '-s', 'bash', yadm])
|
|
|
|
assert run.success
|
|
|
|
|
|
|
|
|
2019-12-03 13:54:59 +00:00
|
|
|
def test_pylint(pytestconfig, runner, pylint_version):
|
2018-07-11 12:50:42 +00:00
|
|
|
"""Passes pylint"""
|
2019-12-03 13:54:59 +00:00
|
|
|
if not pytestconfig.getoption("--force-linters"):
|
|
|
|
run = runner(command=['pylint', '--version'], report=False)
|
|
|
|
if f'pylint {pylint_version}' not in run.out:
|
|
|
|
pytest.skip('Unsupported pylint version')
|
2018-07-11 12:50:42 +00:00
|
|
|
pyfiles = list()
|
|
|
|
for tfile in os.listdir('test'):
|
|
|
|
if tfile.endswith('.py'):
|
|
|
|
pyfiles.append(f'test/{tfile}')
|
|
|
|
run = runner(command=['pylint'] + pyfiles)
|
|
|
|
assert run.success
|
|
|
|
|
|
|
|
|
2019-12-03 13:54:59 +00:00
|
|
|
def test_flake8(pytestconfig, runner, flake8_version):
|
2018-07-11 12:50:42 +00:00
|
|
|
"""Passes flake8"""
|
2019-12-03 13:54:59 +00:00
|
|
|
if not pytestconfig.getoption("--force-linters"):
|
|
|
|
run = runner(command=['flake8', '--version'], report=False)
|
|
|
|
if not run.out.startswith(flake8_version):
|
|
|
|
pytest.skip('Unsupported flake8 version')
|
2018-07-11 12:50:42 +00:00
|
|
|
run = runner(command=['flake8', 'test'])
|
|
|
|
assert run.success
|
2019-03-21 12:38:38 +00:00
|
|
|
|
|
|
|
|
2019-12-03 13:54:59 +00:00
|
|
|
def test_yamllint(pytestconfig, runner, yamllint_version):
|
2019-03-21 12:38:38 +00:00
|
|
|
"""Passes yamllint"""
|
2019-12-03 13:54:59 +00:00
|
|
|
if not pytestconfig.getoption("--force-linters"):
|
|
|
|
run = runner(command=['yamllint', '--version'], report=False)
|
|
|
|
if not run.out.strip().endswith(yamllint_version):
|
|
|
|
pytest.skip('Unsupported yamllint version')
|
2019-03-21 12:38:38 +00:00
|
|
|
run = runner(
|
|
|
|
command=['yamllint', '-s', '$(find . -name \\*.yml)'],
|
|
|
|
shell=True)
|
|
|
|
assert run.success
|