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

Clean up sanity test ignore handling. #59749

Merged
merged 4 commits into from
Jul 29, 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
7 changes: 7 additions & 0 deletions test/runner/lib/sanity/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,7 @@ def test(self, args, targets, python_version):
always = self.config.get('always')
text = self.config.get('text')
ignore_changes = self.config.get('ignore_changes')
ignore_self = self.config.get('ignore_self')

if output == 'path-line-column-message':
pattern = '^(?P<path>[^:]*):(?P<line>[0-9]+):(?P<column>[0-9]+): (?P<message>.*)$'
Expand Down Expand Up @@ -609,6 +610,12 @@ def test(self, args, targets, python_version):
if files:
paths = [p for p in paths if os.path.basename(p) in files]

if ignore_self and data_context().content.is_ansible:
relative_self_path = os.path.relpath(self.path, data_context().content.root)

if relative_self_path in paths:
paths.remove(relative_self_path)

paths = settings.filter_skipped_paths(paths)

if not paths and not always:
Expand Down
14 changes: 0 additions & 14 deletions test/sanity/code-smell/future-import-boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,7 @@


def main():
# We classify files in these directories as ones we don't care about fixing (at least for now)
prune = (
'contrib/inventory/',
'contrib/vault/',
'docs/',
'examples/',
'test/integration/',
'test/legacy/',
'test/units/',
)

for path in sys.argv[1:] or sys.stdin.read().splitlines():
if any(path.startswith(p) for p in prune):
continue

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

Expand Down
14 changes: 0 additions & 14 deletions test/sanity/code-smell/metaclass-boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,7 @@


def main():
# These files pre-date the boilerplate test and should be fixed up as time goes on
prune = (
'contrib/inventory/',
'contrib/vault/',
'docs/',
'examples/',
'test/integration/',
'test/legacy/',
'test/units/',
)

for path in sys.argv[1:] or sys.stdin.read().splitlines():
if any(path.startswith(p) for p in prune):
continue

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

Expand Down
1 change: 1 addition & 0 deletions test/sanity/code-smell/no-basestring.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"extensions": [
".py"
],
"ignore_self": true,
"output": "path-line-column-message"
}
8 changes: 0 additions & 8 deletions test/sanity/code-smell/no-basestring.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'(isinstance.*basestring)', text)
Expand Down
1 change: 1 addition & 0 deletions test/sanity/code-smell/no-dict-iteritems.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"extensions": [
".py"
],
"ignore_self": true,
"output": "path-line-column-message"
}
8 changes: 0 additions & 8 deletions test/sanity/code-smell/no-dict-iteritems.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'(?<! six)\.(iteritems)', text)
Expand Down
1 change: 1 addition & 0 deletions test/sanity/code-smell/no-dict-iterkeys.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"extensions": [
".py"
],
"ignore_self": true,
"output": "path-line-column-message"
}
8 changes: 0 additions & 8 deletions test/sanity/code-smell/no-dict-iterkeys.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'\.(iterkeys)', text)
Expand Down
1 change: 1 addition & 0 deletions test/sanity/code-smell/no-dict-itervalues.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"extensions": [
".py"
],
"ignore_self": true,
"output": "path-line-column-message"
}
8 changes: 0 additions & 8 deletions test/sanity/code-smell/no-dict-itervalues.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'(?<! six)\.(itervalues)', text)
Expand Down
1 change: 1 addition & 0 deletions test/sanity/code-smell/no-get-exception.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"extensions": [
".py"
],
"ignore_self": true,
"output": "path-line-column-message"
}
8 changes: 0 additions & 8 deletions test/sanity/code-smell/no-get-exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
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__),
])

basic_allow_once = True

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'([^a-zA-Z0-9_]get_exception[^a-zA-Z0-9_])', text)
Expand Down
1 change: 1 addition & 0 deletions test/sanity/code-smell/no-smart-quotes.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"text": true,
"ignore_self": true,
"output": "path-line-column-message"
}
15 changes: 0 additions & 15 deletions test/sanity/code-smell/no-smart-quotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,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__),
])

prune = set([
'docs/docsite/_build/',
])

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

if any(path.startswith(p) for p in prune):
continue

with open(path, 'rb') as path_fd:
for line, text in enumerate(path_fd.readlines()):
try:
Expand Down
1 change: 1 addition & 0 deletions test/sanity/code-smell/no-unicode-literals.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"extensions": [
".py"
],
"ignore_self": true,
"output": "path-line-column-message"
}
8 changes: 0 additions & 8 deletions test/sanity/code-smell/no-unicode-literals.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'(unicode_literals)', text)
Expand Down
1 change: 1 addition & 0 deletions test/sanity/code-smell/replace-urlopen.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
"extensions": [
".py"
],
"ignore_self": true,
"output": "path-line-column-message"
}
8 changes: 0 additions & 8 deletions test/sanity/code-smell/replace-urlopen.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'^(?:[^#]*?)(urlopen)', text)
Expand Down