Any issues with the backport_tests.py aside, one of the unittest tests
fails as well.
Patch attached. I'd commit it directly, but I'd have to reset my apache.org
password first. In the meantime, Daniel (or anyone else), feel free to
go ahead and commit it if doing so would unblock your workflow.
Cheers,
Daniel
{{{
Follow-up to r1824013: unbreak the unit tests.
Fixes the following test failure:
[[[
% python3 -m unittest backport.status
.F......
======================================================================
FAIL: test___init__ (backport.status.Test_StatusEntry.test___init__)
Test the entry parser
----------------------------------------------------------------------
Traceback (most recent call last):
File "tools/dist/backport/status.py", line 630, in test___init__
with self.assertRaisesRegex(ParseException, "No logsummary"):
AssertionError: ParseException not raised
----------------------------------------------------------------------
Ran 8 tests in 0.001s
FAILED (failures=1)
]]]
* tools/dist/backport/status.py
(StatusEntry._parse): Revert the fix part of r1824013.
(StatusEntry._is_subheader): Make it return false on area names,
thereby ensuring backport_logsummary_colon() continues to pass.
(Test_StatusEntry.test__is_subheader): Test false cases as well.
}}}
{{{
Index: tools/dist/backport/status.py
===================================================================
--- tools/dist/backport/status.py (revision 1922016)
+++ tools/dist/backport/status.py (working copy)
@@ -379,11 +379,9 @@ class StatusEntry:
raise ParseException("Entry found with neither branch nor revisions")
# Parse the logsummary.
- while True:
+ while lines and not self._is_subheader(lines[0]):
self.logsummary.append(lines[0])
lines = lines[1:]
- if (not lines) or self._is_subheader(lines[0]):
- break
# Parse votes.
if "Votes:" in lines:
@@ -509,13 +507,15 @@ class StatusEntry:
@staticmethod
def _is_subheader(string):
"""Given a single line from an entry, is that line a subheader (such as
- "Justification:" or "Notes:")?"""
- # TODO: maybe change the 'subheader' heuristic? Perhaps "line starts with
- # an uppercase letter and ends with a colon".
- #
- # This is currently only used for finding the end of logsummary, and all
- # explicitly special-cased headers (e.g., "Depends:") match this, though.
- return re.compile(r'^\s*[A-Z]\w*:').match(string)
+ "Justification:" or "Notes:"?"""
+ known_headers = (
+ "Justification", "Depends", "Branch", "Votes",
+ "Note", "Notes",
+ )
+ return any(
+ string.startswith(h + ":")
+ for h in known_headers
+ )
def unparse(self, stream):
"Write this entry to STREAM, an open file-like object."
@@ -686,12 +686,17 @@ class Test_StatusEntry(unittest.TestCase):
self.assertEqual(StatusEntry.parse_branch(string), "1.8.x-r42")
def test__is_subheader(self):
- "Test that all explicitly-special-cased headers are detected as
subheaders."
+ # Test that all explicitly-special-cased headers are detected as
subheaders.
subheaders = "Justification: Notes: Depends: Branch: Votes:".split()
for subheader in subheaders:
self.assertTrue(StatusEntry._is_subheader(subheader))
self.assertTrue(StatusEntry._is_subheader(subheader + " with value"))
+ # Test that area names are not detected as subheaders.
+ for area in ("HTTPv2", "JavaHL", "tests", "cmdline client"):
+ self.assertFalse(StatusEntry._is_subheader(area + ":"))
+ self.assertFalse(StatusEntry._is_subheader(area + ": fix a typo"))
+
def setUpModule():
"Set-up function, invoked by 'python -m unittest'."
}}}