Add a clear() method to reset a Node's state for re-processing.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 12 Apr 2003 10:52:50 +0000 (10:52 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Sat, 12 Apr 2003 10:52:50 +0000 (10:52 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@641 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Node/FS.py
src/engine/SCons/Node/FSTests.py
src/engine/SCons/Node/NodeTests.py
src/engine/SCons/Node/__init__.py

index 83c5613d1d1bfa351f4bbe10bf50612077f319ca..b35be688464f99cff63c66e49b6f114672390e4d 100644 (file)
@@ -38,6 +38,10 @@ RELEASE 0.14 - XXX
   - Check out CVS source files using POSIX path names (forward slashes
     as separators) even on Win32.
 
+  - Add Node.clear() and Node.FS.Entry.clear() methods to wipe out a
+    Node's state, allowing it to be re-evaluated by continuous
+    integration build interfaces.
+
 
 
 RELEASE 0.13 - Mon, 31 Mar 2003 20:22:00 -0600
index f380f7eed523656fd232001f8a7be7f8031d06de..a2d9414434f8b4732ad3202fcff81f2bf6604da4 100644 (file)
@@ -263,6 +263,21 @@ class Entry(SCons.Node.Node):
         self.cwd = None # will hold the SConscript directory for target nodes
         self.duplicate = directory.duplicate
 
+    def clear(self):
+        """Completely clear an Entry of all its cached state (so that it
+        can be re-evaluated by interfaces that do continuous integration
+        builds).
+        """
+        SCons.Node.Node.clear(self)
+        try:
+            delattr(self, '_exists')
+        except AttributeError:
+            pass
+        try:
+            delattr(self, '_rexists')
+        except AttributeError:
+            pass
+
     def get_dir(self):
         return self.dir
 
index 7836a1337d10726379ce0b65c419d66dfad1cc45..b9328968c177441db6d5efda4a8224d857fdd96d 100644 (file)
@@ -1461,6 +1461,31 @@ class CacheDirTestCase(unittest.TestCase):
             SCons.Warnings.warningAsException(old_warn_exceptions)
             SCons.Warnings.suppressWarningClass(SCons.Warnings.CacheWriteErrorWarning)
 
+class clearTestCase(unittest.TestCase):
+    def runTest(self):
+        fs = SCons.Node.FS.FS()
+
+        e = fs.Entry('e')
+        e._exists = 1
+        e._rexists = 1
+        e.clear()
+        assert not hasattr(e, '_exists')
+        assert not hasattr(e, '_rexists')
+
+        d = fs.Dir('d')
+        d._exists = 1
+        d._rexists = 1
+        d.clear()
+        assert not hasattr(d, '_exists')
+        assert not hasattr(d, '_rexists')
+
+        f = fs.File('f')
+        f._exists = 1
+        f._rexists = 1
+        f.clear()
+        assert not hasattr(f, '_exists')
+        assert not hasattr(f, '_rexists')
+
 
 
 if __name__ == "__main__":
@@ -1475,5 +1500,6 @@ if __name__ == "__main__":
     suite.addTest(get_actionsTestCase())
     suite.addTest(SConstruct_dirTestCase())
     suite.addTest(CacheDirTestCase())
+    suite.addTest(clearTestCase())
     if not unittest.TextTestRunner().run(suite).wasSuccessful():
         sys.exit(1)
index 9da74d3d1dcc129a877083e379a3997fda08be4a..45c4af9b190c7da6d081184543eb25dbcd3d565f 100644 (file)
@@ -889,6 +889,26 @@ class NodeTestCase(unittest.TestCase):
         finally:
             SCons.Node.Annotate = save_Annotate
 
+    def test_clear(self):
+        """Test clearing all cached state information."""
+        n = SCons.Node.Node()
+
+        n.set_state(3)
+        n.set_bsig('bsig')
+        n.set_csig('csig')
+        n.includes = 'testincludes'
+        n.found_include = {'testkey':'testvalue'}
+        n.implicit = 'testimplicit'
+
+        n.clear()
+
+        assert n.get_state() is None, n.get_state()
+        assert not hasattr(n, 'bsig'), n.bsig
+        assert not hasattr(n, 'csig'), n.csig
+        assert n.includes is None, n.includes
+        assert n.found_includes == {}, n.found_includes
+        assert n.implicit is None, n.implicit
+
 
 if __name__ == "__main__":
     suite = unittest.makeSuite(NodeTestCase, 'test_')
index c4580263d1d2900c209c63ba6898851b9f900329..1c236848004e21c8dfef9aba2ce0889856f24c95 100644 (file)
@@ -193,6 +193,18 @@ class Node:
         # node were presumably just changed:
         self.del_csig()
 
+    def clear(self):
+        """Completely clear a Node of all its cached state (so that it
+        can be re-evaluated by interfaces that do continuous integration
+        builds).
+        """
+        self.set_state(None)
+        self.del_bsig()
+        self.del_csig()
+        self.includes = None
+        self.found_includes = {}
+        self.implicit = None
+
     def visited(self):
         """Called just after this node has been visited
         without requiring a build.."""