summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/ActionTests.py
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2010-01-14 07:02:42 (GMT)
committerSteven Knight <knight@baldmt.com>2010-01-14 07:02:42 (GMT)
commit31615ed4df11661975191af901f33d54989f8a91 (patch)
tree0e8df1c9a6a927fab7e20816cc6318e22601a56d /src/engine/SCons/ActionTests.py
parent4c70398f3f060490adac69ee8ac57fc513671467 (diff)
downloadSCons-31615ed4df11661975191af901f33d54989f8a91.zip
SCons-31615ed4df11661975191af901f33d54989f8a91.tar.gz
SCons-31615ed4df11661975191af901f33d54989f8a91.tar.bz2
Fix use of varlist in CommandGeneratorAction, ListAction and LazyAction
by adding a .get_varlist() accessor method that lets those wrapping classes fetch the varlist from their wrapped Action object(s).
Diffstat (limited to 'src/engine/SCons/ActionTests.py')
-rw-r--r--src/engine/SCons/ActionTests.py90
1 files changed, 90 insertions, 0 deletions
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py
index b3f5221..4c2198b 100644
--- a/src/engine/SCons/ActionTests.py
+++ b/src/engine/SCons/ActionTests.py
@@ -1485,6 +1485,55 @@ class CommandGeneratorActionTestCase(unittest.TestCase):
c = a.get_contents(target=[], source=[], env=env)
assert c == "guux FFF BBB test", c
+ def test_get_contents_of_function_action(self):
+ """Test contents of a CommandGeneratorAction-generated FunctionAction
+ """
+
+ def LocalFunc():
+ pass
+
+ func_matches = [
+ "0,0,0,0,(),(),(d\000\000S),(),()",
+ "0,0,0,0,(),(),(d\x00\x00S),(),()",
+ ]
+
+ meth_matches = [
+ "1,1,0,0,(),(),(d\000\000S),(),()",
+ "1,1,0,0,(),(),(d\x00\x00S),(),()",
+ ]
+
+ def f_global(target, source, env, for_signature):
+ return SCons.Action.Action(GlobalFunc)
+
+ def f_local(target, source, env, for_signature):
+ return SCons.Action.Action(LocalFunc)
+
+ env = Environment(XYZ = 'foo')
+
+ a = self.factory(f_global)
+ c = a.get_contents(target=[], source=[], env=env)
+ assert c in func_matches, repr(c)
+
+ a = self.factory(f_local)
+ c = a.get_contents(target=[], source=[], env=env)
+ assert c in func_matches, repr(c)
+
+ def f_global(target, source, env, for_signature):
+ return SCons.Action.Action(GlobalFunc, varlist=['XYZ'])
+
+ def f_local(target, source, env, for_signature):
+ return SCons.Action.Action(LocalFunc, varlist=['XYZ'])
+
+ matches_foo = map(lambda x: x + "foo", func_matches)
+
+ a = self.factory(f_global)
+ c = a.get_contents(target=[], source=[], env=env)
+ assert c in matches_foo, repr(c)
+
+ a = self.factory(f_local)
+ c = a.get_contents(target=[], source=[], env=env)
+ assert c in matches_foo, repr(c)
+
class FunctionActionTestCase(unittest.TestCase):
@@ -1808,6 +1857,47 @@ class LazyActionTestCase(unittest.TestCase):
c = a.get_contents(target=[], source=[], env=env)
assert c == "This is a test", c
+ def test_get_contents_of_function_action(self):
+ """Test fetching the contents of a lazy-evaluation FunctionAction
+ """
+
+ def LocalFunc():
+ pass
+
+ func_matches = [
+ "0,0,0,0,(),(),(d\000\000S),(),()",
+ "0,0,0,0,(),(),(d\x00\x00S),(),()",
+ ]
+
+ meth_matches = [
+ "1,1,0,0,(),(),(d\000\000S),(),()",
+ "1,1,0,0,(),(),(d\x00\x00S),(),()",
+ ]
+
+ def factory(act, **kw):
+ return SCons.Action.FunctionAction(act, kw)
+
+
+ a = SCons.Action.Action("${FOO}")
+
+ env = Environment(FOO = factory(GlobalFunc))
+ c = a.get_contents(target=[], source=[], env=env)
+ assert c in func_matches, repr(c)
+
+ env = Environment(FOO = factory(LocalFunc))
+ c = a.get_contents(target=[], source=[], env=env)
+ assert c in func_matches, repr(c)
+
+ matches_foo = map(lambda x: x + "foo", func_matches)
+
+ env = Environment(FOO = factory(GlobalFunc, varlist=['XYZ']))
+ c = a.get_contents(target=[], source=[], env=env)
+ assert c in func_matches, repr(c)
+
+ env['XYZ'] = 'foo'
+ c = a.get_contents(target=[], source=[], env=env)
+ assert c in matches_foo, repr(c)
+
class ActionCallerTestCase(unittest.TestCase):
def test___init__(self):
"""Test creation of an ActionCaller"""