summaryrefslogtreecommitdiffstats
path: root/src/engine
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine')
-rw-r--r--src/engine/SCons/Options.py10
-rw-r--r--src/engine/SCons/OptionsTests.py40
2 files changed, 46 insertions, 4 deletions
diff --git a/src/engine/SCons/Options.py b/src/engine/SCons/Options.py
index d43be28..2aae5fc 100644
--- a/src/engine/SCons/Options.py
+++ b/src/engine/SCons/Options.py
@@ -170,7 +170,7 @@ class Options:
except IOError, x:
raise SCons.Errors.UserError, 'Error writing options to file: %s\n%s' % (filename, x)
- def GenerateHelpText(self, env):
+ def GenerateHelpText(self, env, sort=None):
"""
Generate the help text for the options.
@@ -179,7 +179,13 @@ class Options:
help_text = ""
- for option in self.options:
+ if sort:
+ options = self.options[:]
+ options.sort(lambda x,y,func=sort: func(x.key,y.key))
+ else:
+ options = self.options
+
+ for option in options:
help_text = help_text + '\n%s: %s\n default: %s\n'%(option.key, option.help, option.default)
if env.has_key(option.key):
help_text = help_text + ' actual: %s\n'%env.subst('${%s}'%option.key)
diff --git a/src/engine/SCons/OptionsTests.py b/src/engine/SCons/OptionsTests.py
index 7020787..491845e 100644
--- a/src/engine/SCons/OptionsTests.py
+++ b/src/engine/SCons/OptionsTests.py
@@ -71,7 +71,7 @@ class OptionsTestCase(unittest.TestCase):
assert o.default == None
assert o.validater == None
assert o.converter == None
- assert o.should_save == 0
+ assert o.should_save == 0
o = opts.options[1]
assert o.key == 'ANSWER'
@@ -172,6 +172,18 @@ class OptionsTestCase(unittest.TestCase):
check,
lambda x: int(x) + 12)
+ opts.Add('B',
+ 'b - alpha test',
+ "42",
+ check,
+ lambda x: int(x) + 12)
+
+ opts.Add('A',
+ 'a - alpha test',
+ "42",
+ check,
+ lambda x: int(x) + 12)
+
env = Environment()
opts.Update(env, {})
@@ -179,12 +191,36 @@ class OptionsTestCase(unittest.TestCase):
ANSWER: THE answer to THE question
default: 42
actual: 54
+
+B: b - alpha test
+ default: 42
+ actual: 54
+
+A: a - alpha test
+ default: 42
+ actual: 54
"""
text = opts.GenerateHelpText(env)
assert text == expect, text
+
+ expectAlpha = """
+A: a - alpha test
+ default: 42
+ actual: 54
+
+ANSWER: THE answer to THE question
+ default: 42
+ actual: 54
+
+B: b - alpha test
+ default: 42
+ actual: 54
+"""
+ text = opts.GenerateHelpText(env, sort=cmp)
+ assert text == expectAlpha, text
if __name__ == "__main__":
suite = unittest.makeSuite(OptionsTestCase, 'test_')
if not unittest.TextTestRunner().run(suite).wasSuccessful():
- sys.exit(1)
+ sys.exit(1)