summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2024-09-11 18:12:14 (GMT)
committerMats Wichmann <mats@linux.com>2024-09-11 19:09:07 (GMT)
commit50bee2e7edcfd46dc21f28b131c6f1065ac44dcc (patch)
tree63bdb02d079d98dfa28634ef1197e3c72c18c4f2 /test
parentaad42dd6eeb9b1fe8756895f2567b25ef8e7d82f (diff)
downloadSCons-50bee2e7edcfd46dc21f28b131c6f1065ac44dcc.zip
SCons-50bee2e7edcfd46dc21f28b131c6f1065ac44dcc.tar.gz
SCons-50bee2e7edcfd46dc21f28b131c6f1065ac44dcc.tar.bz2
Fix some AddOption issues
The optparse add_option method supports an additional calling style that is not directly described in SCons docs, but is included by reference ("see the optparse documentation for details"): it takes a single arg consisting of a premade option object. Because the optparse code detects that case based on seeing zero kwargs, and we always add at least one (default=) that would fail for AddOption. Fix for consistency, but don't advertise it further: not addewd to manpage synoposis/description. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test')
-rw-r--r--test/AddOption/basic.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/AddOption/basic.py b/test/AddOption/basic.py
index 9fc3c4d..83297a8 100644
--- a/test/AddOption/basic.py
+++ b/test/AddOption/basic.py
@@ -33,6 +33,8 @@ import TestSCons
test = TestSCons.TestSCons()
test.write('SConstruct', """\
+from SCons.Script.SConsOptions import SConsOption
+
DefaultEnvironment(tools=[])
env = Environment(tools=[])
AddOption(
@@ -55,6 +57,9 @@ AddOption(
action="store_true",
help="try SetOption of 'prefix' to '/opt/share'"
)
+z_opt = SConsOption("--zcount", type="int", nargs=1, settable=True)
+AddOption(z_opt)
+
f = GetOption('force')
if f:
f = "True"
@@ -63,6 +68,8 @@ print(GetOption('prefix'))
if GetOption('set'):
SetOption('prefix', '/opt/share')
print(GetOption('prefix'))
+if GetOption('zcount'):
+ print(GetOption('zcount'))
""")
test.run('-Q -q .', stdout="None\nNone\n")
@@ -73,6 +80,8 @@ test.run('-Q -q . -- --prefix=/home/foo --force', status=1, stdout="None\nNone\n
test.run('-Q -q . --set', stdout="None\nNone\n/opt/share\n")
# but the "command line wins" rule is not violated
test.run('-Q -q . --set --prefix=/home/foo', stdout="None\n/home/foo\n/home/foo\n")
+# also try in case we pass a premade option object to AddOption
+test.run('-Q -q . --zcount=22', stdout="None\nNone\n22\n")
test.pass_test()