##// END OF EJS Templates
tests: do not change sys.path, it can break loading cext.parsers...
Joerg Sonnenberger -
r40134:8a08aefa default
parent child Browse files
Show More
@@ -1,45 +1,39
1 1 from __future__ import absolute_import, print_function
2 2
3 import os
4 import sys
5
6 # make it runnable using python directly without run-tests.py
7 sys.path[0:0] = [os.path.join(os.path.dirname(__file__), '..')]
8
9 3 # Import something from Mercurial, so the module loader gets initialized.
10 4 from mercurial import pycompat
11 5 del pycompat # unused for now
12 6
13 7 from hgext.lfs import pointer
14 8
15 9 def tryparse(text):
16 10 r = {}
17 11 try:
18 12 r = pointer.deserialize(text)
19 13 print('ok')
20 14 except Exception as ex:
21 15 print((b'%s' % ex).decode('ascii'))
22 16 if r:
23 17 text2 = r.serialize()
24 18 if text2 != text:
25 19 print('reconstructed text differs')
26 20 return r
27 21
28 22 t = (b'version https://git-lfs.github.com/spec/v1\n'
29 23 b'oid sha256:4d7a214614ab2935c943f9e0ff69d22eadbb8f32b1'
30 24 b'258daaa5e2ca24d17e2393\n'
31 25 b'size 12345\n'
32 26 b'x-foo extra-information\n')
33 27
34 28 tryparse(b'')
35 29 tryparse(t)
36 30 tryparse(t.replace(b'git-lfs', b'unknown'))
37 31 tryparse(t.replace(b'v1\n', b'v1\n\n'))
38 32 tryparse(t.replace(b'sha256', b'ahs256'))
39 33 tryparse(t.replace(b'sha256:', b''))
40 34 tryparse(t.replace(b'12345', b'0x12345'))
41 35 tryparse(t.replace(b'extra-information', b'extra\0information'))
42 36 tryparse(t.replace(b'extra-information', b'extra\ninformation'))
43 37 tryparse(t.replace(b'x-foo', b'x_foo'))
44 38 tryparse(t.replace(b'oid', b'blobid'))
45 39 tryparse(t.replace(b'size', b'size-bytes').replace(b'oid', b'object-id'))
@@ -1,41 +1,35
1 1 from __future__ import absolute_import
2 2 from __future__ import print_function
3 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 4 from mercurial import minifileset
11 5
12 6 def check(text, truecases, falsecases):
13 7 f = minifileset.compile(text)
14 8 for args in truecases:
15 9 if not f(*args):
16 10 print('unexpected: %r should include %r' % (text, args))
17 11 for args in falsecases:
18 12 if f(*args):
19 13 print('unexpected: %r should exclude %r' % (text, args))
20 14
21 15 check(b'all()', [(b'a.php', 123), (b'b.txt', 0)], [])
22 16 check(b'none()', [], [(b'a.php', 123), (b'b.txt', 0)])
23 17 check(b'!!!!((!(!!all())))', [], [(b'a.php', 123), (b'b.txt', 0)])
24 18
25 19 check(b'"path:a" & (**.b | **.c)',
26 20 [(b'a/b.b', 0), (b'a/c.c', 0)], [(b'b/c.c', 0)])
27 21 check(b'(path:a & **.b) | **.c',
28 22 [(b'a/b.b', 0), (b'a/c.c', 0), (b'b/c.c', 0)], [])
29 23
30 24 check(b'**.bin - size("<20B")',
31 25 [(b'b.bin', 21)], [(b'a.bin', 11), (b'b.txt', 21)])
32 26
33 27 check(b'!!**.bin or size(">20B") + "path:bin" or !size(">10")',
34 28 [(b'a.bin', 11), (b'b.txt', 21), (b'bin/abc', 11)],
35 29 [(b'a.notbin', 11), (b'b.txt', 11), (b'bin2/abc', 11)])
36 30
37 31 check(
38 32 b'(**.php and size(">10KB")) | **.zip | ("path:bin" & !"path:bin/README") '
39 33 b' | size(">1M")',
40 34 [(b'a.php', 15000), (b'a.zip', 0), (b'bin/a', 0), (b'bin/README', 1e7)],
41 35 [(b'a.php', 5000), (b'b.zip2', 0), (b't/bin/a', 0), (b'bin/README', 1)])
General Comments 0
You need to be logged in to leave comments. Login now