Mercurial > public > mercurial-scm > hg
comparison tests/test-filecache.py @ 20041:42deff43460a
test-filecache.py: add markers to the output for each event
Previously it was possible that a different, incorrect set of events might
print out 'creating' the same number of times.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Sat, 16 Nov 2013 13:57:35 -0800 |
parents | ed80cecdfc57 |
children | b3684fd2ff1a |
comparison
equal
deleted
inserted
replaced
20040:ed80cecdfc57 | 20041:42deff43460a |
---|---|
29 delattr(self, k) | 29 delattr(self, k) |
30 except AttributeError: | 30 except AttributeError: |
31 pass | 31 pass |
32 | 32 |
33 def basic(repo): | 33 def basic(repo): |
34 # file doesn't exist, calls function | 34 print "* file doesn't exist" |
35 # calls function | |
35 repo.cached | 36 repo.cached |
36 | 37 |
37 repo.invalidate() | 38 repo.invalidate() |
38 # file still doesn't exist, uses cache | 39 print "* file still doesn't exist" |
40 # uses cache | |
39 repo.cached | 41 repo.cached |
40 | 42 |
41 # create empty file | 43 # create empty file |
42 f = open('x', 'w') | 44 f = open('x', 'w') |
43 f.close() | 45 f.close() |
44 repo.invalidate() | 46 repo.invalidate() |
47 print "* empty file x created" | |
45 # should recreate the object | 48 # should recreate the object |
46 repo.cached | 49 repo.cached |
47 | 50 |
48 f = open('x', 'w') | 51 f = open('x', 'w') |
49 f.write('a') | 52 f.write('a') |
50 f.close() | 53 f.close() |
51 repo.invalidate() | 54 repo.invalidate() |
55 print "* file x changed size" | |
52 # should recreate the object | 56 # should recreate the object |
53 repo.cached | 57 repo.cached |
54 | 58 |
55 repo.invalidate() | 59 repo.invalidate() |
56 # stats file again, nothing changed, reuses object | 60 print "* nothing changed with file x" |
61 # stats file again, reuses object | |
57 repo.cached | 62 repo.cached |
58 | 63 |
59 # atomic replace file, size doesn't change | 64 # atomic replace file, size doesn't change |
60 # hopefully st_mtime doesn't change as well so this doesn't use the cache | 65 # hopefully st_mtime doesn't change as well so this doesn't use the cache |
61 # because of inode change | 66 # because of inode change |
62 f = scmutil.opener('.')('x', 'w', atomictemp=True) | 67 f = scmutil.opener('.')('x', 'w', atomictemp=True) |
63 f.write('b') | 68 f.write('b') |
64 f.close() | 69 f.close() |
65 | 70 |
66 repo.invalidate() | 71 repo.invalidate() |
72 print "* file x changed inode" | |
67 repo.cached | 73 repo.cached |
68 | 74 |
69 def fakeuncacheable(): | 75 def fakeuncacheable(): |
70 def wrapcacheable(orig, *args, **kwargs): | 76 def wrapcacheable(orig, *args, **kwargs): |
71 return False | 77 return False |
104 | 110 |
105 def setbeforeget(repo): | 111 def setbeforeget(repo): |
106 os.remove('x') | 112 os.remove('x') |
107 repo.cached = 'string set externally' | 113 repo.cached = 'string set externally' |
108 repo.invalidate() | 114 repo.invalidate() |
115 print "* file x doesn't exist" | |
109 print repo.cached | 116 print repo.cached |
110 repo.invalidate() | 117 repo.invalidate() |
111 f = open('x', 'w') | 118 f = open('x', 'w') |
112 f.write('a') | 119 f.write('a') |
113 f.close() | 120 f.close() |
121 print "* file x created" | |
114 print repo.cached | 122 print repo.cached |
115 | 123 |
116 print 'basic:' | 124 print 'basic:' |
117 print | 125 print |
118 basic(fakerepo()) | 126 basic(fakerepo()) |