view tests/test-minifileset.py @ 40572:def08813b290

tests: remove obsolete PYTHONPATH override from remotefilelog tests They were added in https://bitbucket.org/facebook/hg-experimental/commits/fdcad37a6a68cfbaf5920f3eeaa0cc9cae42bd26, which says this: When remotefilelog moved from its own repo, the tests needed to be updated to adjust the PYTHONPATH to ensure the in-repo remotefilelog was loaded instead of the system one. This meant any local runs of remotefilelog tests would've been using the system remotefilelog unless the user had manually set the PYTHONPATH themselves. That doesn't seem relevant with remotefilelog in core. Differential Revision: https://phab.mercurial-scm.org/D5248
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 09 Nov 2018 09:27:37 -0800
parents 8a08aefa9273
children 2372284d9457
line wrap: on
line source

from __future__ import absolute_import
from __future__ import print_function

from mercurial import minifileset

def check(text, truecases, falsecases):
    f = minifileset.compile(text)
    for args in truecases:
        if not f(*args):
            print('unexpected: %r should include %r' % (text, args))
    for args in falsecases:
        if f(*args):
            print('unexpected: %r should exclude %r' % (text, args))

check(b'all()', [(b'a.php', 123), (b'b.txt', 0)], [])
check(b'none()', [], [(b'a.php', 123), (b'b.txt', 0)])
check(b'!!!!((!(!!all())))', [], [(b'a.php', 123), (b'b.txt', 0)])

check(b'"path:a" & (**.b | **.c)',
      [(b'a/b.b', 0), (b'a/c.c', 0)], [(b'b/c.c', 0)])
check(b'(path:a & **.b) | **.c',
      [(b'a/b.b', 0), (b'a/c.c', 0), (b'b/c.c', 0)], [])

check(b'**.bin - size("<20B")',
      [(b'b.bin', 21)], [(b'a.bin', 11), (b'b.txt', 21)])

check(b'!!**.bin or size(">20B") + "path:bin" or !size(">10")',
      [(b'a.bin', 11), (b'b.txt', 21), (b'bin/abc', 11)],
      [(b'a.notbin', 11), (b'b.txt', 11), (b'bin2/abc', 11)])

check(
    b'(**.php and size(">10KB")) | **.zip | ("path:bin" & !"path:bin/README") '
    b' | size(">1M")',
    [(b'a.php', 15000), (b'a.zip', 0), (b'bin/a', 0), (b'bin/README', 1e7)],
    [(b'a.php', 5000), (b'b.zip2', 0), (b't/bin/a', 0), (b'bin/README', 1)])