Add unit tests for the last two changes.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 25 May 2004 13:24:06 +0000 (13:24 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 25 May 2004 13:24:06 +0000 (13:24 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@986 fdb21ef1-2011-0410-befe-b5e4ea1792b1

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

index f69dd4e110e8529a128bf66a101bfa6b243aab87..f537acf8ffc8b6e8d99fdfaa26d662c84304e5bc 100644 (file)
@@ -1389,6 +1389,30 @@ class StringDirTestCase(unittest.TestCase):
         assert str(f) == os.path.join('sub', 'file')
         assert not f.exists()
 
+class stored_infoTestCase(unittest.TestCase):
+    def runTest(self):
+        """Test how storing build information"""
+        test = TestCmd(workdir = '')
+        test.subdir('sub')
+        fs = SCons.Node.FS.FS(test.workpath(''))
+
+        d = fs.Dir('sub')
+        f = fs.File('file1', d)
+        bi = f.get_stored_info()
+        assert bi.bsig == None, bi.bsig
+
+        class MySConsign:
+            class Null:
+                def __init__(self):
+                    self.xyzzy = 7
+            def get_entry(self, name):
+                return self.Null()
+
+        f = fs.File('file2', d)
+        f.dir.sconsign = MySConsign
+        bi = f.get_stored_info()
+        assert bi.xyzzy == 7, bi
+
 class has_src_builderTestCase(unittest.TestCase):
     def runTest(self):
         """Test the has_src_builder() method"""
@@ -1954,6 +1978,7 @@ if __name__ == "__main__":
     suite.addTest(RepositoryTestCase())
     suite.addTest(find_fileTestCase())
     suite.addTest(StringDirTestCase())
+    suite.addTest(stored_infoTestCase())
     suite.addTest(has_src_builderTestCase())
     suite.addTest(prepareTestCase())
     suite.addTest(get_actionsTestCase())
index e36d6ce8c09bcb9218e4aa21f413fa8697c5dced..f14339e1dc37d830415ece2c9c284bfd2c404c7e 100644 (file)
@@ -414,6 +414,15 @@ class NodeTestCase(unittest.TestCase):
         result = node.explain()
         assert result == None, result
 
+        class Null_BInfo:
+            def __init__(self):
+                pass
+
+        node.get_stored_info = Null_BInfo
+        node.__str__ = lambda: 'null_binfo'
+        result = node.explain()
+        assert result == "Cannot explain why `null_binfo' is being rebuilt: No previous build information found\n", result
+
         # XXX additional tests for the guts of the functionality some day
 
     def test_del_binfo(self):
index 009addd1a0c4e76b5c6bbc28da2b18b751238761..4390a607bead9e8985e4a24a17f7fab27eccd59a 100644 (file)
@@ -194,6 +194,16 @@ def clear(nodes):
         node.csig = None
         node.bsig = None
 
+class SConsignEntryTestCase(unittest.TestCase):
+
+    def runTest(self):
+        
+        se = SCons.Sig.SConsignEntry()
+        assert hasattr(se, 'timestamp'), "no timestamp attribute"
+        assert hasattr(se, 'bsig'), "no bsig attribute"
+        assert hasattr(se, 'csig'), "no csig attribute"
+        assert hasattr(se, 'implicit'), "no implicit attribute"
+
 class SigTestBase:
 
     def runTest(self):
@@ -397,6 +407,7 @@ class CalcTestCase(unittest.TestCase):
 
 def suite():
     suite = unittest.TestSuite()
+    suite.addTest(SConsignEntryTestCase())
     suite.addTest(MD5TestCase())
     suite.addTest(TimeStampTestCase())
     suite.addTest(CalcTestCase())