comparison tests/run-tests.py @ 42899:f461b65866e9

run-tests: extract a `process_out_line` from the main function The main function doing line comparison is quite complex. Slicing it in smaller piece should clarify it. To avoid a huge diff, the code is kept at the same indentation. We'll re-indent in the next changesets. (This is a gratuitous cleanup that I made while investigating a bug).
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 14 Jun 2019 17:37:04 +0100
parents fc8072f38fd6
children 8510566b2bef
comparison
equal deleted inserted replaced
42898:fc8072f38fd6 42899:f461b65866e9
1614 for out_rawline in output: 1614 for out_rawline in output:
1615 out_line, cmd_line = out_rawline, None 1615 out_line, cmd_line = out_rawline, None
1616 if salt in out_rawline: 1616 if salt in out_rawline:
1617 out_line, cmd_line = out_rawline.split(salt, 1) 1617 out_line, cmd_line = out_rawline.split(salt, 1)
1618 1618
1619 pos, postout, warnonly = self._process_out_line(out_line,
1620 pos,
1621 postout,
1622 expected,
1623 warnonly)
1624 pos, postout = self._process_cmd_line(cmd_line, pos, postout,
1625 after)
1626
1627 if pos in after:
1628 postout += after.pop(pos)
1629
1630 if warnonly == WARN_YES:
1631 exitcode = False # Set exitcode to warned.
1632
1633 return exitcode, postout
1634
1635 def _process_out_line(self, out_line, pos, postout, expected, warnonly):
1636 if True:
1619 while out_line: 1637 while out_line:
1620 if not out_line.endswith(b'\n'): 1638 if not out_line.endswith(b'\n'):
1621 out_line += b' (no-eol)\n' 1639 out_line += b' (no-eol)\n'
1622 1640
1623 # Find the expected output at the current position. 1641 # Find the expected output at the current position.
1692 # Don't append as optional line 1710 # Don't append as optional line
1693 continue 1711 continue
1694 else: 1712 else:
1695 continue 1713 continue
1696 postout.append(b' ' + el) 1714 postout.append(b' ' + el)
1697 1715 return pos, postout, warnonly
1698 pos, postout = self._process_cmd_line(cmd_line, pos, postout, after)
1699
1700 if pos in after:
1701 postout += after.pop(pos)
1702
1703 if warnonly == WARN_YES:
1704 exitcode = False # Set exitcode to warned.
1705
1706 return exitcode, postout
1707 1716
1708 def _process_cmd_line(self, cmd_line, pos, postout, after): 1717 def _process_cmd_line(self, cmd_line, pos, postout, after):
1709 """process a "command" part of a line from unified test output""" 1718 """process a "command" part of a line from unified test output"""
1710 if cmd_line: 1719 if cmd_line:
1711 # Add on last return code. 1720 # Add on last return code.