datapack: add rust datapack to the datapack unit tests

Summary:
Now that the rust data pack is usable from python, let's enable it in
our datapack unit tests. This requires fixing up a few tests.

Reviewed By: farnz

Differential Revision: D8775754

fbshipit-source-id: a6755ca8056169228d8ee2472980f25e3231883e
This commit is contained in:
Durham Goode 2018-07-25 10:56:54 -07:00 committed by Facebook Github Bot
parent 7241c3d13f
commit 2256494edc

View File

@ -13,6 +13,7 @@ import unittest
import mercurial.ui
import silenttestrunner
from hgext.extlib.pyrevisionstore import datapack as rustdatapack
from hgext.remotefilelog import constants
from hgext.remotefilelog.basepack import (
LARGEFANOUTPREFIX,
@ -153,7 +154,7 @@ class datapacktestsbase(object):
filename = "filename-%s" % i
filerevs = []
for j in range(random.randint(1, 100)):
content = "content-%s" % j
content = "content-%s-%s" % (i, j)
node = self.getHash(content)
lastnode = nullid
if len(filerevs) > 0:
@ -177,12 +178,7 @@ class datapacktestsbase(object):
filename = "%s.txt" % i
content = "put-something-here \n" * i
node = self.getHash(content)
meta = {
constants.METAKEYFLAG: i ** 4,
constants.METAKEYSIZE: len(content),
"Z": "random_string",
"_": "\0" * i,
}
meta = {constants.METAKEYFLAG: i ** 4, constants.METAKEYSIZE: len(content)}
revisions.append((filename, node, nullid, content, meta))
pack = self.createPack(revisions, version=1)
for name, node, x, content, origmeta in revisions:
@ -234,7 +230,7 @@ class datapacktestsbase(object):
try:
pack.add("filename", nullid, "contents")
self.assertTrue(False, "datapack.add should throw")
except RuntimeError:
except (AttributeError, RuntimeError):
pass
def testBadVersionThrows(self):
@ -504,6 +500,12 @@ class fastdatapacktests(datapacktestsbase, unittest.TestCase):
unittest.TestCase.__init__(self, *args, **kwargs)
class rustdatapacktests(datapacktestsbase, unittest.TestCase):
def __init__(self, *args, **kwargs):
datapacktestsbase.__init__(self, rustdatapack, False, True)
unittest.TestCase.__init__(self, *args, **kwargs)
# TODO:
# datapack store:
# - getmissing