run-tests: use symbolic constant instead of arbitrary number line matching
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 14 Jun 2019 13:59:47 +0100
changeset 42866 141bb77b606b
parent 42865 69195b6f8f97
child 42867 eab66266180e
run-tests: use symbolic constant instead of arbitrary number line matching (This is a gratuitous cleanup that I made while investigating a bug).
tests/run-tests.py
--- a/tests/run-tests.py	Sun Aug 25 23:40:22 2019 -0400
+++ b/tests/run-tests.py	Fri Jun 14 13:59:47 2019 +0100
@@ -1302,6 +1302,10 @@
 if PYTHON3:
     bchr = lambda x: bytes([x])
 
+WARN_UNDEFINED = 1
+WARN_YES = 2
+WARN_NO = 3
+
 class TTest(Test):
     """A "t test" is a test backed by a .t file."""
 
@@ -1601,9 +1605,9 @@
 
     def _processoutput(self, exitcode, output, salt, after, expected):
         # Merge the script output back into a unified test.
-        warnonly = 1 # 1: not yet; 2: yes; 3: for sure not
+        warnonly = WARN_UNDEFINED # 1: not yet; 2: yes; 3: for sure not
         if exitcode != 0:
-            warnonly = 3
+            warnonly = WARN_NO
 
         pos = -1
         postout = []
@@ -1670,9 +1674,9 @@
                                                    lout.rstrip(b'\n'))
                     postout.append(b'  ' + lout) # Let diff deal with it.
                     if r != '': # If line failed.
-                        warnonly = 3 # for sure not
-                    elif warnonly == 1: # Is "not yet" and line is warn only.
-                        warnonly = 2 # Yes do warn.
+                        warnonly = WARN_NO
+                    elif warnonly == WARN_UNDEFINED:
+                        warnonly = WARN_YES
                 break
             else:
                 # clean up any optional leftovers
@@ -1704,7 +1708,7 @@
         if pos in after:
             postout += after.pop(pos)
 
-        if warnonly == 2:
+        if warnonly == WARN_YES:
             exitcode = False # Set exitcode to warned.
 
         return exitcode, postout