1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

More code-smell sanity test updates. (#36830)

* Add test for missing Azure requirements.
* Improve readability.
* Enhance no-unicode-literals code-smell test.
This commit is contained in:
Matt Clay 2018-02-28 00:50:00 -08:00 committed by GitHub
parent a031e02ab0
commit dc71c2197f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 42 additions and 17 deletions

View file

@ -269,6 +269,7 @@ class SanityCodeSmellTest(SanityTest):
if data:
display.info(data, verbosity=4)
try:
stdout, stderr = run_command(args, cmd, data=data, env=env, capture=True)
status = 0

View file

@ -9,6 +9,14 @@ def main():
src = 'packaging/requirements/requirements-azure.txt'
dst = 'test/runner/requirements/integration.cloud.azure.txt'
missing = [p for p in [src, dst] if not os.path.isfile(p)]
if missing:
for path in missing:
print('%s: missing required file' % path)
return
if not filecmp.cmp(src, dst):
print('%s: must be identical to `%s`' % (dst, src))

View file

@ -0,0 +1,6 @@
{
"extensions": [
".py"
],
"output": "path-line-column-message"
}

View file

@ -0,0 +1,27 @@
#!/usr/bin/env python
import os
import re
import sys
def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
])
for path in sys.argv[1:] or sys.stdin.read().splitlines():
if path in skip:
continue
with open(path, 'r') as path_fd:
for line, text in enumerate(path_fd.readlines()):
match = re.search(r'(unicode_literals)', text)
if match:
print('%s:%d:%d: do not use `unicode_literals`' % (
path, line + 1, match.start(1) + 1))
if __name__ == '__main__':
main()

View file

@ -1,17 +0,0 @@
#!/bin/sh
UNICODE_LITERALS_USERS=$(grep -r unicode_literals . \
--exclude-dir .git \
--exclude-dir .tox \
--exclude no-unicode-literals.sh \
--exclude no-unicode-literals.rst |
grep -v ./test/results | \
grep -v ansible.egg-info/SOURCES.txt \
)
if [ "${UNICODE_LITERALS_USERS}" ]; then
echo "${UNICODE_LITERALS_USERS}"
exit 1
fi
exit 0