diff options
author | Steven Knight <knight@baldmt.com> | 2003-03-13 14:18:35 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-03-13 14:18:35 (GMT) |
commit | 71a49faea8b046709ef816aee7b7bb5f9e4a1ccc (patch) | |
tree | 5ebbb790d2e1f160925b8a749029572076e2613b /src/engine/SCons/EnvironmentTests.py | |
parent | 739a3fa86075710448e66e6488135b65a9e3f9c4 (diff) | |
download | SCons-71a49faea8b046709ef816aee7b7bb5f9e4a1ccc.zip SCons-71a49faea8b046709ef816aee7b7bb5f9e4a1ccc.tar.gz SCons-71a49faea8b046709ef816aee7b7bb5f9e4a1ccc.tar.bz2 |
Support using construction variables as re-usable, callable command generators. (Charles Crain)
Diffstat (limited to 'src/engine/SCons/EnvironmentTests.py')
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index e590d7d..9a6eb1c 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -477,7 +477,7 @@ class EnvironmentTestCase(unittest.TestCase): action='buildfoo $target $source') assert not t.builder is None assert t.builder.action.__class__.__name__ == 'CommandAction' - assert t.builder.action.cmd_list == ['buildfoo', '$target', '$source'] + assert t.builder.action.cmd_list == 'buildfoo $target $source' assert 'foo1.in' in map(lambda x: x.path, t.sources) assert 'foo2.in' in map(lambda x: x.path, t.sources) @@ -540,6 +540,21 @@ class EnvironmentTestCase(unittest.TestCase): lst = env.subst_list([ "$AAA", "B $CCC" ]) assert lst == [ [ "a", "b" ], [ "c", "B a", "b" ], [ "c" ] ], lst + # Test callables in the Environment + def foo(target, source, env): + assert target == 1, target + assert source == 2, source + return env["FOO"] + + env = Environment(BAR=foo, FOO='baz') + + subst = env.subst('test $BAR', target=1, source=2) + assert subst == 'test baz', subst + + lst = env.subst_list('test $BAR', target=1, source=2) + assert lst[0][0] == 'test', lst[0][0] + assert lst[0][1] == 'baz', lst[0][1] + def test_autogenerate(dict): """Test autogenerating variables in a dictionary.""" @@ -816,6 +831,9 @@ class EnvironmentTestCase(unittest.TestCase): assert s == '', s s = map(str, d['TARGETS'][3:5]) assert s == ['__t4__', '__t5__'], s + s = map(lambda x: os.path.normcase(str(x)), d['TARGETS'].abspath) + assert s == map(os.path.normcase, [ os.path.join(os.getcwd(), '__t1__'), + os.path.join(os.getcwd(), '__t2__') ]) s = str(d['SOURCE']) assert s == '__s1__', s @@ -833,6 +851,9 @@ class EnvironmentTestCase(unittest.TestCase): assert s == '', s s = map(str, d['SOURCES'][3:5]) assert s == ['__s4__', '__s5__'], s + s = map(lambda x: os.path.normcase(str(x)), d['SOURCES'].abspath) + assert s == map(os.path.normcase, [ os.path.join(os.getcwd(), '__s1__'), + os.path.join(os.getcwd(), '__s2__') ]) if __name__ == "__main__": |