run-tests: extract a `process_out_line` from the main function
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 14 Jun 2019 17:37:04 +0100
changeset 42899 f461b65866e9
parent 42898 fc8072f38fd6
child 42900 8510566b2bef
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).
tests/run-tests.py
--- a/tests/run-tests.py	Sun Sep 08 10:08:41 2019 +0200
+++ b/tests/run-tests.py	Fri Jun 14 17:37:04 2019 +0100
@@ -1616,6 +1616,24 @@
             if salt in out_rawline:
                 out_line, cmd_line = out_rawline.split(salt, 1)
 
+            pos, postout, warnonly = self._process_out_line(out_line,
+                                                            pos,
+                                                            postout,
+                                                            expected,
+                                                            warnonly)
+            pos, postout = self._process_cmd_line(cmd_line, pos, postout,
+                                                  after)
+
+        if pos in after:
+            postout += after.pop(pos)
+
+        if warnonly == WARN_YES:
+            exitcode = False # Set exitcode to warned.
+
+        return exitcode, postout
+
+    def _process_out_line(self, out_line, pos, postout, expected, warnonly):
+        if True:
             while out_line:
                 if not out_line.endswith(b'\n'):
                     out_line += b' (no-eol)\n'
@@ -1694,16 +1712,7 @@
                             else:
                                 continue
                     postout.append(b'  ' + el)
-
-            pos, postout = self._process_cmd_line(cmd_line, pos, postout, after)
-
-        if pos in after:
-            postout += after.pop(pos)
-
-        if warnonly == WARN_YES:
-            exitcode = False # Set exitcode to warned.
-
-        return exitcode, postout
+        return pos, postout, warnonly
 
     def _process_cmd_line(self, cmd_line, pos, postout, after):
         """process a "command" part of a line from unified test output"""