Have Task.make_ready() create a list of the out-of-date Nodes.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 7 Apr 2004 22:58:22 +0000 (22:58 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 7 Apr 2004 22:58:22 +0000 (22:58 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@951 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Taskmaster.py
src/engine/SCons/TaskmasterTests.py

index 45295c6dfb6fab4aa426758497fe3b22b11cd25b..a7323ea7c2191b26fbb04e29d9e73121be6dea17 100644 (file)
@@ -64,6 +64,9 @@ RELEASE 0.96 - XXX
     the env.SourceCode() method was called with an individual file name
     or node, not a directory name or node.
 
+  - Enhance the Task.make_ready() method to create a list of the
+    out-of-date Nodes for the task for use by the wrapping interface.
+
   From Gary Oberbrunner:
 
   - Add a --debug=presub option to print actions prior to substitution.
index 8afd847105f9c178c9d10df4f04982723df5b812..ffdc065a8bfcae10cb1355a96b650e724e25effb 100644 (file)
@@ -169,17 +169,26 @@ class Task:
 
     def make_ready(self):
         """Make a task ready for execution."""
-        state = SCons.Node.up_to_date
+        self.out_of_date = []
         calc = self.tm.calc
-        for t in self.targets:
-            c = calc or t.calculator()
-            if not t.current(c):
-                state = SCons.Node.executing
-        for t in self.targets:
-            if state == SCons.Node.executing:
+        if calc:
+            for t in self.targets:
+                if not t.current(calc):
+                    self.out_of_date.append(t)
+        else:
+            for t in self.targets:
+                if not t.current(t.calculator()):
+                    self.out_of_date.append(t)
+        if self.out_of_date:
+            state = SCons.Node.executing
+            for t in self.targets:
                 for side_effect in t.side_effects:
                     side_effect.set_state(state)
-            t.set_state(state)
+                t.set_state(state)
+        else:
+            state = SCons.Node.up_to_date
+            for t in self.targets:
+                t.set_state(state)
 
     def postprocess(self):
         """Post process a task after it's been executed."""
index d20b805b2de0b96358380a2d7e1560a372d6f7d4..1f66e06bb9d82bec121a2763094cbde3c30de808 100644 (file)
@@ -23,6 +23,7 @@
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import copy
 import sys
 import unittest
 
@@ -409,6 +410,49 @@ class TaskmasterTestCase(unittest.TestCase):
         t.executed()
 
 
+    def test_make_ready_out_of_date(self):
+        """Test the Task.make_ready() method's list of out-of-date Nodes
+        """
+        class MyCalc(SCons.Taskmaster.Calc):
+            def current(self, node, sig):
+                n = str(node)
+                return n[0] == 'c'
+
+        ood = []
+        def TaskGen(tm, targets, top, node, ood=ood):
+            class MyTask(SCons.Taskmaster.Task):
+                def make_ready(self):
+                    SCons.Taskmaster.Task.make_ready(self)
+                    self.ood.extend(self.out_of_date)
+            t = MyTask(tm, targets, top, node)
+            t.ood = ood
+            return t
+
+        n1 = Node("n1")
+        c2 = Node("c2")
+        n3 = Node("n3")
+        c4 = Node("c4")
+        tm = SCons.Taskmaster.Taskmaster(targets = [n1, c2, n3, c4],
+                                         tasker = TaskGen,
+                                         calc = MyCalc())
+
+        del ood[:]
+        t = tm.next_task()
+        assert ood == [n1], ood
+
+        del ood[:]
+        t = tm.next_task()
+        assert ood == [], ood
+
+        del ood[:]
+        t = tm.next_task()
+        assert ood == [n3], ood
+
+        del ood[:]
+        t = tm.next_task()
+        assert ood == [], ood
+
+
     def test_make_ready_exception(self):
         """Test handling exceptions from Task.make_ready()
         """