diff options
author | Steven Knight <knight@baldmt.com> | 2008-12-07 18:04:59 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2008-12-07 18:04:59 (GMT) |
commit | 9c0324beafa6dd9f4554b25d6824ea2f5de7cb77 (patch) | |
tree | f666a8f466995e10af0195ac50db1358cdfb432a /src/engine/SCons/EnvironmentTests.py | |
parent | 12141dbc1cbf67855a45d43a8c6cdc18d0ea5bc2 (diff) | |
download | SCons-9c0324beafa6dd9f4554b25d6824ea2f5de7cb77.zip SCons-9c0324beafa6dd9f4554b25d6824ea2f5de7cb77.tar.gz SCons-9c0324beafa6dd9f4554b25d6824ea2f5de7cb77.tar.bz2 |
Make ${,UN}CHANGED_{SOURCES,TARGETS} into future reserved construction
variable names, with an appropriate warning.
Diffstat (limited to 'src/engine/SCons/EnvironmentTests.py')
-rw-r--r-- | src/engine/SCons/EnvironmentTests.py | 44 |
1 files changed, 39 insertions, 5 deletions
diff --git a/src/engine/SCons/EnvironmentTests.py b/src/engine/SCons/EnvironmentTests.py index 2c09378..f3210b8 100644 --- a/src/engine/SCons/EnvironmentTests.py +++ b/src/engine/SCons/EnvironmentTests.py @@ -1120,25 +1120,59 @@ env4.builder1.env, env3) assert env.Dictionary('ENV')['PATH'] == '/foo:/bar' def test_ReservedVariables(self): - """Test generation of warnings when reserved variable names - are set in an environment.""" + """Test warning generation when reserved variable names are set""" - SCons.Warnings.enableWarningClass(SCons.Warnings.ReservedVariableWarning) + reserved_variables = [ + 'SOURCE', + 'SOURCES', + 'TARGET', + 'TARGETS', + ] + + warning = SCons.Warnings.ReservedVariableWarning + SCons.Warnings.enableWarningClass(warning) old = SCons.Warnings.warningAsException(1) try: env4 = Environment() - for kw in ['TARGET', 'TARGETS', 'SOURCE', 'SOURCES']: + for kw in reserved_variables: exc_caught = None try: env4[kw] = 'xyzzy' - except SCons.Warnings.ReservedVariableWarning: + except warning: exc_caught = 1 assert exc_caught, "Did not catch ReservedVariableWarning for `%s'" % kw assert not env4.has_key(kw), "`%s' variable was incorrectly set" % kw finally: SCons.Warnings.warningAsException(old) + def test_FutureReservedVariables(self): + """Test warning generation when future reserved variable names are set""" + + future_reserved_variables = [ + 'CHANGED_SOURCES', + 'CHANGED_TARGETS', + 'UNCHANGED_SOURCES', + 'UNCHANGED_TARGETS', + ] + + warning = SCons.Warnings.FutureReservedVariableWarning + SCons.Warnings.enableWarningClass(warning) + old = SCons.Warnings.warningAsException(1) + + try: + env4 = Environment() + for kw in future_reserved_variables: + exc_caught = None + try: + env4[kw] = 'xyzzy' + except warning: + exc_caught = 1 + assert exc_caught, "Did not catch FutureReservedVariableWarning for `%s'" % kw + assert env4.has_key(kw), "`%s' variable was not set" % kw + finally: + SCons.Warnings.warningAsException(old) + def test_IllegalVariables(self): """Test that use of illegal variables raises an exception""" env = Environment() |