summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2004-02-17 03:35:08 (GMT)
committerSteven Knight <knight@baldmt.com>2004-02-17 03:35:08 (GMT)
commit854094bf6993b4872f50e625377216950aee1d56 (patch)
tree66a0628f708f5d3144925c3c056af89a394d3e67 /src
parent40e2a5d1459f36811727d5f660c4f3ce33fbc213 (diff)
downloadSCons-854094bf6993b4872f50e625377216950aee1d56.zip
SCons-854094bf6993b4872f50e625377216950aee1d56.tar.gz
SCons-854094bf6993b4872f50e625377216950aee1d56.tar.bz2
Update the __env__ variable when making a Copy() or Override() of an Environment.
Diffstat (limited to 'src')
-rw-r--r--src/engine/SCons/Environment.py2
-rw-r--r--src/engine/SCons/EnvironmentTests.py26
2 files changed, 20 insertions, 8 deletions
diff --git a/src/engine/SCons/Environment.py b/src/engine/SCons/Environment.py
index 900b1e1..5f8575e 100644
--- a/src/engine/SCons/Environment.py
+++ b/src/engine/SCons/Environment.py
@@ -489,6 +489,7 @@ class Base:
"""
clone = copy.copy(self)
clone._dict = our_deepcopy(self._dict)
+ clone['__env__'] = clone
try:
cbd = clone._dict['BUILDERS']
clone._dict['BUILDERS'] = BuilderDict(cbd, clone)
@@ -553,6 +554,7 @@ class Base:
if overrides:
env = copy.copy(self)
env._dict = copy.copy(self._dict)
+ env['__env__'] = env
env._dict.update(overrides)
return env
else:
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py
index 0887ae3..3a0e79e 100644
--- a/src/engine/SCons/EnvironmentTests.py
+++ b/src/engine/SCons/EnvironmentTests.py
@@ -117,14 +117,17 @@ class Scanner:
class EnvironmentTestCase(unittest.TestCase):
def test___init__(self):
- """Test construction Environments creation
-
- Create two with identical arguments and check that
- they compare the same.
- """
- env1 = Environment(XXX = 'x', YYY = 'y')
- env2 = Environment(XXX = 'x', YYY = 'y')
- assert env1 == env2, diff_env(env1, env2)
+ """Test construction Environment creation
+
+ Create two with identical arguments and check that
+ they compare the same.
+ """
+ env1 = Environment(XXX = 'x', YYY = 'y')
+ env2 = Environment(XXX = 'x', YYY = 'y')
+ assert env1 == env2, diff_env(env1, env2)
+
+ assert env1['__env__'] is env1, env1['__env__']
+ assert env2['__env__'] is env2, env2['__env__']
def test_get(self):
"""Test the get() method."""
@@ -947,6 +950,10 @@ class EnvironmentTestCase(unittest.TestCase):
assert env3.Dictionary('ZZZ') == 'z3'
assert env1 == env1copy
+ assert env1['__env__'] is env1, env1['__env__']
+ assert env2['__env__'] is env2, env2['__env__']
+ assert env3['__env__'] is env3, env3['__env__']
+
# Ensure that lists and dictionaries are
# deep copied, but not instances.
class TestA:
@@ -1106,6 +1113,9 @@ class EnvironmentTestCase(unittest.TestCase):
assert env2['ONE'] == "won"
assert env['ONE'] == 1
+ assert env['__env__'] is env, env['__env__']
+ assert env2['__env__'] is env2, env2['__env__']
+
def test_ParseConfig(self):
"""Test the ParseConfig() method"""
env = Environment(COMMAND='command',