Add a genstring() method to the ListAction class.
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 10 Nov 2004 02:37:58 +0000 (02:37 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 10 Nov 2004 02:37:58 +0000 (02:37 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1152 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Action.py
src/engine/SCons/ActionTests.py

index 5f89cc2b583f1e3133d9975f463deba006f563ac..3b62702bd28304dfcb7afb66b5edec3b8134bcee 100644 (file)
@@ -575,6 +575,12 @@ class ListAction(ActionBase):
             return Action(x)
         self.list = map(list_of_actions, list)
 
+    def genstring(self, target, source, env):
+        return string.join(map(lambda a, t=target, s=source, e=env:
+                                  a.genstring(t, s, e),
+                               self.list),
+                           '\n')
+
     def __str__(self):
         return string.join(map(str, self.list), '\n')
     
index e996f61c8c8aebed26a35fa6e3d152c1f2f24514..74812df45626497fbebba52d7259d6837fd99946 100644 (file)
@@ -1408,11 +1408,12 @@ class ListActionTestCase(unittest.TestCase):
         """
         def f(target,source,env):
             pass
-        def g(target,source,env):
-            pass
+        def g(target,source,env,for_signature):
+            return 'generated %s %s' % (target[0], source[0])
+        g = SCons.Action.CommandGenerator(g)
         a = SCons.Action.ListAction([f, g, "XXX", f])
-        s = a.genstring([], [], Environment())
-        assert s == "f(target, source, env)\ng(target, source, env)\nXXX\nf(target, source, env)", s
+        s = a.genstring(['foo.x'], ['bar.y'], Environment())
+        assert s == "f(target, source, env)\ngenerated foo.x bar.y\nXXX\nf(target, source, env)", s
 
     def test_execute(self):
         """Test executing a list of subsidiary Actions