diff options
author | Steven Knight <knight@baldmt.com> | 2003-04-12 10:52:50 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-04-12 10:52:50 (GMT) |
commit | 5e229b4f577acd2a89196c74196997d2a6f017cc (patch) | |
tree | faf99f3ad74bbc39c45e4897f94318afea0a11a8 | |
parent | 864888601110b99b76ed83958bc370b12d3656ad (diff) | |
download | SCons-5e229b4f577acd2a89196c74196997d2a6f017cc.zip SCons-5e229b4f577acd2a89196c74196997d2a6f017cc.tar.gz SCons-5e229b4f577acd2a89196c74196997d2a6f017cc.tar.bz2 |
Add a clear() method to reset a Node's state for re-processing.
-rw-r--r-- | src/CHANGES.txt | 4 | ||||
-rw-r--r-- | src/engine/SCons/Node/FS.py | 15 | ||||
-rw-r--r-- | src/engine/SCons/Node/FSTests.py | 26 | ||||
-rw-r--r-- | src/engine/SCons/Node/NodeTests.py | 20 | ||||
-rw-r--r-- | src/engine/SCons/Node/__init__.py | 12 |
5 files changed, 77 insertions, 0 deletions
diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 83c5613..b35be68 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -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 diff --git a/src/engine/SCons/Node/FS.py b/src/engine/SCons/Node/FS.py index f380f7e..a2d9414 100644 --- a/src/engine/SCons/Node/FS.py +++ b/src/engine/SCons/Node/FS.py @@ -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 diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index 7836a13..b932896 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -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) diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index 9da74d3..45c4af9 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -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_') diff --git a/src/engine/SCons/Node/__init__.py b/src/engine/SCons/Node/__init__.py index c458026..1c23684 100644 --- a/src/engine/SCons/Node/__init__.py +++ b/src/engine/SCons/Node/__init__.py @@ -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..""" |