From a7e7c22cc9ba27e731e9b8c5c0c7c6f3607f3869 Mon Sep 17 00:00:00 2001 From: stevenknight Date: Fri, 28 Sep 2001 20:17:52 +0000 Subject: [PATCH] Add unit tests for Node methods that have been recently added. git-svn-id: http://scons.tigris.org/svn/scons/trunk@71 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Node/FSTests.py | 8 +++- src/engine/SCons/Node/NodeTests.py | 65 +++++++++++++++++++++++++++++- 2 files changed, 71 insertions(+), 2 deletions(-) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 94ec5b0b..8e7e2a6f 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -9,10 +9,14 @@ import SCons.Node.FS built_it = None class Builder: - def execute(self, target = None, source = None): + def execute(self, **kw): global built_it built_it = 1 +class Environment: + def Dictionary(self, *args): + pass + class FSTestCase(unittest.TestCase): def runTest(self): """Test FS (file system) Node operations @@ -94,6 +98,7 @@ class FSTestCase(unittest.TestCase): d1.path = "d" # XXX FAKE SUBCLASS ATTRIBUTE d1.add_source(["d"]) # XXX FAKE SUBCLASS ATTRIBUTE d1.builder_set(Builder()) + d1.env_set(Environment()) d1.build() assert built_it @@ -102,6 +107,7 @@ class FSTestCase(unittest.TestCase): f1.path = "f" # XXX FAKE SUBCLASS ATTRIBUTE f1.add_source(["f"]) # XXX FAKE SUBCLASS ATTRIBUTE f1.builder_set(Builder()) + f1.env_set(Environment()) f1.build() assert built_it diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 7e5afb03..738c7ccd 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -11,10 +11,14 @@ import SCons.Node built_it = None class Builder: - def execute(self, target = None, source = None): + def execute(self, **kw): global built_it built_it = 1 +class Environment: + def Dictionary(self, *args): + pass + class NodeTestCase(unittest.TestCase): @@ -24,6 +28,7 @@ class NodeTestCase(unittest.TestCase): """ node = SCons.Node.Node() node.builder_set(Builder()) + node.env_set(Environment()) node.path = "xxx" # XXX FAKE SUBCLASS ATTRIBUTE node.sources = "yyy" # XXX FAKE SUBCLASS ATTRIBUTE node.build() @@ -37,6 +42,64 @@ class NodeTestCase(unittest.TestCase): node.builder_set(b) assert node.builder == b + def test_env_set(self): + """Test setting a Node's Environment + """ + node = SCons.Node.Node() + e = Environment() + node.env_set(e) + assert node.env == e + + def test_has_signature(self): + """Test whether or not a node has a signature + """ + node = SCons.Node.Node() + assert not node.has_signature() + node.set_signature('xxx') + assert node.has_signature() + + def test_set_signature(self): + """Test setting a Node's signature + """ + node = SCons.Node.Node() + node.set_signature('yyy') + assert node.signature == 'yyy' + + def test_get_signature(self): + """Test fetching a Node's signature + """ + node = SCons.Node.Node() + node.set_signature('zzz') + assert node.get_signature() == 'zzz' + + def test_add_dependency(self): + """Test adding dependencies to a Node's list. + """ + node = SCons.Node.Node() + assert node.depends == [] + try: + node.add_dependency('zero') + except TypeError: + pass + node.add_dependency(['one']) + assert node.depends == ['one'] + node.add_dependency(['two', 'three']) + assert node.depends == ['one', 'two', 'three'] + + def test_add_source(self): + """Test adding sources to a Node's list. + """ + node = SCons.Node.Node() + assert node.sources == [] + try: + node.add_source('zero') + except TypeError: + pass + node.add_source(['one']) + assert node.sources == ['one'] + node.add_source(['two', 'three']) + assert node.sources == ['one', 'two', 'three'] + if __name__ == "__main__": -- 2.26.2