зеркало из https://github.com/mozilla/pjs.git
bug 654448 - don't call Typelib._sanitycheck after every merge in xpt_link. r=glandium
This commit is contained in:
Родитель
22a8516584
Коммит
056de14098
|
@ -32,6 +32,7 @@
|
|||
|
||||
import difflib
|
||||
import os
|
||||
import shutil
|
||||
from StringIO import StringIO
|
||||
import subprocess
|
||||
import sys
|
||||
|
@ -746,5 +747,65 @@ class TestTypelibMerge(unittest.TestCase):
|
|||
self.assertEqual(t1.interfaces[1],
|
||||
t1.interfaces[0].methods[0].params[0].type.element_type.iface)
|
||||
|
||||
class TestXPTLink(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tempdir = tempfile.mkdtemp()
|
||||
|
||||
def tearDown(self):
|
||||
shutil.rmtree(self.tempdir, True)
|
||||
|
||||
def gettempfile(self):
|
||||
fd, f = tempfile.mkstemp(dir=self.tempdir)
|
||||
os.close(fd)
|
||||
return f
|
||||
|
||||
def test_xpt_link(self):
|
||||
"""
|
||||
Test the xpt_link method.
|
||||
|
||||
"""
|
||||
t1 = xpt.Typelib()
|
||||
# add an unresolved interface
|
||||
t1.interfaces.append(xpt.Interface("IFoo"))
|
||||
f1 = self.gettempfile()
|
||||
t1.write(f1)
|
||||
|
||||
t2 = xpt.Typelib()
|
||||
# add an unresolved interface
|
||||
t2.interfaces.append(xpt.Interface("IBar"))
|
||||
f2 = self.gettempfile()
|
||||
t2.write(f2)
|
||||
|
||||
f3 = self.gettempfile()
|
||||
xpt.xpt_link(f3, [f1, f2])
|
||||
t3 = xpt.Typelib.read(f3)
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
# Interfaces should wind up sorted
|
||||
self.assertEqual("IBar", t3.interfaces[0].name)
|
||||
self.assertEqual("IFoo", t3.interfaces[1].name)
|
||||
|
||||
# Add some IID values
|
||||
t1 = xpt.Typelib()
|
||||
# add an unresolved interface
|
||||
t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff"))
|
||||
f1 = self.gettempfile()
|
||||
t1.write(f1)
|
||||
|
||||
t2 = xpt.Typelib()
|
||||
# add an unresolved interface
|
||||
t2.interfaces.append(xpt.Interface("IBar", iid="44332211-6655-8877-0099-aabbccddeeff"))
|
||||
f2 = self.gettempfile()
|
||||
t2.write(f2)
|
||||
|
||||
f3 = self.gettempfile()
|
||||
xpt.xpt_link(f3, [f1, f2])
|
||||
t3 = xpt.Typelib.read(f3)
|
||||
|
||||
self.assertEqual(2, len(t3.interfaces))
|
||||
# Interfaces should wind up sorted
|
||||
self.assertEqual("IFoo", t3.interfaces[0].name)
|
||||
self.assertEqual("IBar", t3.interfaces[1].name)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
|
@ -1155,9 +1155,11 @@ class Typelib(object):
|
|||
for i in self.interfaces:
|
||||
i.write_directory_entry(f)
|
||||
|
||||
def merge(self, other):
|
||||
def merge(self, other, sanitycheck=True):
|
||||
"""
|
||||
Merge the contents of Typelib |other| into this typelib.
|
||||
If |sanitycheck| is False, don't sort the interface table
|
||||
after merging.
|
||||
|
||||
"""
|
||||
# This will be a list of (replaced interface, replaced with)
|
||||
|
@ -1229,7 +1231,8 @@ class Typelib(object):
|
|||
checkType(m.result.type, replaced_from, replaced_to)
|
||||
for p in m.params:
|
||||
checkType(p.type, replaced_from, replaced_to)
|
||||
self._sanityCheck()
|
||||
if sanitycheck:
|
||||
self._sanityCheck()
|
||||
#TODO: do we care about annotations? probably not
|
||||
|
||||
def dump(self, out):
|
||||
|
@ -1303,7 +1306,8 @@ def xpt_link(dest, inputs):
|
|||
t1 = Typelib.read(inputs[0])
|
||||
for f in inputs[1:]:
|
||||
t2 = Typelib.read(f)
|
||||
t1.merge(t2)
|
||||
# write will call sanitycheck, so skip it here.
|
||||
t1.merge(t2, sanitycheck=False)
|
||||
t1.write(dest)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Загрузка…
Ссылка в новой задаче