From 21322dd01fbc0a227ee80b7da9733cd77d210ebb Mon Sep 17 00:00:00 2001 From: stevenknight Date: Tue, 25 May 2004 13:24:06 +0000 Subject: [PATCH] Add unit tests for the last two changes. git-svn-id: http://scons.tigris.org/svn/scons/trunk@986 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Node/FSTests.py | 25 +++++++++++++++++++++++++ src/engine/SCons/Node/NodeTests.py | 9 +++++++++ src/engine/SCons/Sig/SigTests.py | 11 +++++++++++ 3 files changed, 45 insertions(+) diff --git a/src/engine/SCons/Node/FSTests.py b/src/engine/SCons/Node/FSTests.py index f69dd4e1..f537acf8 100644 --- a/src/engine/SCons/Node/FSTests.py +++ b/src/engine/SCons/Node/FSTests.py @@ -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()) diff --git a/src/engine/SCons/Node/NodeTests.py b/src/engine/SCons/Node/NodeTests.py index e36d6ce8..f14339e1 100644 --- a/src/engine/SCons/Node/NodeTests.py +++ b/src/engine/SCons/Node/NodeTests.py @@ -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): diff --git a/src/engine/SCons/Sig/SigTests.py b/src/engine/SCons/Sig/SigTests.py index 009addd1..4390a607 100644 --- a/src/engine/SCons/Sig/SigTests.py +++ b/src/engine/SCons/Sig/SigTests.py @@ -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()) -- 2.26.2