Update hacking.py for @testtools.skip() formatting.

This commit updates the hacking rules to add a strict format for bug
skips. Previously, there was no defined rules for skip formatting
which caused a number of test skips to be added without consistent
formatting. These skips then failed to get picked up by
tools/skip_tracker.py. This commit adds a new hacking test to ensure
that any skips added conform to a format that the skip_tracker will pick
up. HACKING.rst was also updated to explain the new rules being enforced.

Change-Id: I95f3ec7de2ee5e2039d53ad9565b5cec936a7672
This commit is contained in:
Matthew Treinish 2013-03-19 11:44:12 -04:00
parent 770e5a44b4
commit 997da922c9
2 changed files with 37 additions and 0 deletions

View File

@ -153,6 +153,19 @@ Rather than constructing parameters inline, it is better to break things up::
kwarg2=dict_of_numbers)
Test Skips
----------
If a test is broken because of a bug it is appropriate to skip the test until
bug has been fixed. However, the skip message should be formatted so that
Tempest's skip tracking tool can watch the bug status. The skip message should
contain the string 'Bug' immediately followed by a space. Then the bug number
should be included in the message '#' in front of the number.
Example::
@testtools.skip("Skipped until the Bug #980688 is resolved")
openstack-common
----------------

View File

@ -323,6 +323,30 @@ def tempest_no_test_docstring(physical_line, previous_logical, filename):
return (pos, "T404: test functions must "
"not have doc strings")
SKIP_DECORATOR = '@testtools.skip('
def tempest_skip_bugs(physical_line):
"""Check skip lines for proper bug entries
T601: Bug not in skip line
T602: Bug in message formatted incorrectly
"""
pos = physical_line.find(SKIP_DECORATOR)
skip_re = re.compile(r'^\s*@testtools.skip.*')
if pos != -1 and skip_re.match(physical_line):
bug = re.compile(r'^.*\bbug\b.*', re.IGNORECASE)
if bug.match(physical_line) is None:
return (pos, 'T601: skips must have an associated bug')
bug_re = re.compile(r'.*skip\(.*Bug\s\#\d+', re.IGNORECASE)
if bug_re.match(physical_line) is None:
return (pos, 'T602: Bug number formatted incorrectly')
FORMAT_RE = re.compile("%(?:"
"%|" # Ignore plain percents