Use fake Nodes, not strings, for scanner tests. Have Scanner test rexists() methods...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 7 Oct 2004 22:01:25 +0000 (22:01 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 7 Oct 2004 22:01:25 +0000 (22:01 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1119 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Scanner/ProgTests.py
src/engine/SCons/Scanner/ScannerTests.py

index f7064ffc09dc4845dc58f3785b16e2ff0fa0018d..7ab88f94720202eecfc4ee9adafd89920ea7e28e 100644 (file)
@@ -83,6 +83,14 @@ class DummyEnvironment:
             path = [path]
         return map(self.subst, path)
 
+class DummyNode:
+    def __init__(self, name):
+        self.name = name
+    def rexists(self):
+        return 1
+    def __str__(self):
+        return self.name
+    
 def deps_match(deps, libs):
     deps=map(str, deps)
     deps.sort()
@@ -99,14 +107,14 @@ class ProgScanTestCase1(unittest.TestCase):
                                LIBS=[ 'l1', 'l2', 'l3' ])
         s = SCons.Scanner.Prog.ProgScan()
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['l1.lib']), map(str, deps)
 
         env = DummyEnvironment(LIBPATH=[ test.workpath("") ],
                                LIBS='l1')
         s = SCons.Scanner.Prog.ProgScan()
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['l1.lib']), map(str, deps)
 
         f1 = SCons.Node.FS.default_fs.File(test.workpath('f1'))
@@ -114,7 +122,7 @@ class ProgScanTestCase1(unittest.TestCase):
                                LIBS=[f1])
         s = SCons.Scanner.Prog.ProgScan()
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps[0] is f1, deps
 
         f2 = SCons.Node.FS.default_fs.File(test.workpath('f1'))
@@ -122,7 +130,7 @@ class ProgScanTestCase1(unittest.TestCase):
                                LIBS=f2)
         s = SCons.Scanner.Prog.ProgScan()
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps[0] is f2, deps
 
 
@@ -133,7 +141,7 @@ class ProgScanTestCase2(unittest.TestCase):
                                LIBS=[ 'l1', 'l2', 'l3' ])
         s = SCons.Scanner.Prog.ProgScan()
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['l1.lib', 'd1/l2.lib', 'd1/d2/l3.lib' ]), map(str, deps)
 
 class ProgScanTestCase3(unittest.TestCase):
@@ -143,7 +151,7 @@ class ProgScanTestCase3(unittest.TestCase):
                                LIBS=string.split('l2 l3'))
         s = SCons.Scanner.Prog.ProgScan()
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps)
 
 class ProgScanTestCase5(unittest.TestCase):
@@ -158,7 +166,7 @@ class ProgScanTestCase5(unittest.TestCase):
                                LIBS=string.split('l2 l3'))
         s = SCons.Scanner.Prog.ProgScan()
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, [ 'd1/l2.lib' ]), map(str, deps)
 
 class ProgScanTestCase6(unittest.TestCase):
@@ -169,7 +177,7 @@ class ProgScanTestCase6(unittest.TestCase):
                                LIBSUFFIXES=['.a'])
         s = SCons.Scanner.Prog.ProgScan()
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), map(str, deps)
 
 class ProgScanTestCase7(unittest.TestCase):
@@ -182,33 +190,30 @@ class ProgScanTestCase7(unittest.TestCase):
                                XYZ='xyz.other')
         s = SCons.Scanner.Prog.ProgScan()
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps_match(deps, ['dir/libfoo.a', 'dir/sub/libbar.a', 'dir/libxyz.other']), map(str, deps)
 
 class ProgScanTestCase8(unittest.TestCase):
     def runTest(self):
         
-        class DummyNode:
-            pass
-
-        n1 = DummyNode()
+        n1 = DummyNode('n1')
         env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
                                LIBS=[n1],
                                LIBPREFIXES=['p1-', 'p2-'],
                                LIBSUFFIXES=['.1', '2'])
         s = SCons.Scanner.Prog.ProgScan(node_class = DummyNode)
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps == [n1], deps
 
-        n2 = DummyNode()
+        n2 = DummyNode('n2')
         env = DummyEnvironment(LIBPATH=[ test.workpath("dir") ],
                                LIBS=[n1, [n2]],
                                LIBPREFIXES=['p1-', 'p2-'],
                                LIBSUFFIXES=['.1', '2'])
         s = SCons.Scanner.Prog.ProgScan(node_class = DummyNode)
         path = s.path(env)
-        deps = s('dummy', env, path)
+        deps = s(DummyNode('dummy'), env, path)
         assert deps == [n1, n2], deps
 
 def suite():
@@ -229,7 +234,7 @@ def suite():
                                            LIBS=string.split(u'l2 l3'))
                     s = SCons.Scanner.Prog.ProgScan()
                     path = s.path(env)
-                    deps = s('dummy', env, path)
+                    deps = s(DummyNode('dummy'), env, path)
                     assert deps_match(deps, ['d1/l2.lib', 'd1/d2/l3.lib']), map(str, deps)
             suite.addTest(ProgScanTestCase4())
             \n"""
index d4ae05b5e278be47b71111fd3744ca8beeb17405..6520788b25695b9527bb6cd8d9c6db0b43b6314a 100644 (file)
@@ -53,7 +53,7 @@ class DummyNode:
     def __init__(self, name):
         self.name = name
     def rexists(self):
-        return None
+        return 1
     def __str__(self):
         return self.name
     
@@ -252,7 +252,7 @@ class SelectorTestCase(unittest.TestCase):
         def scanner_key(self):
             return self.key
         def rexists(self):
-            return None
+            return 1
 
     def test___init__(self):
         """Test creation of Scanner.Selector object"""
@@ -310,7 +310,7 @@ class CurrentTestCase(unittest.TestCase):
                 self.called_current = None
                 self.func_called = None
             def rexists(self):
-                return None
+                return 1
         class HasNoBuilder(MyNode):
             def has_builder(self):
                 self.called_has_builder = 1