Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate sanity test ignore entries. #59665

Merged
merged 20 commits into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 0 additions & 14 deletions test/sanity/code-smell/empty-init.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,7 @@


def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
# facts is grandfathered in but will break namespacing
# the only way to fix it is to deprecate and eventually remove it
# six and distro will break namespacing but because it is bundled we should not be
# overriding it
'lib/ansible/module_utils/facts/__init__.py',
'lib/ansible/module_utils/six/__init__.py',
'lib/ansible/module_utils/distro/__init__.py',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
if path in skip:
continue

if os.path.getsize(path) > 0:
print('%s: empty __init__.py required' % path)

Expand Down
978 changes: 1 addition & 977 deletions test/sanity/code-smell/future-import-boilerplate.py

Large diffs are not rendered by default.

12 changes: 0 additions & 12 deletions test/sanity/code-smell/line-endings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,7 @@


def main():
skip = set([
'test/integration/targets/template/files/foo.dos.txt',
'test/integration/targets/win_regmerge/templates/win_line_ending.j2',
'test/integration/targets/win_template/files/foo.dos.txt',
'test/integration/targets/win_module_utils/library/legacy_only_new_way_win_line_ending.ps1',
'test/integration/targets/win_module_utils/library/legacy_only_old_way_win_line_ending.ps1',
'test/units/modules/network/routeros/fixtures/system_package_print',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
if path in skip:
continue

with open(path, 'rb') as path_fd:
contents = path_fd.read()

Expand Down
977 changes: 1 addition & 976 deletions test/sanity/code-smell/metaclass-boilerplate.py

Large diffs are not rendered by default.

10 changes: 0 additions & 10 deletions test/sanity/code-smell/no-assert.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import os
import re
import sys

ASSERT_RE = re.compile(r'^\s*assert[^a-z0-9_:]')


def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
'lib/ansible/module_utils/compat/ipaddress.py',
'lib/ansible/module_utils/distro/_distro.py',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
if path in skip:
continue

with open(path, 'r') as f:
for i, line in enumerate(f.readlines()):
matches = ASSERT_RE.findall(line)
Expand Down
1 change: 0 additions & 1 deletion test/sanity/code-smell/no-basestring.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
'lib/ansible/module_utils/six/__init__.py',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
Expand Down
1 change: 0 additions & 1 deletion test/sanity/code-smell/no-dict-iteritems.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
'lib/ansible/module_utils/six/__init__.py',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
Expand Down
1 change: 0 additions & 1 deletion test/sanity/code-smell/no-dict-iterkeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
'lib/ansible/module_utils/six/__init__.py',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
Expand Down
1 change: 0 additions & 1 deletion test/sanity/code-smell/no-dict-itervalues.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
'lib/ansible/module_utils/six/__init__.py',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
Expand Down
1 change: 0 additions & 1 deletion test/sanity/code-smell/no-get-exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
'lib/ansible/module_utils/pycompat24.py',
])

basic_allow_once = True
Expand Down
7 changes: 0 additions & 7 deletions test/sanity/code-smell/no-main-display.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,13 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import os
import re
import sys

MAIN_DISPLAY_IMPORT = 'from __main__ import display'


def main():
skip = set()

for path in sys.argv[1:] or sys.stdin.read().splitlines():
if path in skip:
continue

with open(path, 'r') as f:
for i, line in enumerate(f.readlines()):
if MAIN_DISPLAY_IMPORT in line:
Expand Down
6 changes: 0 additions & 6 deletions test/sanity/code-smell/no-smart-quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@

def main():
skip = set([
'docs/docsite/rst/dev_guide/testing/sanity/no-smart-quotes.rst',
'test/integration/targets/lookup_properties/lookup-8859-15.ini',
'test/integration/targets/template/files/encoding_1252_utf-8.expected',
'test/integration/targets/template/files/encoding_1252_windows-1252.expected',
'test/integration/targets/template/templates/encoding_1252.j2',
'test/integration/targets/unicode/unicode.yml',
'test/sanity/code-smell/%s' % os.path.basename(__file__),
])

Expand Down
1 change: 0 additions & 1 deletion test/sanity/code-smell/no-unicode-literals.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
'lib/ansible/module_utils/compat/ipaddress.py',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
Expand Down
11 changes: 0 additions & 11 deletions test/sanity/code-smell/no-unwanted-files.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,11 @@ def main():
'.py',
)

skip = (
# allowed special cases
'lib/ansible/config/base.yml',
'lib/ansible/config/module_defaults.yml',
'lib/ansible/galaxy/data/collections_galaxy_meta.yml',
)

skip_directories = (
'lib/ansible.egg-info/',
'lib/ansible/galaxy/data/',
)

for path in paths:
if path in skip:
continue

if any(path.startswith(skip_directory) for skip_directory in skip_directories):
continue

Expand Down
4 changes: 0 additions & 4 deletions test/sanity/code-smell/replace-urlopen.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
'lib/ansible/module_utils/six/__init__.py',
'lib/ansible/module_utils/urls.py',
'test/units/module_utils/urls/test_Request.py',
'test/units/module_utils/urls/test_fetch_url.py',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
Expand Down
8 changes: 0 additions & 8 deletions test/sanity/code-smell/required-and-default-attributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

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'(FieldAttribute.*(default|required).*(default|required))', text)
Expand Down
16 changes: 0 additions & 16 deletions test/sanity/code-smell/shebang.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,6 @@ def main():
'.ps1': b'#!powershell',
}

skip = set([
'test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/win_csbasic_only.ps1',
'test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/win_selfcontained.ps1',
'test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/win_uses_coll_csmu.ps1',
'test/integration/targets/collections/collection_root_user/ansible_collections/testns/testcoll/plugins/modules/win_uses_coll_psmu.ps1',
'test/integration/targets/win_module_utils/library/legacy_only_new_way_win_line_ending.ps1',
'test/integration/targets/win_module_utils/library/legacy_only_old_way_win_line_ending.ps1',
'test/utils/shippable/timing.py',
'test/integration/targets/old_style_modules_posix/library/helloworld.sh',
# The following are Python 3.6+. Only run by release engineers
'hacking/build-ansible.py',
])

# see https://unicode.org/faq/utf_bom.html#bom1
byte_order_marks = (
(b'\x00\x00\xFE\xFF', 'UTF-32 (BE)'),
Expand All @@ -54,9 +41,6 @@ def main():
)

for path in sys.argv[1:] or sys.stdin.read().splitlines():
if path in skip:
continue

with open(path, 'rb') as path_fd:
shebang = path_fd.readline().strip()
mode = os.stat(path).st_mode
Expand Down
8 changes: 0 additions & 8 deletions test/sanity/code-smell/test-constraints.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,7 @@


def main():
skip = set([
'test/runner/requirements/constraints.txt',
'test/runner/requirements/integration.cloud.azure.txt',
])

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'^[^;#]*?([<>=])(?!.*sanity_ok.*)', text)
Expand Down
30 changes: 0 additions & 30 deletions test/sanity/code-smell/use-argspec-type-path.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,37 +7,7 @@


def main():
skip = set([
# add legitimate uses of expanduser to the following list
'lib/ansible/modules/cloud/docker/docker_container.py', # uses colon-separated paths, can't use type=path
'lib/ansible/modules/cloud/lxc/lxc_container.py',
'lib/ansible/modules/cloud/rackspace/rax_files_objects.py',
'lib/ansible/modules/database/mongodb/mongodb_parameter.py',
'lib/ansible/modules/database/mongodb/mongodb_replicaset.py',
'lib/ansible/modules/database/mongodb/mongodb_shard.py',
'lib/ansible/modules/database/mongodb/mongodb_user.py',
'lib/ansible/modules/database/postgresql/postgresql_db.py',
'lib/ansible/modules/files/synchronize.py',
'lib/ansible/modules/source_control/git.py',
'lib/ansible/modules/system/puppet.py',
'lib/ansible/modules/utilities/logic/async_status.py',
'lib/ansible/modules/utilities/logic/async_wrapper.py',
'lib/ansible/modules/web_infrastructure/ansible_tower/tower_host.py',
'lib/ansible/modules/web_infrastructure/ansible_tower/tower_group.py',
'lib/ansible/modules/web_infrastructure/jenkins_plugin.py',
'lib/ansible/modules/cloud/vmware/vmware_deploy_ovf.py',
'lib/ansible/modules/crypto/certificate_complete_chain.py', # would need something like type=list(path)
# fix uses of expanduser in the following modules and remove them from the following list
'lib/ansible/modules/cloud/rackspace/rax.py',
'lib/ansible/modules/cloud/rackspace/rax_scaling_group.py',
'lib/ansible/modules/files/archive.py',
'lib/ansible/modules/files/find.py',
])

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'(expanduser)', text)
Expand Down
14 changes: 0 additions & 14 deletions test/sanity/code-smell/use-compat-six.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,12 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

import os
import re
import sys


def main():
skip = set([
'test/sanity/code-smell/%s' % os.path.basename(__file__),
# digital_ocean is checking for six because dopy doesn't specify the
# requirement on six so it needs to try importing six to give the correct error message
'lib/ansible/modules/cloud/digital_ocean/digital_ocean.py',
])

for path in sys.argv[1:] or sys.stdin.read().splitlines():
if path in skip:
continue

if path.startswith('test/sanity/pylint/plugins/'):
continue

with open(path, 'r') as path_fd:
for line, text in enumerate(path_fd.readlines()):
match = re.search(r'((^\s*import\s+six\b)|(^\s*from\s+six\b))', text)
Expand Down