This is an archive of the discontinued Mercurial Phabricator instance.

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

Authored by martinvonz on Dec 27 2019, 1:01 PM.

Details

Summary

It was failing with "OSError: [Errno 13] Permission denied:
'/root/sub'". It has been failing since 8b1a9ba375e5 (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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

martinvonz created this revision.Dec 27 2019, 1:01 PM
marmoute accepted this revision.Jan 7 2020, 6:42 AM
marmoute added a subscriber: marmoute.

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

mharbison72 accepted this revision.Jan 7 2020, 12:41 PM
mharbison72 added a subscriber: mharbison72.

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

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'
+**********************************************************************

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.

pulkit accepted this revision.Jan 8 2020, 6:36 AM
This revision is now accepted and ready to land.Jan 8 2020, 6:36 AM