Add unit tests for Node methods that have been recently added.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 28 Sep 2001 20:17:52 +0000 (20:17 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 28 Sep 2001 20:17:52 +0000 (20:17 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@71 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/FSTests.py
src/engine/SCons/Node/NodeTests.py

index 94ec5b0bec39966c99bbd287368c4973433ba90e..8e7e2a6f84237f054e7f03edb78eb3009b1d615a 100644 (file)
@@ -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
 
index 7e5afb0335766bc07d604fec88a712074b477f20..738c7ccd741b259bfd721596686617c547775a27 100644 (file)
@@ -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__":