From 68fcd2b14042333c40301841406a968564159105 Mon Sep 17 00:00:00 2001 From: Gary Oberbrunner Date: Thu, 13 Jan 2011 21:36:05 +0000 Subject: Improve error messages for invalid EnumVariables to include legal values. --- src/CHANGES.txt | 3 +++ src/engine/SCons/Variables/EnumVariable.py | 2 +- test/Deprecated/Options/EnumOption.py | 6 +++--- test/Variables/EnumVariable.py | 6 +++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/CHANGES.txt b/src/CHANGES.txt index 19a037d..3f16e58 100644 --- a/src/CHANGES.txt +++ b/src/CHANGES.txt @@ -8,6 +8,9 @@ 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.: diff --git a/src/engine/SCons/Variables/EnumVariable.py b/src/engine/SCons/Variables/EnumVariable.py index 71302ee..582be27 100644 --- a/src/engine/SCons/Variables/EnumVariable.py +++ b/src/engine/SCons/Variables/EnumVariable.py @@ -47,7 +47,7 @@ import SCons.Errors 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): diff --git a/test/Deprecated/Options/EnumOption.py b/test/Deprecated/Options/EnumOption.py index 6756f09..57ae7eb 100644 --- a/test/Deprecated/Options/EnumOption.py +++ b/test/Deprecated/Options/EnumOption.py @@ -90,19 +90,19 @@ test.run(arguments='debug=full guilib=KdE some=EiNs', stderr=warnings) 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) diff --git a/test/Variables/EnumVariable.py b/test/Variables/EnumVariable.py index bb85f4c..c04b396 100644 --- a/test/Variables/EnumVariable.py +++ b/test/Variables/EnumVariable.py @@ -83,19 +83,19 @@ test.run(arguments='debug=full guilib=KdE some=EiNs') 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) -- cgit v0.12