diff options
| author | Steven Knight <knight@baldmt.com> | 2004-01-04 14:36:40 (GMT) |
|---|---|---|
| committer | Steven Knight <knight@baldmt.com> | 2004-01-04 14:36:40 (GMT) |
| commit | ffa68a9db1f04d9efedab845c1c744bc9c7e785b (patch) | |
| tree | 80a5a0a882566123f73db2719df959eceb063d60 /src/engine/SCons/Node | |
| parent | 21bcea81ee5091735a41d7bfac8d5398dc8bf97f (diff) | |
| download | SCons-ffa68a9db1f04d9efedab845c1c744bc9c7e785b.zip SCons-ffa68a9db1f04d9efedab845c1c744bc9c7e785b.tar.gz SCons-ffa68a9db1f04d9efedab845c1c744bc9c7e785b.tar.bz2 | |
Miscellaneous changes: update a call to env.subst(); white space cleanup in EnvironmentTests.py and Node/NodeTests.py; more informative failure reporting in Node/FSTests.py; remove the now-unused SCons.Node.arg2nodes() function.
Diffstat (limited to 'src/engine/SCons/Node')
| -rw-r--r-- | src/engine/SCons/Node/FSTests.py | 18 | ||||
| -rw-r--r-- | src/engine/SCons/Node/NodeTests.py | 130 | ||||
| -rw-r--r-- | src/engine/SCons/Node/__init__.py | 38 |
3 files changed, 15 insertions, 171 deletions
diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index fcd605b..739d4e9 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -1708,36 +1708,36 @@ class SpecialAttrTestCase(unittest.TestCase): f=fs.Entry('foo/bar/baz.blat').get_subst_proxy() assert str(f.dir) == os.path.normpath('foo/bar'), str(f.dir) - assert f.dir.is_literal() + assert f.dir.is_literal(), f.dir assert f.dir.for_signature() == 'bar', f.dir.for_signature() assert str(f.file) == 'baz.blat', str(f.file) - assert f.file.is_literal() + assert f.file.is_literal(), f.file assert f.file.for_signature() == 'baz.blat_file', \ f.file.for_signature() assert str(f.base) == os.path.normpath('foo/bar/baz'), str(f.base) - assert f.base.is_literal() + assert f.base.is_literal(), f.base assert f.base.for_signature() == 'baz.blat_base', \ f.base.for_signature() assert str(f.filebase) == 'baz', str(f.filebase) - assert f.filebase.is_literal() + assert f.filebase.is_literal(), f.filebase assert f.filebase.for_signature() == 'baz.blat_filebase', \ f.filebase.for_signature() assert str(f.suffix) == '.blat', str(f.suffix) - assert f.suffix.is_literal() + assert f.suffix.is_literal(), f.suffix assert f.suffix.for_signature() == 'baz.blat_suffix', \ f.suffix.for_signature() assert str(f.abspath) == test.workpath('foo', 'bar', 'baz.blat'), str(f.abspath) - assert f.abspath.is_literal() + assert f.abspath.is_literal(), f.abspath assert f.abspath.for_signature() == 'baz.blat_abspath', \ f.abspath.for_signature() assert str(f.posix) == 'foo/bar/baz.blat', str(f.posix) - assert f.posix.is_literal() + assert f.posix.is_literal(), f.posix if f.posix != f: assert f.posix.for_signature() == 'baz.blat_posix', \ f.posix.for_signature() @@ -1771,11 +1771,11 @@ class SpecialAttrTestCase(unittest.TestCase): fs.BuildDir('foo', 'baz') assert str(f.srcpath) == os.path.normpath('baz/bar/baz.blat'), str(f.srcpath) - assert f.srcpath.is_literal() + assert f.srcpath.is_literal(), f.srcpath assert isinstance(f.srcpath.get(), SCons.Node.FS.Entry) assert str(f.srcdir) == os.path.normpath('baz/bar'), str(f.srcdir) - assert f.srcdir.is_literal() + assert f.srcdir.is_literal(), f.srcdir assert isinstance(f.srcdir.get(), SCons.Node.FS.Dir) # And now, combinations!!! diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index f4d4845..fa0b6f7 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -42,7 +42,7 @@ built_order = 0 class MyAction: def __init__(self): self.order = 0 - + def __call__(self, target, source, env): global built_it, built_target, built_source, built_args, built_order built_it = 1 @@ -260,7 +260,7 @@ class NodeTestCase(unittest.TestCase): """ n = SCons.Node.Node() n.visited() - + def test_depends_on(self): """Test the depends_on() method """ @@ -268,7 +268,7 @@ class NodeTestCase(unittest.TestCase): child = SCons.Node.Node() parent.add_dependency([child]) assert parent.depends_on([child]) - + def test_builder_set(self): """Test setting a Node's Builder """ @@ -455,7 +455,7 @@ class NodeTestCase(unittest.TestCase): n4 = MyNode() node.implicit = [] node.implicit_dict = {} - node._add_child(node.implicit, node.implicit_dict, [n4]) + node._add_child(node.implicit, node.implicit_dict, [n4]) exc_caught = 0 try: node.prepare() @@ -836,134 +836,16 @@ class NodeTestCase(unittest.TestCase): def for_signature(self): return self.sig - + n = TestNode("foo", "bar") assert n.get_string(0) == "foo", n.get_string(0) assert n.get_string(1) == "bar", n.get_string(1) - def test_arg2nodes(self): - """Test the arg2nodes function.""" - dict = {} - class X(SCons.Node.Node): - pass - def Factory(name, directory = None, create = 1, dict=dict, X=X): - if not dict.has_key(name): - dict[name] = X() - dict[name].name = name - return dict[name] - - nodes = SCons.Node.arg2nodes("Util.py UtilTests.py", Factory) - assert len(nodes) == 1, nodes - assert isinstance(nodes[0], X) - assert nodes[0].name == "Util.py UtilTests.py" - - if hasattr(types, 'UnicodeType'): - code = """if 1: - nodes = SCons.Node.arg2nodes(u"Util.py UtilTests.py", Factory) - assert len(nodes) == 1, nodes - assert isinstance(nodes[0], X) - assert nodes[0].name == u"Util.py UtilTests.py" - \n""" - exec code in globals(), locals() - - nodes = SCons.Node.arg2nodes(["Util.py", "UtilTests.py"], Factory) - assert len(nodes) == 2, nodes - assert isinstance(nodes[0], X) - assert isinstance(nodes[1], X) - assert nodes[0].name == "Util.py" - assert nodes[1].name == "UtilTests.py" - - n1 = Factory("Util.py") - nodes = SCons.Node.arg2nodes([n1, "UtilTests.py"], Factory) - assert len(nodes) == 2, nodes - assert isinstance(nodes[0], X) - assert isinstance(nodes[1], X) - assert nodes[0].name == "Util.py" - assert nodes[1].name == "UtilTests.py" - - class SConsNode(SCons.Node.Node): - pass - nodes = SCons.Node.arg2nodes(SConsNode()) - assert len(nodes) == 1, nodes - assert isinstance(nodes[0], SConsNode), node - - class OtherNode: - pass - nodes = SCons.Node.arg2nodes(OtherNode()) - assert len(nodes) == 1, nodes - assert isinstance(nodes[0], OtherNode), node - - def lookup_a(str, F=Factory): - if str[0] == 'a': - n = F(str) - n.a = 1 - return n - else: - return None - - def lookup_b(str, F=Factory): - if str[0] == 'b': - n = F(str) - n.b = 1 - return n - else: - return None - - SCons.Node.arg2nodes_lookups.append(lookup_a) - SCons.Node.arg2nodes_lookups.append(lookup_b) - - nodes = SCons.Node.arg2nodes(['aaa', 'bbb', 'ccc'], Factory) - assert len(nodes) == 3, nodes - - assert nodes[0].name == 'aaa', nodes[0] - assert nodes[0].a == 1, nodes[0] - assert not hasattr(nodes[0], 'b'), nodes[0] - - assert nodes[1].name == 'bbb' - assert not hasattr(nodes[1], 'a'), nodes[1] - assert nodes[1].b == 1, nodes[1] - - assert nodes[2].name == 'ccc' - assert not hasattr(nodes[2], 'a'), nodes[1] - assert not hasattr(nodes[2], 'b'), nodes[1] - - def lookup_bbbb(str, F=Factory): - if str == 'bbbb': - n = F(str) - n.bbbb = 1 - return n - else: - return None - - def lookup_c(str, F=Factory): - if str[0] == 'c': - n = F(str) - n.c = 1 - return n - else: - return None - - nodes = SCons.Node.arg2nodes(['bbbb', 'ccc'], Factory, - [lookup_c, lookup_bbbb, lookup_b]) - assert len(nodes) == 2, nodes - - assert nodes[0].name == 'bbbb' - assert not hasattr(nodes[0], 'a'), nodes[1] - assert not hasattr(nodes[0], 'b'), nodes[1] - assert nodes[0].bbbb == 1, nodes[1] - assert not hasattr(nodes[0], 'c'), nodes[0] - - assert nodes[1].name == 'ccc' - assert not hasattr(nodes[1], 'a'), nodes[1] - assert not hasattr(nodes[1], 'b'), nodes[1] - assert not hasattr(nodes[1], 'bbbb'), nodes[0] - assert nodes[1].c == 1, nodes[1] - def test_literal(self): """Test the is_literal() function.""" n=SCons.Node.Node() assert n.is_literal() - + def test_Annotate(self): """Test using an interface-specific Annotate function.""" def my_annotate(node, self=self): diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index 1eb7f29..51bfe30 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -825,41 +825,3 @@ class Walker: arg2nodes_lookups = [] - -def arg2nodes(args, node_factory=None, lookup_list=arg2nodes_lookups): - """This function converts a string or list into a list of Node - instances. It accepts the following inputs: - - A single string, - - A single Node instance, - - A list containing either strings or Node instances. - In all cases, strings are converted to Node instances, and the - function returns a list of Node instances.""" - - if not args: - return [] - if not SCons.Util.is_List(args): - args = [args] - - nodes = [] - for v in args: - if SCons.Util.is_String(v): - n = None - for l in lookup_list: - n = l(v) - if not n is None: - break - if not n is None: - if SCons.Util.is_String(n) and node_factory: - n = node_factory(n) - nodes.append(n) - elif node_factory: - nodes.append(node_factory(v)) - # Do we enforce the following restriction? Maybe, but it - # would also restrict what we can do to allow people to - # use the engine with alternate Node implementations... - #elif not issubclass(v.__class__, Node): - # raise TypeError - else: - nodes.append(v) - - return nodes |
