summaryrefslogtreecommitdiffstats
path: root/src/engine/SCons/Variables/VariablesTests.py
diff options
context:
space:
mode:
authorGary Oberbrunner <garyo@oberbrunner.com>2009-04-14 10:51:00 (GMT)
committerGary Oberbrunner <garyo@oberbrunner.com>2009-04-14 10:51:00 (GMT)
commit51cff874f72bc4afe2eb60a928472dc1669eab88 (patch)
tree76521351251ce2cd5e13b5157d2fabb24ec4b231 /src/engine/SCons/Variables/VariablesTests.py
parenta1e8d845f6d0b6f2bb86f7347fbdf1ba4a777bc4 (diff)
downloadSCons-51cff874f72bc4afe2eb60a928472dc1669eab88.zip
SCons-51cff874f72bc4afe2eb60a928472dc1669eab88.tar.gz
SCons-51cff874f72bc4afe2eb60a928472dc1669eab88.tar.bz2
Patch submitted by Lukas Erlinghagen. Thanks, Lukas!
this patch should fix issue 2362. - Variables that are added via Variables.Add or Variables.AddVariables are now removed from the 'unknown' dict if present - An option's name and its aliases can now actually be provided as a tuple as well as a list - Test cases for using option aliases and for issue 2362 itself are included
Diffstat (limited to 'src/engine/SCons/Variables/VariablesTests.py')
-rw-r--r--src/engine/SCons/Variables/VariablesTests.py106
1 files changed, 106 insertions, 0 deletions
diff --git a/src/engine/SCons/Variables/VariablesTests.py b/src/engine/SCons/Variables/VariablesTests.py
index 7f49692..69ef9fe 100644
--- a/src/engine/SCons/Variables/VariablesTests.py
+++ b/src/engine/SCons/Variables/VariablesTests.py
@@ -513,6 +513,44 @@ B 42 54 b - alpha test ['B']
"""
text = opts.GenerateHelpText(env, sort=cmp)
assert text == expectAlpha, text
+
+ def test_Aliases(self):
+ """Test option aliases"""
+ # test alias as a tuple
+ opts = SCons.Variables.Variables()
+ opts.AddVariables(
+ (('ANSWER', 'ANSWERALIAS'),
+ 'THE answer to THE question',
+ "42"),
+ )
+
+ env = Environment()
+ opts.Update(env, {'ANSWER' : 'answer'})
+
+ assert env.has_key('ANSWER')
+
+ env = Environment()
+ opts.Update(env, {'ANSWERALIAS' : 'answer'})
+
+ assert env.has_key('ANSWER') and not env.has_key('ANSWERALIAS')
+
+ # test alias as a list
+ opts = SCons.Variables.Variables()
+ opts.AddVariables(
+ (['ANSWER', 'ANSWERALIAS'],
+ 'THE answer to THE question',
+ "42"),
+ )
+
+ env = Environment()
+ opts.Update(env, {'ANSWER' : 'answer'})
+
+ assert env.has_key('ANSWER')
+
+ env = Environment()
+ opts.Update(env, {'ANSWERALIAS' : 'answer'})
+
+ assert env.has_key('ANSWER') and not env.has_key('ANSWERALIAS')
@@ -537,7 +575,75 @@ class UnknownVariablesTestCase(unittest.TestCase):
r = opts.UnknownVariables()
assert r == {'UNKNOWN' : 'unknown'}, r
assert env['ANSWER'] == 'answer', env['ANSWER']
+
+ def test_AddOptionUpdatesUnknown(self):
+ """Test updating of the 'unknown' dict"""
+ opts = SCons.Variables.Variables()
+
+ opts.Add('A',
+ 'A test variable',
+ "1")
+
+ args = {
+ 'A' : 'a',
+ 'ADDEDLATER' : 'notaddedyet',
+ }
+
+ env = Environment()
+ opts.Update(env,args)
+
+ r = opts.UnknownVariables()
+ assert r == {'ADDEDLATER' : 'notaddedyet'}, r
+ assert env['A'] == 'a', env['A']
+
+ opts.Add('ADDEDLATER',
+ 'An option not present initially',
+ "1")
+
+ args = {
+ 'A' : 'a',
+ 'ADDEDLATER' : 'added',
+ }
+
+ opts.Update(env, args)
+
+ r = opts.UnknownVariables()
+ assert len(r) == 0, r
+ assert env['ADDEDLATER'] == 'added', env['ADDEDLATER']
+ def test_AddOptionWithAliasUpdatesUnknown(self):
+ """Test updating of the 'unknown' dict (with aliases)"""
+ opts = SCons.Variables.Variables()
+
+ opts.Add('A',
+ 'A test variable',
+ "1")
+
+ args = {
+ 'A' : 'a',
+ 'ADDEDLATERALIAS' : 'notaddedyet',
+ }
+
+ env = Environment()
+ opts.Update(env,args)
+
+ r = opts.UnknownVariables()
+ assert r == {'ADDEDLATERALIAS' : 'notaddedyet'}, r
+ assert env['A'] == 'a', env['A']
+
+ opts.AddVariables(
+ (('ADDEDLATER', 'ADDEDLATERALIAS'),
+ 'An option not present initially',
+ "1"),
+ )
+
+ args['ADDEDLATERALIAS'] = 'added'
+
+ opts.Update(env, args)
+
+ r = opts.UnknownVariables()
+ assert len(r) == 0, r
+ assert env['ADDEDLATER'] == 'added', env['ADDEDLATER']
if __name__ == "__main__":