Gary Oberbrunner avatar Gary Oberbrunner committed ccba95c

Improve error messages for invalid EnumVariables to include legal values.

Comments (0)

Files changed (4)

 RELEASE 2.1.0.alpha.yyyymmdd - NEW DATE WILL BE INSERTED HERE
 
   From Gary Oberbrunner:
+    - Improve error message for EnumVariables to show legal values.
+
+  From Gary Oberbrunner:
     - Fix Intel compiler to sort versions >9 correctly (esp. on Linux)
 
   From Dmitry R.:

src/engine/SCons/Variables/EnumVariable.py

 def _validator(key, val, env, vals):
     if not val in vals:
         raise SCons.Errors.UserError(
-            'Invalid value for option %s: %s' % (key, val))
+            'Invalid value for option %s: %s.  Valid values are: %s' % (key, val, vals))
 
 
 def EnumVariable(key, help, default, allowed_values, map={}, ignorecase=0):

test/Deprecated/Options/EnumOption.py

 check(['full', 'KdE', 'eins'])
 
 expect_stderr = warnings + """
-scons: \\*\\*\\* Invalid value for option debug: FULL
+scons: \\*\\*\\* Invalid value for option debug: FULL.  Valid values are: \\('yes', 'no', 'full'\\)
 """ + TestSCons.file_expr
 
 test.run(arguments='debug=FULL', stderr=expect_stderr, status=2)
 
 expect_stderr = warnings + """
-scons: \\*\\*\\* Invalid value for option guilib: irgendwas
+scons: \\*\\*\\* Invalid value for option guilib: irgendwas.  Valid values are: \\('motif', 'gtk', 'kde'\\)
 """ + TestSCons.file_expr
 
 test.run(arguments='guilib=IrGeNdwas', stderr=expect_stderr, status=2)
 
 expect_stderr = warnings + """
-scons: \\*\\*\\* Invalid value for option some: irgendwas
+scons: \\*\\*\\* Invalid value for option some: irgendwas.  Valid values are: \\('xaver', 'eins'\\)
 """ + TestSCons.file_expr
 
 test.run(arguments='some=IrGeNdwas', stderr=expect_stderr, status=2)

test/Variables/EnumVariable.py

 check(['full', 'KdE', 'eins'])
 
 expect_stderr = """
-scons: *** Invalid value for option debug: FULL
+scons: *** Invalid value for option debug: FULL.  Valid values are: ('yes', 'no', 'full')
 """ + test.python_file_line(SConstruct_path, 21)
 
 test.run(arguments='debug=FULL', stderr=expect_stderr, status=2)
 
 expect_stderr = """
-scons: *** Invalid value for option guilib: irgendwas
+scons: *** Invalid value for option guilib: irgendwas.  Valid values are: ('motif', 'gtk', 'kde')
 """ + test.python_file_line(SConstruct_path, 21)
 
 test.run(arguments='guilib=IrGeNdwas', stderr=expect_stderr, status=2)
 
 expect_stderr = """
-scons: *** Invalid value for option some: irgendwas
+scons: *** Invalid value for option some: irgendwas.  Valid values are: ('xaver', 'eins')
 """ + test.python_file_line(SConstruct_path, 21)
 
 test.run(arguments='some=IrGeNdwas', stderr=expect_stderr, status=2)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.