[PATCH 5 of 7 V4] revlog: add test case for _findsnapshots
Boris Feld
boris.feld at octobus.net
Sun Dec 30 13:43:52 EST 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1545366450 -3600
# Fri Dec 21 05:27:30 2018 +0100
# Node ID 5aff42c50dd1bc1e7c2e533a8e052fa42c6f9304
# Parent 1730cc2b1fdae573dd58cb2def13c65fcbbd6162
# EXP-Topic sparse-revlog
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 5aff42c50dd1
revlog: add test case for _findsnapshots
Testing the method directly is more robust.
diff --git a/tests/test-revlog-raw.py b/tests/test-revlog-raw.py
--- a/tests/test-revlog-raw.py
+++ b/tests/test-revlog-raw.py
@@ -2,6 +2,7 @@
from __future__ import absolute_import, print_function
+import collections
import hashlib
import sys
@@ -397,6 +398,24 @@ def issnapshottest(rlog):
print(' expected: %s' % snapshots)
print(' got: %s' % result)
+snapshotmapall = {0: [6, 8, 11, 17, 19, 25], 8: [21], -1: [0, 30]}
+snapshotmap15 = {0: [17, 19, 25], 8: [21], -1: [30]}
+def findsnapshottest(rlog):
+ resultall = collections.defaultdict(list)
+ deltas._findsnapshots(rlog, resultall, 0)
+ resultall = dict(resultall.items())
+ if resultall != snapshotmapall:
+ print('snapshot map differ:')
+ print(' expected: %s' % snapshotmapall)
+ print(' got: %s' % resultall)
+ result15 = collections.defaultdict(list)
+ deltas._findsnapshots(rlog, result15, 15)
+ result15 = dict(result15.items())
+ if result15 != snapshotmap15:
+ print('snapshot map differ:')
+ print(' expected: %s' % snapshotmap15)
+ print(' got: %s' % result15)
+
def maintest():
expected = rl = None
with newtransaction() as tr:
@@ -424,6 +443,8 @@ def maintest():
rl5 = makesnapshot(tr)
issnapshottest(rl5)
print('issnapshot test passed')
+ findsnapshottest(rl5)
+ print('findsnapshot test passed')
try:
maintest()
diff --git a/tests/test-revlog-raw.py.out b/tests/test-revlog-raw.py.out
--- a/tests/test-revlog-raw.py.out
+++ b/tests/test-revlog-raw.py.out
@@ -4,3 +4,4 @@ clone test passed
lowlevelcopy test passed
slicing test passed
issnapshot test passed
+findsnapshot test passed
More information about the Mercurial-devel
mailing list