This is an archive of the discontinued Mercurial Phabricator instance.

match: de-flake test-doctest.py by not depending on util.dirs() order
ClosedPublic

Authored by martinvonz on May 22 2019, 5:26 PM.

Details

Summary

util.dirs() yields directories in arbitrary order, which has made
test-doctest.py flaky. I think they have been flaky since d8e55c0c642c
(util: make util.dirs() and util.finddirs() include root directory
(API), 2017-05-16). Before that commit, I think util.dirs() would
return at most one entry, so there was only one iteration order. This
patch fixes the problem by making _rootsdirsandparents() return a set
(whose str() is defined to be in sorted order, I believe). The
only caller wanted a set anyway.

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.May 22 2019, 5:26 PM
yuja added a subscriber: yuja.May 22 2019, 7:26 PM

@@ -1384,26 +1384,26 @@

>>> _rootsdirsandparents(
...     [(b'glob', b'g/h/*', b''), (b'glob', b'g/h', b''),
...      (b'glob', b'g*', b'')])
  • (['g/h', 'g/h', ''], [], ['', 'g'])

+ (['g/h', 'g/h', ''], [], set(['', 'g']))

Perhaps, this would break py3 doctests. The repr syntax changed.

This revision was automatically updated to reflect the committed changes.
In D6432#93545, @yuja wrote:

@@ -1384,26 +1384,26 @@

>>> _rootsdirsandparents(
...     [(b'glob', b'g/h/*', b''), (b'glob', b'g/h', b''),
...      (b'glob', b'g*', b'')])
  • (['g/h', 'g/h', ''], [], ['', 'g'])

+ (['g/h', 'g/h', ''], [], set(['', 'g']))

Perhaps, this would break py3 doctests. The repr syntax changed.

Good point. However, it turns out they were already broken (b'' prefixes), so I'll leave it for the py3 folks to clean up.

yuja added a comment.May 24 2019, 8:28 AM
> > @@ -1384,26 +1384,26 @@
> > 
> >   >>> _rootsdirsandparents(
> >   ...     [(b'glob', b'g/h/*', b''), (b'glob', b'g/h', b''),
> >   ...      (b'glob', b'g*', b'')])
> > 
> > - (['g/h', 'g/h', ''], [], ['', 'g']) +    (['g/h', 'g/h', ''], [], set(['', 'g']))
>
> Perhaps, this would break py3 doctests. The repr syntax changed.
Good point. However, it turns out they were already broken (b'' prefixes), so I'll leave it for the py3 folks to clean up.

FYI, there's a weird hack to normalize '', u'', and b'' because that's the
only way to make doctests portable.