summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/EnvironmentTests.py15
-rw-r--r--src/engine/SCons/PathList.py10
-rw-r--r--src/engine/SCons/PathListTests.py36
3 files changed, 57 insertions, 4 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 9237c8a..45cf876 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -1440,6 +1440,21 @@ def exists(env):
x = s("${_concat(PRE, LIST, SUF, __env__)}")
assert x == 'preasuf prebsuf', x
+ def test_concat_nested(self):
+ "Test _concat() on a nested substitution strings."
+ e = self.TestEnvironment(PRE='pre', SUF='suf',
+ L1=['a', 'b'],
+ L2=['c', 'd'],
+ L3=['$L2'])
+ x = e.subst('$( ${_concat(PRE, L1, SUF, __env__)} $)')
+ assert x == 'preasuf prebsuf', x
+ e.AppendUnique(L1 = ['$L2'])
+ x = e.subst('$( ${_concat(PRE, L1, SUF, __env__)} $)')
+ assert x == 'preasuf prebsuf precsuf predsuf', x
+ e.AppendUnique(L1 = ['$L3'])
+ x = e.subst('$( ${_concat(PRE, L1, SUF, __env__)} $)')
+ assert x == 'preasuf prebsuf precsuf predsuf precsuf predsuf', x
+
def test_gvars(self):
"""Test the Environment gvars() method"""
env = self.TestEnvironment(XXX = 'x', YYY = 'y', ZZZ = 'z')
diff --git a/src/engine/SCons/PathList.py b/src/engine/SCons/PathList.py
index 870c195..f3de57c 100644
--- a/src/engine/SCons/PathList.py
+++ b/src/engine/SCons/PathList.py
@@ -131,12 +131,14 @@ class _PathList(object):
value = env.subst(value, target=target, source=source,
conv=node_conv)
if SCons.Util.is_Sequence(value):
- result.extend(value)
- continue
-
+ result.extend(SCons.Util.flatten(value))
+ elif value:
+ result.append(value)
elif type == TYPE_OBJECT:
value = node_conv(value)
- if value:
+ if value:
+ result.append(value)
+ elif value:
result.append(value)
return tuple(result)
diff --git a/src/engine/SCons/PathListTests.py b/src/engine/SCons/PathListTests.py
index 212c761..e83fc50 100644
--- a/src/engine/SCons/PathListTests.py
+++ b/src/engine/SCons/PathListTests.py
@@ -48,6 +48,8 @@ class subst_pathTestCase(unittest.TestCase):
return s
self.env = FakeEnvironment(AAA = 'aaa', NULL = '')
+ from SCons.Environment import Environment
+ self.env = Environment(AAA = 'aaa', NULL = '')
def test_node(self):
"""Test the subst_path() method on a Node
@@ -120,6 +122,40 @@ class subst_pathTestCase(unittest.TestCase):
assert result == ('aaa',), result
+ def test_list_of_lists(self):
+ """Test the subst_path() method on substitution of nested lists.
+ """
+ pl = SCons.PathList.PathList((['$AAA', '$AAA'], '$NULL'))
+ result = pl.subst_path(self.env, 'y', 'z')
+ assert result == ('aaa', 'aaa'), result
+
+ def test_subst_nested(self):
+ """Test the subst_path() method on nested substitution of strings.
+ """
+ self.env.Append(L1 = ['a', 'b'],
+ L2 = ['c', 'd'],
+ L3 = ['$L2'])
+ pl = SCons.PathList.PathList(['$L1'])
+ result = pl.subst_path(self.env, 'y', 'z')
+ assert result == ('a', 'b'), result
+ self.env.Append(L1 = ['$L2'])
+ pl = SCons.PathList.PathList(['$L1'])
+ result = pl.subst_path(self.env, 'y', 'z')
+ assert result == ('a', 'b', 'c', 'd'), result
+ self.env.Append(L1 = ['$L3'])
+ pl = SCons.PathList.PathList(['$L1'])
+ result = pl.subst_path(self.env, 'y', 'z')
+ assert result == ('a', 'b', 'c', 'd', 'c', 'd'), result
+
+ def test_another_env(self):
+ """Test the subst_path does lazy evaluation.
+ """
+ pl = SCons.PathList.PathList(('$AAA', '$NULL'))
+ result = pl.subst_path(self.env, 'y', 'z')
+ assert result == ('aaa',), result
+ e = self.env.Clone(AAA = 'bbb')
+ result = pl.subst_path(e, 'y', 'z')
+ assert result == ('bbb',), result
class PathListCacheTestCase(unittest.TestCase):