Patchwork D7731: tests: fix failing doctest in match.py by adding dummy auditor

login
register
mail settings
Submitter phabricator
Date Dec. 27, 2019, 6:01 p.m.
Message ID <differential-rev-PHID-DREV-ig37z726bhe3lapw4lfj-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44060/
State Superseded
Headers show

Comments

phabricator - Dec. 27, 2019, 6:01 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  It was failing with "OSError: [Errno 13] Permission denied:
  '/root/sub'". It has been failing since 8b1a9ba375e5 <https://phab.mercurial-scm.org/rHG8b1a9ba375e5dfade0e4e57be0ffd505887e936f> (match: make sure
  `root` argument is always an absolute path (API), 2019-12-13). I don't
  know why I didn't notice it before sending that patch.

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D7731

AFFECTED FILES
  mercurial/match.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 7, 2020, 11:42 a.m.
marmoute added a comment.
marmoute accepted this revision.


  I was wondering why the doctest were on fire. Thanks for the fix.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7731/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7731

To: martinvonz, #hg-reviewers, marmoute
Cc: marmoute, mercurial-devel
phabricator - Jan. 7, 2020, 5:41 p.m.
mharbison72 added a comment.
mharbison72 accepted this revision.


  Oddly, it's not an issue on Windows.  No idea why that's the case.  What's the stacktrace look like?

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7731/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7731

To: martinvonz, #hg-reviewers, marmoute, mharbison72
Cc: mharbison72, marmoute, mercurial-devel
phabricator - Jan. 7, 2020, 5:52 p.m.
martinvonz added a comment.


  In D7731#114647 <https://phab.mercurial-scm.org/D7731#114647>, @mharbison72 wrote:
  
  > Oddly, it's not an issue on Windows.  No idea why that's the case.  What's the stacktrace look like?
  
  
  
    +**********************************************************************
    +File "/usr/local/google/home/martinvonz/hg/mercurial/match.py", line 948, in mercurial.match.subdirmatcher
    +Failed example:   
    +    m1 = match(util.localpath(b'/root'), b'', [b'a.txt', b'sub/b.txt'])
    +Exception raised:                                                                                                                          
    +    Traceback (most recent call last):                                                                                                     
    +      File "/usr/lib/python2.7/doctest.py", line 1315, in __run
    +        compileflags, 1) in test.globs
    +      File "<doctest mercurial.match.subdirmatcher[1]>", line 1, in <module>
    +        m1 = match(util.localpath(b'/root'), b'', [b'a.txt', b'sub/b.txt'])
    +      File "/usr/local/google/home/martinvonz/hg/mercurial/match.py", line 257, in match
    +        kindpats = normalize(patterns, default, root, cwd, auditor, warn)
    +      File "/usr/local/google/home/martinvonz/hg/mercurial/match.py", line 326, in _donormalize
    +        pat = pathutil.canonpath(root, cwd, pat, auditor=auditor)
    +      File "/usr/local/google/home/martinvonz/hg/mercurial/pathutil.py", line 207, in canonpath
    +        auditor(name)                                                                                                                      
    +      File "/usr/local/google/home/martinvonz/hg/mercurial/pathutil.py", line 112, in __call__            
    +        self._checkfs(prefix, path)
    +      File "/usr/local/google/home/martinvonz/hg/mercurial/pathutil.py", line 125, in _checkfs
    +        st = os.lstat(curpath)
    +    OSError: [Errno 13] Permission denied: '/root/sub'
    +**********************************************************************

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7731/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7731

To: martinvonz, #hg-reviewers, marmoute, mharbison72
Cc: mharbison72, marmoute, mercurial-devel
phabricator - Jan. 8, 2020, 4:41 a.m.
mharbison72 added a comment.


  In D7731#114648 <https://phab.mercurial-scm.org/D7731#114648>, @martinvonz wrote:
  
  > In D7731#114647 <https://phab.mercurial-scm.org/D7731#114647>, @mharbison72 wrote:
  >
  >> Oddly, it's not an issue on Windows.  No idea why that's the case.  What's the stacktrace look like?
  >
  >   +**********************************************************************
  >   +File "/usr/local/google/home/martinvonz/hg/mercurial/match.py", line 948, in mercurial.match.subdirmatcher
  >   +Failed example:   
  >   +    m1 = match(util.localpath(b'/root'), b'', [b'a.txt', b'sub/b.txt'])
  >   ...
  >   +      File "/usr/local/google/home/martinvonz/hg/mercurial/pathutil.py", line 125, in _checkfs
  >   +        st = os.lstat(curpath)
  >   +    OSError: [Errno 13] Permission denied: '/root/sub'
  >   +**********************************************************************
  
  OK, thanks.  We hit that path on Windows, so it must be something about the `os.lstat` implementation that differs.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7731/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7731

To: martinvonz, #hg-reviewers, marmoute, mharbison72
Cc: mharbison72, marmoute, mercurial-devel

Patch

diff --git a/mercurial/match.py b/mercurial/match.py
--- a/mercurial/match.py
+++ b/mercurial/match.py
@@ -945,7 +945,7 @@ 
     The paths are remapped to remove/insert the path as needed:
 
     >>> from . import pycompat
-    >>> m1 = match(util.localpath(b'/root'), b'', [b'a.txt', b'sub/b.txt'])
+    >>> m1 = match(util.localpath(b'/root'), b'', [b'a.txt', b'sub/b.txt'], auditor=lambda name: None)
     >>> m2 = subdirmatcher(b'sub', m1)
     >>> m2(b'a.txt')
     False