Patchwork [7,of,9] run-tests: extract a `process_out_line` from the main function

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 7, 2019, 12:16 p.m.
Message ID <37175973a3ca496e7d32.1567858606@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41536/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 7, 2019, 12:16 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@octobus.net>
# Date 1560530224 -3600
#      Fri Jun 14 17:37:04 2019 +0100
# Node ID 37175973a3ca496e7d32044e342f88ad8894f69b
# Parent  e9d8154ab03d353fcc5284a10d943be0129e4f4e
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 37175973a3ca
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).

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1620,6 +1620,25 @@  class TTest(Test):
                 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'
@@ -1699,17 +1718,7 @@  class TTest(Test):
                             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"""