From e014a38cb4deac67f3cdded96cc5a8cf447c4b1c Mon Sep 17 00:00:00 2001 From: stevenknight Date: Sat, 3 Apr 2004 07:47:40 +0000 Subject: [PATCH] Put the --duplicate option in alphabetical order in the help output. git-svn-id: http://scons.tigris.org/svn/scons/trunk@945 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- src/engine/SCons/Script/__init__.py | 23 ++++++++++++----------- test/option--H.py | 17 ++++++++++++++++- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/engine/SCons/Script/__init__.py b/src/engine/SCons/Script/__init__.py index 52d0db21..a5363666 100644 --- a/src/engine/SCons/Script/__init__.py +++ b/src/engine/SCons/Script/__init__.py @@ -507,6 +507,18 @@ class OptParser(OptionParser): help="Print various types of debugging information: " "%s." % string.join(debug_options, ", ")) + def opt_duplicate(option, opt, value, parser): + if not value in SCons.Node.FS.Valid_Duplicates: + raise OptionValueError("`%s' is not a valid duplication style." % value) + setattr(parser.values, 'duplicate', value) + # Set the duplicate style right away so it can affect linking + # of SConscript files. + SCons.Node.FS.set_duplicate(value) + self.add_option('--duplicate', action="callback", type="string", + callback=opt_duplicate, nargs=1, dest="duplicate", + help="Set the preferred duplication methods. Must be one of " + + string.join(SCons.Node.FS.Valid_Duplicates, ", ")) + self.add_option('-f', '--file', '--makefile', '--sconstruct', action="append", nargs=1, help="Read FILE as the top-level SConstruct file.") @@ -613,17 +625,6 @@ class OptParser(OptionParser): # "LOAD-AVERAGE." # type="int", help=SUPPRESS_HELP) - def opt_duplicate(option, opt, value, parser): - if not value in SCons.Node.FS.Valid_Duplicates: - raise OptionValueError("`%s' is not a valid duplication style." % value) - setattr(parser.values, 'duplicate', value) - # Set the duplicate stye right away so it can affect linking - # of SConscript files. - SCons.Node.FS.set_duplicate(value) - self.add_option('--duplicate', action="callback", type="string", - callback=opt_duplicate, nargs=1, dest="duplicate", - help="Set the preferred duplication methods. Must be one of " - + string.join(SCons.Node.FS.Valid_Duplicates, ", ")) self.add_option('--list-derived', action="callback", callback=opt_not_yet, # help="Don't build; list files that would be built." diff --git a/test/option--H.py b/test/option--H.py index 5cf9ab73..0cf3b2bf 100644 --- a/test/option--H.py +++ b/test/option--H.py @@ -24,10 +24,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import TestSCons +import copy import string import sys +import TestSCons + test = TestSCons.TestSCons() test.write('SConstruct', "") @@ -37,5 +39,18 @@ test.run(arguments = '-H') test.fail_test(string.find(test.stdout(), '-H, --help-options') == -1) test.fail_test(string.find(test.stdout(), '--debug=TYPE') == -1) +# Validate that the help output lists the options in case-insensitive +# alphabetical order. +lines = string.split(test.stdout(), '\n') +lines = filter(lambda x: x[:3] == ' -', lines) +lines = map(lambda x: x[3:], lines) +lines = map(lambda x: x[0] == '-' and x[1:] or x, lines) +options = map(lambda x: string.split(x)[0], lines) +options = map(lambda x: x[-1] == ',' and x[:-1] or x, options) +lowered = map(lambda x: string.lower(x), options) +sorted = copy.copy(lowered) +sorted.sort() +test.fail_test(lowered != sorted) + test.pass_test() -- 2.26.2