Delay scanning a node from when we ask for its children to just before we're going...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 11 Dec 2001 04:52:18 +0000 (04:52 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 11 Dec 2001 04:52:18 +0000 (04:52 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@139 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Node/__init__.py
src/engine/SCons/Taskmaster.py
src/engine/SCons/TaskmasterTests.py

index 8b1ef55a37f8ac19af12e537a204b59ca7768900..d444c3de28edc7199c67381fad16cc7ad9713f33 100644 (file)
@@ -151,8 +151,6 @@ class Node:
         if parent not in self.parents: self.parents.append(parent)
 
     def children(self):
-        if not self.scanned:
-            self.scan()
        return self.sources + self.depends
 
     def get_parents(self):
index 1fb200c9f665018c35acc7b05eefb3e97bedd395..828fecd5160f85c24671b77a2093ceb4f5c2256d 100644 (file)
@@ -143,6 +143,8 @@ class Taskmaster:
     def __init__(self, targets=[], tasker=Task, calc=Calc()):
         
         def out_of_date(node):
+            # Scan the file before fetching its children().
+            node.scan()
             return filter(lambda x: x.get_state() != SCons.Node.up_to_date,
                           node.children())
 
index ca3037dd41b3ebed6c1a478755630d9f5e2d952e..5e661ee380918acd5e1a6b5cac02a7bc88698c08 100644 (file)
@@ -34,9 +34,10 @@ built = None
 executed = None
 
 class Node:
-    def __init__(self, name, kids = []):
+    def __init__(self, name, kids = [], scans = []):
         self.name = name
         self.kids = kids
+        self.scans = scans
         self.builder = Node.build
         self.bsig = None
         self.csig = None
@@ -52,6 +53,12 @@ class Node:
 
     def children(self):
        return self.kids
+
+    def scan(self):
+        self.kids = self.kids + self.scans
+        for scan in self.scans:
+            scan.parents.append(self)
+        self.scans = []
   
     def get_parents(self):
         return self.parents
@@ -210,7 +217,23 @@ class TaskmasterTestCase(unittest.TestCase):
         t.executed()
         assert not tm.is_blocked()
         t = tm.next_task()
-        assert tm. next_task() == None
+        assert tm.next_task() == None
+
+
+        n1 = Node("n1")
+        n2 = Node("n2")
+        n3 = Node("n3", [n1], [n2])
+        tm = SCons.Taskmaster.Taskmaster([n3])
+        t = tm.next_task()
+        assert t.get_target() == n1
+        t.executed()
+        t = tm.next_task()
+        assert t.get_target() == n2
+        t.executed()
+        t = tm.next_task()
+        assert t.get_target() == n3
+        t.executed()
+        assert tm.next_task() == None
     
     def test_cycle_detection(self):
         n1 = Node("n1")