зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1604079 - Add a unit test for mozlint yamllint r=ahal
+ some python 3 changes Differential Revision: https://phabricator.services.mozilla.com/D57263 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
3d352aa73a
Коммит
08e2e04f2a
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
yamllint:
|
||||
description: YAML linteraaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaax
|
||||
include:
|
||||
- .cron.yml
|
||||
- browser/config/
|
||||
- wrong
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
yamllint:
|
||||
description: YAML linter
|
||||
include:
|
||||
- .cron.yml
|
||||
- browser/config/
|
|
@ -16,3 +16,4 @@ skip-if = os == "win"
|
|||
[test_rst.py]
|
||||
[test_codespell.py]
|
||||
skip-if = os == "win" || os == "mac" # codespell installed on Linux
|
||||
[test_yaml.py]
|
|
@ -0,0 +1,26 @@
|
|||
import pytest
|
||||
import mozunit
|
||||
from mozfile import which
|
||||
|
||||
LINTER = 'yaml'
|
||||
pytestmark = pytest.mark.skipif(not which('yamllint'), reason="yamllint is not installed")
|
||||
|
||||
|
||||
def test_basic(lint, paths):
|
||||
results = lint(paths())
|
||||
|
||||
assert len(results) == 2
|
||||
|
||||
assert "line too long (122 > 80 characters)'" in results[0].message
|
||||
assert results[0].level == "error"
|
||||
assert "bad.yml" in results[0].relpath
|
||||
assert results[0].lineno == 3
|
||||
|
||||
assert "wrong indentation: expected 4 but found 8" in results[1].message
|
||||
assert results[1].level == "error"
|
||||
assert "bad.yml" in results[1].relpath
|
||||
assert results[0].lineno == 3
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
mozunit.main()
|
|
@ -23,7 +23,7 @@ Try to install it manually with:
|
|||
$ pip install -U --require-hashes -r {}
|
||||
""".strip().format(YAMLLINT_REQUIREMENTS_PATH)
|
||||
|
||||
YAMLLINT_FORMAT_REGEX = re.compile(r'(.*):(.*):(.*): \[(error|warning)\] (.*) \((.*)\)$')
|
||||
YAMLLINT_FORMAT_REGEX = re.compile(b'(.*):(.*):(.*): \[(error|warning)\] (.*) \((.*)\)$')
|
||||
|
||||
results = []
|
||||
|
||||
|
@ -43,8 +43,8 @@ class YAMLLintProcess(ProcessHandlerMixin):
|
|||
print('Unable to match yaml regex against output: {}'.format(line))
|
||||
return
|
||||
|
||||
res = {'path': os.path.relpath(abspath, self.config['root']),
|
||||
'message': message,
|
||||
res = {'path': os.path.relpath(str(abspath), self.config['root']),
|
||||
'message': str(message),
|
||||
'level': 'error',
|
||||
'lineno': line,
|
||||
'column': col,
|
||||
|
|
Загрузка…
Ссылка в новой задаче