Ignore null tools. (Gary Oberbrunner)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 30 Jul 2004 17:10:08 +0000 (17:10 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Fri, 30 Jul 2004 17:10:08 +0000 (17:10 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1015 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/Environment.py
src/engine/SCons/EnvironmentTests.py

index 080232ab4c8190e62b4e84fc77df07cf5c8829a1..0e79eb4db1d78e1149caf698ae78ea8477b1dd87 100644 (file)
@@ -115,6 +115,8 @@ def our_deepcopy(x):
 
 def apply_tools(env, tools, toolpath):
     if tools:
+        # Filter out null tools from the list.
+        tools = filter(None, tools)
         for tool in tools:
             if SCons.Util.is_String(tool):
                 env.Tool(tool, toolpath)
index 8ac43cb9a6fc65147cd6862c474ea27c16a6551b..c65fb03175190eb99a09c48011a15531c67bf84a 100644 (file)
@@ -866,6 +866,23 @@ class EnvironmentTestCase(unittest.TestCase):
         finally:
             SCons.Defaults.ConstructionEnvironment = save
 
+    def test_null_tools(self):
+        """Test specifying a tool of None is OK."""
+        def t1(env):
+            env['TOOL1'] = 111
+        def t2(env):
+            env['TOOL2'] = 222
+        env = Environment(tools = [t1, None, t2], XYZ = 'aaa')
+        assert env['TOOL1'] == 111, env['TOOL1']
+        assert env['TOOL2'] == 222, env
+        assert env['XYZ'] == 'aaa', env
+        env = Environment(tools = [None], XYZ = 'xyz')
+        assert env['XYZ'] == 'xyz', env
+        env = Environment(tools = [t1, '', t2], XYZ = 'ddd')
+        assert env['TOOL1'] == 111, env['TOOL1']
+        assert env['TOOL2'] == 222, env
+        assert env['XYZ'] == 'ddd', env
+
     def test_concat(self):
         "Test _concat()"
         e1 = Environment(PRE='pre', SUF='suf', STR='a b', LIST=['a', 'b'])