diff --git a/test/runner/lib/sanity/__init__.py b/test/runner/lib/sanity/__init__.py index e9fe96d536c..a773e917fb9 100644 --- a/test/runner/lib/sanity/__init__.py +++ b/test/runner/lib/sanity/__init__.py @@ -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 diff --git a/test/sanity/code-smell/azure-requirements.py b/test/sanity/code-smell/azure-requirements.py index 95ab47d0f48..dc3554c698d 100755 --- a/test/sanity/code-smell/azure-requirements.py +++ b/test/sanity/code-smell/azure-requirements.py @@ -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)) diff --git a/test/sanity/code-smell/no-unicode-literals.json b/test/sanity/code-smell/no-unicode-literals.json new file mode 100644 index 00000000000..776590b74d2 --- /dev/null +++ b/test/sanity/code-smell/no-unicode-literals.json @@ -0,0 +1,6 @@ +{ + "extensions": [ + ".py" + ], + "output": "path-line-column-message" +} diff --git a/test/sanity/code-smell/no-unicode-literals.py b/test/sanity/code-smell/no-unicode-literals.py new file mode 100755 index 00000000000..f12b18efbf8 --- /dev/null +++ b/test/sanity/code-smell/no-unicode-literals.py @@ -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() diff --git a/test/sanity/code-smell/no-unicode-literals.sh b/test/sanity/code-smell/no-unicode-literals.sh deleted file mode 100755 index e659242b18d..00000000000 --- a/test/sanity/code-smell/no-unicode-literals.sh +++ /dev/null @@ -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