From 205bce15b461669f84830ec57ca19c7377f2a528 Mon Sep 17 00:00:00 2001 From: Steven Knight Date: Thu, 16 Sep 2004 17:03:17 +0000 Subject: Guarantee ListOption persistence. (Elliot Murphy) --- src/CHANGES.txt | 5 +++++ src/engine/SCons/Options/ListOption.py | 4 ++-- src/engine/SCons/Options/ListOptionTests.py | 3 +++ test/Options.py | 10 ++++++++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 76dec9a..be3522b 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -40,6 +40,11 @@ RELEASE 0.97 - XXX interrupting builds by writing to a temporary file and renaming, not writing the file directly. + From Elliot Murphy: + + - Enhance the tests to guarantee persistence of ListOption + values in saved options files. + From Gary Oberbrunner: - Add an Environment.Dump() method to print the contents of a diff --git a/src/engine/SCons/Options/ListOption.py b/src/engine/SCons/Options/ListOption.py index eade374..8a94037 100644 --- a/src/engine/SCons/Options/ListOption.py +++ b/src/engine/SCons/Options/ListOption.py @@ -84,8 +84,8 @@ class _ListOption(UserList.UserList): return 'all' else: return string.join(self, ',') - #def __repr__(self): - # todo: implement this + def __repr__(self): + return self.__str__() def _converter(val, allowedElems): """ diff --git a/src/engine/SCons/Options/ListOptionTests.py b/src/engine/SCons/Options/ListOptionTests.py index 0c7cc8e..ec33963 100644 --- a/src/engine/SCons/Options/ListOptionTests.py +++ b/src/engine/SCons/Options/ListOptionTests.py @@ -106,6 +106,9 @@ class ListOptionTestCase(unittest.TestCase): l = o.converter('all') n = l.__class__(copy.copy(l)) + def test___repr__(self): + """Test copying a ListOption like an Environment would""" + if __name__ == "__main__": suite = unittest.makeSuite(ListOptionTestCase, 'test_') if not unittest.TextTestRunner().run(suite).wasSuccessful(): diff --git a/test/Options.py b/test/Options.py index d9bfd17..ecd9aa4 100644 --- a/test/Options.py +++ b/test/Options.py @@ -245,10 +245,16 @@ opts.Add('DEBUG_BUILD', opts.Add('UNSPECIFIED', 'An option with no value') +opts.Add('LISTOPTION_TEST', + 'testing list option persistence', + 'none', + names = ['a','b','c',]) + env = Environment(options = opts) print env['RELEASE_BUILD'] print env['DEBUG_BUILD'] +print env['LISTOPTION_TEST'] opts.Save('options.saved', env) """) @@ -264,9 +270,9 @@ check(['0','1']) checkSave('options.saved', {}) # Now specify same option non-default and make sure only it is written out -test.run(arguments='"DEBUG_BUILD=0"') +test.run(arguments='"DEBUG_BUILD=0" "LISTOPTION_TEST=a,b"') check(['0','0']) -checkSave('options.saved',{'DEBUG_BUILD':0}) +checkSave('options.saved',{'DEBUG_BUILD':0, 'LISTOPTION_TEST':'a,b'}) test.write('SConstruct', """ opts = Options('custom.py') -- cgit v0.12