Patchwork [5,of,9] run-tests: document the `pos` variable in the matching code

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 7, 2019, 12:16 p.m.
Message ID <a8b6d502b98abcb4853d.1567858604@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/41534/
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 1560529354 -3600
#      Fri Jun 14 17:22:34 2019 +0100
# Node ID a8b6d502b98abcb4853d062d06cbb9d8168c8a32
# Parent  5a3595259384c15ebce94b662592e0091492a4b3
# EXP-Topic test-match
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r a8b6d502b98a
run-tests: document the `pos` variable in the matching code

3 months ago I took some time understand this code, let us not loose what I
learned.
Joerg Sonnenberger - Sept. 7, 2019, 12:59 p.m.
On Sat, Sep 07, 2019 at 02:16:44PM +0200, Pierre-Yves David wrote:
> diff --git a/tests/run-tests.py b/tests/run-tests.py
> --- a/tests/run-tests.py
> +++ b/tests/run-tests.py
> @@ -1609,6 +1609,9 @@ class TTest(Test):
>          if exitcode != 0:
>              warnonly = WARN_NO
>  
> +        # `pos` is the key for the currently expected output it should match an
> +        # entry in `expected`. This `pos` is provided by "command" in the
> +        # output stream. These command are recognised using the `salt`

That should be *on* entry.

>          pos = -1
>          postout = []
>          for out_rawline in output:
> @@ -1628,6 +1631,7 @@ class TTest(Test):
>                  optional = []
>                  for i, el in enumerate(els):
>                      r = False
> +                    assert el is None or bool(el)
>                      if el:
>                          r, exact = self.linematch(el, out_line)
>                      if isinstance(r, str):

Is this chunk intentional?

Joerg
Pierre-Yves David - Sept. 8, 2019, 8:05 a.m.
On 9/7/19 2:59 PM, Joerg Sonnenberger wrote:
> On Sat, Sep 07, 2019 at 02:16:44PM +0200, Pierre-Yves David wrote:
>> diff --git a/tests/run-tests.py b/tests/run-tests.py
>> --- a/tests/run-tests.py
>> +++ b/tests/run-tests.py
>> @@ -1609,6 +1609,9 @@ class TTest(Test):
>>           if exitcode != 0:
>>               warnonly = WARN_NO
>>   
>> +        # `pos` is the key for the currently expected output it should match an
>> +        # entry in `expected`. This `pos` is provided by "command" in the
>> +        # output stream. These command are recognised using the `salt`
> 
> That should be *on* entry.

What do you mean ? That is should be "`pos` is the key for the currently 
expected output it should match on entry in expected?"

> 
>>           pos = -1
>>           postout = []
>>           for out_rawline in output:
>> @@ -1628,6 +1631,7 @@ class TTest(Test):
>>                   optional = []
>>                   for i, el in enumerate(els):
>>                       r = False
>> +                    assert el is None or bool(el)
>>                       if el:
>>                           r, exact = self.linematch(el, out_line)
>>                       if isinstance(r, str):
> 
> Is this chunk intentional?

Oops, I forgot to split it out.
Joerg Sonnenberger - Sept. 8, 2019, 8:50 a.m.
On Sun, Sep 08, 2019 at 10:05:39AM +0200, Pierre-Yves David wrote:
> 
> 
> On 9/7/19 2:59 PM, Joerg Sonnenberger wrote:
> > On Sat, Sep 07, 2019 at 02:16:44PM +0200, Pierre-Yves David wrote:
> > > diff --git a/tests/run-tests.py b/tests/run-tests.py
> > > --- a/tests/run-tests.py
> > > +++ b/tests/run-tests.py
> > > @@ -1609,6 +1609,9 @@ class TTest(Test):
> > >           if exitcode != 0:
> > >               warnonly = WARN_NO
> > > +        # `pos` is the key for the currently expected output it should match an
> > > +        # entry in `expected`. This `pos` is provided by "command" in the
> > > +        # output stream. These command are recognised using the `salt`
> > 
> > That should be *on* entry.
> 
> What do you mean ? That is should be "`pos` is the key for the currently
> expected output it should match on entry in expected?"

OK, ignore what I said.

Joerg

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1609,6 +1609,9 @@  class TTest(Test):
         if exitcode != 0:
             warnonly = WARN_NO
 
+        # `pos` is the key for the currently expected output it should match an
+        # entry in `expected`. This `pos` is provided by "command" in the
+        # output stream. These command are recognised using the `salt`
         pos = -1
         postout = []
         for out_rawline in output:
@@ -1628,6 +1631,7 @@  class TTest(Test):
                 optional = []
                 for i, el in enumerate(els):
                     r = False
+                    assert el is None or bool(el)
                     if el:
                         r, exact = self.linematch(el, out_line)
                     if isinstance(r, str):