run-tests: extract a `process_cmd_line` from the main function
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sun, 08 Sep 2019 10:08:41 +0200
changeset 42898 fc8072f38fd6
parent 42897 d7304434390f
child 42899 f461b65866e9
run-tests: extract a `process_cmd_line` from the main function The main function doing line comparison is quite complex. Slicing it in smaller piece should clarify it. (This is a gratuitous cleanup that I made while investigating a bug).
tests/run-tests.py
--- a/tests/run-tests.py	Sun Sep 08 09:42:53 2019 +0200
+++ b/tests/run-tests.py	Sun Sep 08 10:08:41 2019 +0200
@@ -1695,15 +1695,7 @@
                                 continue
                     postout.append(b'  ' + el)
 
-            if cmd_line:
-                # Add on last return code.
-                ret = int(cmd_line.split()[1])
-                if ret != 0:
-                    postout.append(b'  [%d]\n' % ret)
-                if pos in after:
-                    # Merge in non-active test bits.
-                    postout += after.pop(pos)
-                pos = int(cmd_line.split()[0])
+            pos, postout = self._process_cmd_line(cmd_line, pos, postout, after)
 
         if pos in after:
             postout += after.pop(pos)
@@ -1713,6 +1705,19 @@
 
         return exitcode, postout
 
+    def _process_cmd_line(self, cmd_line, pos, postout, after):
+        """process a "command" part of a line from unified test output"""
+        if cmd_line:
+            # Add on last return code.
+            ret = int(cmd_line.split()[1])
+            if ret != 0:
+                postout.append(b'  [%d]\n' % ret)
+            if pos in after:
+                # Merge in non-active test bits.
+                postout += after.pop(pos)
+            pos = int(cmd_line.split()[0])
+        return pos, postout
+
     @staticmethod
     def rematch(el, l):
         try: