|
1 from __future__ import absolute_import |
|
2 from __future__ import print_function |
|
3 |
|
4 import os |
|
5 import sys |
|
6 |
|
7 # make it runnable directly without run-tests.py |
|
8 sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')] |
|
9 |
|
10 from mercurial import minifileset |
|
11 |
|
12 def check(text, truecases, falsecases): |
|
13 f = minifileset.compile(text) |
|
14 for args in truecases: |
|
15 if not f(*args): |
|
16 print('unexpected: %r should include %r' % (text, args)) |
|
17 for args in falsecases: |
|
18 if f(*args): |
|
19 print('unexpected: %r should exclude %r' % (text, args)) |
|
20 |
|
21 check('all()', [('a.php', 123), ('b.txt', 0)], []) |
|
22 check('none()', [], [('a.php', 123), ('b.txt', 0)]) |
|
23 check('!!!!((!(!!all())))', [], [('a.php', 123), ('b.txt', 0)]) |
|
24 |
|
25 check('"path:a" & (**.b | **.c)', [('a/b.b', 0), ('a/c.c', 0)], [('b/c.c', 0)]) |
|
26 check('("path:a" & **.b) | **.c', |
|
27 [('a/b.b', 0), ('a/c.c', 0), ('b/c.c', 0)], []) |
|
28 |
|
29 check('**.bin - size("<20B")', [('b.bin', 21)], [('a.bin', 11), ('b.txt', 21)]) |
|
30 |
|
31 check('!!**.bin or size(">20B") + "path:bin" or !size(">10")', |
|
32 [('a.bin', 11), ('b.txt', 21), ('bin/abc', 11)], |
|
33 [('a.notbin', 11), ('b.txt', 11), ('bin2/abc', 11)]) |
|
34 |
|
35 check('(**.php and size(">10KB")) | **.zip | ("path:bin" & !"path:bin/README") ' |
|
36 ' | size(">1M")', |
|
37 [('a.php', 15000), ('a.zip', 0), ('bin/a', 0), ('bin/README', 1e7)], |
|
38 [('a.php', 5000), ('b.zip2', 0), ('t/bin/a', 0), ('bin/README', 1)]) |