def test_merge(self): l1 = HierarchicalStringList() l1 += ['root1', 'root2', 'root3'] l1.child1 += ['child11', 'child12', 'child13'] l1.child1.grandchild1 += ['grandchild111', 'grandchild112'] l1.child1.grandchild2 += ['grandchild121', 'grandchild122'] l1.child2.grandchild1 += ['grandchild211', 'grandchild212'] l1.child2.grandchild1 += ['grandchild213', 'grandchild214'] l2 = HierarchicalStringList() l2.child1 += ['child14', 'child15'] l2.child1.grandchild2 += ['grandchild123'] l2.child3 += ['child31', 'child32'] l1 += l2 els = list((path, list(seq)) for path, seq in l1.walk()) self.assertEqual(els, [ ('', ['root1', 'root2', 'root3']), ('child1', ['child11', 'child12', 'child13', 'child14', 'child15']), ('child1/grandchild1', ['grandchild111', 'grandchild112']), ('child1/grandchild2', ['grandchild121', 'grandchild122', 'grandchild123']), ('child2/grandchild1', ['grandchild211', 'grandchild212', 'grandchild213', 'grandchild214']), ('child3', ['child31', 'child32']), ])
def test_walk(self): l = HierarchicalStringList() l += ["root1", "root2", "root3"] l.child1 += ["child11", "child12", "child13"] l.child1.grandchild1 += ["grandchild111", "grandchild112"] l.child1.grandchild2 += ["grandchild121", "grandchild122"] l.child2.grandchild1 += ["grandchild211", "grandchild212"] l.child2.grandchild1 += ["grandchild213", "grandchild214"] els = list((path, list(seq)) for path, seq in l.walk()) self.assertEqual( els, [ ("", ["root1", "root2", "root3"]), ("child1", ["child11", "child12", "child13"]), ("child1/grandchild1", ["grandchild111", "grandchild112"]), ("child1/grandchild2", ["grandchild121", "grandchild122"]), ( "child2/grandchild1", [ "grandchild211", "grandchild212", "grandchild213", "grandchild214", ], ), ], )
def test_merge(self): l1 = HierarchicalStringList() l1 += ['root1', 'root2', 'root3'] l1.child1 += ['child11', 'child12', 'child13'] l1.child1.grandchild1 += ['grandchild111', 'grandchild112'] l1.child1.grandchild2 += ['grandchild121', 'grandchild122'] l1.child2.grandchild1 += ['grandchild211', 'grandchild212'] l1.child2.grandchild1 += ['grandchild213', 'grandchild214'] l2 = HierarchicalStringList() l2.child1 += ['child14', 'child15'] l2.child1.grandchild2 += ['grandchild123'] l2.child3 += ['child31', 'child32'] l1 += l2 els = list((path, list(seq)) for path, seq in l1.walk()) self.assertEqual(els, [ ('', ['root1', 'root2', 'root3']), ('child1', ['child11', 'child12', 'child13', 'child14', 'child15' ]), ('child1/grandchild1', ['grandchild111', 'grandchild112']), ('child1/grandchild2', ['grandchild121', 'grandchild122', 'grandchild123']), ('child2/grandchild1', [ 'grandchild211', 'grandchild212', 'grandchild213', 'grandchild214' ]), ('child3', ['child31', 'child32']), ])
def test_merge(self): l1 = HierarchicalStringList() l1 += ["root1", "root2", "root3"] l1.child1 += ["child11", "child12", "child13"] l1.child1.grandchild1 += ["grandchild111", "grandchild112"] l1.child1.grandchild2 += ["grandchild121", "grandchild122"] l1.child2.grandchild1 += ["grandchild211", "grandchild212"] l1.child2.grandchild1 += ["grandchild213", "grandchild214"] l2 = HierarchicalStringList() l2.child1 += ["child14", "child15"] l2.child1.grandchild2 += ["grandchild123"] l2.child3 += ["child31", "child32"] l1 += l2 els = list((path, list(seq)) for path, seq in l1.walk()) self.assertEqual( els, [ ("", ["root1", "root2", "root3"]), ("child1", ["child11", "child12", "child13", "child14", "child15"]), ("child1/grandchild1", ["grandchild111", "grandchild112"]), ("child1/grandchild2", ["grandchild121", "grandchild122", "grandchild123"]), ("child2/grandchild1", ["grandchild211", "grandchild212", "grandchild213", "grandchild214"]), ("child3", ["child31", "child32"]), ], )
def test_walk(self): l = HierarchicalStringList() l += ['root1', 'root2', 'root3'] l.child1 += ['child11', 'child12', 'child13'] l.child1.grandchild1 += ['grandchild111', 'grandchild112'] l.child1.grandchild2 += ['grandchild121', 'grandchild122'] l.child2.grandchild1 += ['grandchild211', 'grandchild212'] l.child2.grandchild1 += ['grandchild213', 'grandchild214'] els = list((path, list(seq)) for path, seq in l.walk()) self.assertEqual(els, [ ('', ['root1', 'root2', 'root3']), ('child1', ['child11', 'child12', 'child13']), ('child1/grandchild1', ['grandchild111', 'grandchild112']), ('child1/grandchild2', ['grandchild121', 'grandchild122']), ('child2/grandchild1', ['grandchild211', 'grandchild212', 'grandchild213', 'grandchild214']), ])
def test_walk(self): l = HierarchicalStringList() l += ["root1", "root2", "root3"] l.child1 += ["child11", "child12", "child13"] l.child1.grandchild1 += ["grandchild111", "grandchild112"] l.child1.grandchild2 += ["grandchild121", "grandchild122"] l.child2.grandchild1 += ["grandchild211", "grandchild212"] l.child2.grandchild1 += ["grandchild213", "grandchild214"] els = list((path, list(seq)) for path, seq in l.walk()) self.assertEqual( els, [ ("", ["root1", "root2", "root3"]), ("child1", ["child11", "child12", "child13"]), ("child1/grandchild1", ["grandchild111", "grandchild112"]), ("child1/grandchild2", ["grandchild121", "grandchild122"]), ("child2/grandchild1", ["grandchild211", "grandchild212", "grandchild213", "grandchild214"]), ], )
def test_merge(self): l1 = HierarchicalStringList() l1 += ["root1", "root2", "root3"] l1.child1 += ["child11", "child12", "child13"] l1.child1.grandchild1 += ["grandchild111", "grandchild112"] l1.child1.grandchild2 += ["grandchild121", "grandchild122"] l1.child2.grandchild1 += ["grandchild211", "grandchild212"] l1.child2.grandchild1 += ["grandchild213", "grandchild214"] l2 = HierarchicalStringList() l2.child1 += ["child14", "child15"] l2.child1.grandchild2 += ["grandchild123"] l2.child3 += ["child31", "child32"] l1 += l2 els = list((path, list(seq)) for path, seq in l1.walk()) self.assertEqual( els, [ ("", ["root1", "root2", "root3"]), ("child1", ["child11", "child12", "child13", "child14", "child15"]), ("child1/grandchild1", ["grandchild111", "grandchild112"]), ( "child1/grandchild2", ["grandchild121", "grandchild122", "grandchild123"], ), ( "child2/grandchild1", [ "grandchild211", "grandchild212", "grandchild213", "grandchild214", ], ), ("child3", ["child31", "child32"]), ], )
This is a substitute for AC_OUTPUT in autoconf. For each path in this list, we will search for a file in the srcdir having the name {path}.in. The contents of this file will be read and variable patterns like @foo@ will be substituted with the values of the AC_SUBST variables declared during configure. """), 'MODULE': (unicode, "", """Module name. Historically, this variable was used to describe where to install header files, but that feature is now handled by EXPORTS_NAMESPACES. Currently it is used as the XPIDL module name if XPIDL_MODULE is not defined, but using XPIDL_MODULE directly is preferred. MODULE will likely be removed in the future. """), 'EXPORTS': (HierarchicalStringList, HierarchicalStringList(), """List of files to be exported, and in which subdirectories. EXPORTS is generally used to list the include files to be exported to dist/include, but it can be used for other files as well. This variable behaves as a list when appending filenames for export in the top-level directory. Files can also be appended to a field to indicate which subdirectory they should be exported to. For example, to export 'foo.h' to the top-level directory, and 'bar.h' to mozilla/dom/, append to EXPORTS like so: EXPORTS += ['foo.h'] EXPORTS.mozilla.dom += ['bar.h'] """), # IDL Generation.
def setUp(self): self.EXPORTS = HierarchicalStringList()
class TestHierarchicalStringList(unittest.TestCase): def setUp(self): self.EXPORTS = HierarchicalStringList() def test_exports_append(self): self.assertEqual(self.EXPORTS.get_strings(), []) self.EXPORTS += ["foo.h"] self.assertEqual(self.EXPORTS.get_strings(), ["foo.h"]) self.EXPORTS += ["bar.h"] self.assertEqual(self.EXPORTS.get_strings(), ["foo.h", "bar.h"]) def test_exports_subdir(self): self.assertEqual(self.EXPORTS.get_children(), {}) self.EXPORTS.foo += ["foo.h"] self.assertItemsEqual(self.EXPORTS.get_children(), {"foo" : True}) self.assertEqual(self.EXPORTS.foo.get_strings(), ["foo.h"]) self.EXPORTS.bar += ["bar.h"] self.assertItemsEqual(self.EXPORTS.get_children(), {"foo" : True, "bar" : True}) self.assertEqual(self.EXPORTS.foo.get_strings(), ["foo.h"]) self.assertEqual(self.EXPORTS.bar.get_strings(), ["bar.h"]) def test_exports_multiple_subdir(self): self.EXPORTS.foo.bar = ["foobar.h"] self.assertItemsEqual(self.EXPORTS.get_children(), {"foo" : True}) self.assertItemsEqual(self.EXPORTS.foo.get_children(), {"bar" : True}) self.assertItemsEqual(self.EXPORTS.foo.bar.get_children(), {}) self.assertEqual(self.EXPORTS.get_strings(), []) self.assertEqual(self.EXPORTS.foo.get_strings(), []) self.assertEqual(self.EXPORTS.foo.bar.get_strings(), ["foobar.h"]) def test_invalid_exports_append(self): with self.assertRaises(ValueError) as ve: self.EXPORTS += "foo.h" self.assertEqual(str(ve.exception), "Expected a list of strings, not <type '%s'>" % str_type) def test_invalid_exports_set(self): with self.assertRaises(ValueError) as ve: self.EXPORTS.foo = "foo.h" self.assertEqual(str(ve.exception), "Expected a list of strings, not <type '%s'>" % str_type) def test_invalid_exports_append_base(self): with self.assertRaises(ValueError) as ve: self.EXPORTS += "foo.h" self.assertEqual(str(ve.exception), "Expected a list of strings, not <type '%s'>" % str_type) def test_invalid_exports_bool(self): with self.assertRaises(ValueError) as ve: self.EXPORTS += [True] self.assertEqual(str(ve.exception), "Expected a list of strings, not an element of " "<type 'bool'>") def test_del_exports(self): with self.assertRaises(MozbuildDeletionError) as mde: self.EXPORTS.foo += ['bar.h'] del self.EXPORTS.foo