Guarantee ListOption persistence. (Elliot Murphy)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 16 Sep 2004 17:03:17 +0000 (17:03 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Thu, 16 Sep 2004 17:03:17 +0000 (17:03 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1077 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/CHANGES.txt
src/engine/SCons/Options/ListOption.py
src/engine/SCons/Options/ListOptionTests.py
test/Options.py

index 76dec9ac92cd6ed26728c3a71a93f25c29152535..be3522bf5bc5838a32d0bf9c03223e6832f4b32d 100644 (file)
@@ -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
index eade37429e5ebb52fff04e4a6ff4ece95d528fdf..8a9403709f760036c9617c3b8b1d4ff1f1c5b847 100644 (file)
@@ -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):
     """
index 0c7cc8eb50790dcd50694ed15d3009c16d87462e..ec339630a7d1c61fe1719390e1aefedd0b275ddb 100644 (file)
@@ -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():
index d9bfd176256b001c0f67191894f992d7b7f0a693..ecd9aa4ef3055187777b26f3ee6dcb125798451c 100644 (file)
@@ -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')