Patchwork [1,of,9] run-tests: use symbolic constant instead of arbitrary number line matching

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 7, 2019, 12:16 p.m.
Message ID <f927343f31b96019d36f.1567858600@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41531/
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 1560517187 -3600
#      Fri Jun 14 13:59:47 2019 +0100
# Node ID f927343f31b96019d36f0546f71ebe9a357b0123
# Parent  69195b6f8f974ba56aec9b9bd4cd0a259a646f72
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r f927343f31b9
run-tests: use symbolic constant instead of arbitrary number line matching

(This is a gratuitous cleanup that I made while investigating a bug).
Gregory Szorc - Sept. 7, 2019, 4:42 p.m.
On Sat, Sep 7, 2019 at 5:31 AM Pierre-Yves David <
pierre-yves.david@ens-lyon.org> wrote:

> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@octobus.net>
> # Date 1560517187 -3600
> #      Fri Jun 14 13:59:47 2019 +0100
> # Node ID f927343f31b96019d36f0546f71ebe9a357b0123
> # Parent  69195b6f8f974ba56aec9b9bd4cd0a259a646f72
> # EXP-Topic test-match
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> f927343f31b9
> run-tests: use symbolic constant instead of arbitrary number line matching
>

Queued parts 1-4.


>
> (This is a gratuitous cleanup that I made while investigating a bug).
>
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -1302,6 +1302,10 @@ bchr = chr
>  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 @@ class TTest(Test):
>
>      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 @@ class TTest(Test):
>                                                     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 @@ class TTest(Test):
>          if pos in after:
>              postout += after.pop(pos)
>
> -        if warnonly == 2:
> +        if warnonly == WARN_YES:
>              exitcode = False # Set exitcode to warned.
>
>          return exitcode, postout
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1302,6 +1302,10 @@  bchr = chr
 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 @@  class TTest(Test):
 
     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 @@  class TTest(Test):
                                                    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 @@  class TTest(Test):
         if pos in after:
             postout += after.pop(pos)
 
-        if warnonly == 2:
+        if warnonly == WARN_YES:
             exitcode = False # Set exitcode to warned.
 
         return exitcode, postout