[PATCH 3 of 3] tests: test to detect newly introduced reference cycles

Simon Heimberg simohe at besonet.ch
Mon Jul 13 09:15:01 CDT 2009


# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1247492561 -7200
# Node ID 40634563c71bed080e70648693ca55d48ee3c2f3
# Parent  d0d02a480e6a65cac1c86f7e74445c3e71ed173a
tests: test to detect newly introduced reference cycles

diff -r d0d02a480e6a -r 40634563c71b tests/test-reference-cycle.py
--- /dev/null	Don Jan 01 00:00:00 1970 +0000
+++ b/tests/test-reference-cycle.py	Mon Jul 13 15:42:41 2009 +0200
@@ -0,0 +1,50 @@
+from mercurial import hg, ui, extensions
+import os, gc
+import gc
+
+gcstate = gc.isenabled()
+gc.disable()
+
+u = ui.ui()
+
+print '''test reference cycles: when the test fails and a number is lower, this is good!
+Update the test output.'''
+
+def extension(name):
+    extensions.load(u, name, None)
+    print '  %s' % name
+
+def gccollect(prefix):
+    print '%s: collect %s, garbage %s' % (prefix, gc.collect(), len(gc.garbage))
+
+def test(create=False):
+    repo = hg.repository(u, os.getcwd(), create)
+    repo.status()
+    repo.tags()
+    repo.wfile('a', mode='a').write('a\n')
+    repo.commit('commit a')
+    gccollect('comm')
+    repo.invalidate()
+    gccollect('inva') # del changelog and manifest
+    del repo.dirstate
+    gccollect('dirs')
+    repo = None
+    gccollect('repo')
+
+
+test(True)
+extension('mq')
+test()
+extension('inotify')
+test()
+extension('keyword')
+test()
+extension('parentrevspec')
+test()
+
+u = None
+print
+gccollect('ui')
+
+if gcstate:
+    gc.enable()
diff -r d0d02a480e6a -r 40634563c71b tests/test-reference-cycle.py.out
--- /dev/null	Don Jan 01 00:00:00 1970 +0000
+++ b/tests/test-reference-cycle.py.out	Mon Jul 13 15:42:41 2009 +0200
@@ -0,0 +1,28 @@
+test reference cycles: when the test fails and a number is lower, this is good!
+Update the test output.
+comm: collect 0, garbage 0
+inva: collect 0, garbage 0
+dirs: collect 0, garbage 0
+repo: collect 0, garbage 0
+  mq
+comm: collect 0, garbage 0
+inva: collect 0, garbage 0
+dirs: collect 0, garbage 0
+repo: collect 21, garbage 0
+  inotify
+comm: collect 5, garbage 0
+inva: collect 0, garbage 0
+dirs: collect 10, garbage 0
+repo: collect 21, garbage 0
+  keyword
+comm: collect 0, garbage 0
+inva: collect 0, garbage 0
+dirs: collect 11, garbage 0
+repo: collect 21, garbage 0
+  parentrevspec
+comm: collect 0, garbage 0
+inva: collect 0, garbage 0
+dirs: collect 11, garbage 0
+repo: collect 28, garbage 0
+
+ui: collect 0, garbage 0


More information about the Mercurial-devel mailing list