summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2024-08-31 14:24:44 (GMT)
committerMats Wichmann <mats@linux.com>2024-09-04 11:22:56 (GMT)
commitafd59b1f66ffeb53d86a361d2622a1fe50cfbdc9 (patch)
tree48794ddcfbc4889f302f6f48e6a034cd8b4ae416 /test
parentb2a103bff8787f9de51af975eae5e57347cdac80 (diff)
downloadSCons-afd59b1f66ffeb53d86a361d2622a1fe50cfbdc9.zip
SCons-afd59b1f66ffeb53d86a361d2622a1fe50cfbdc9.tar.gz
SCons-afd59b1f66ffeb53d86a361d2622a1fe50cfbdc9.tar.bz2
PackageVariable now returns the default on "true"
In all doc versions until 4.8.0, PackageVariable had wording like: "The option will support the values yes, true, on, enable or search, in which case the specified default will be used", but the code didn't actually do that, it just returned True. With this change it now returns the default value, with a slight tweak - if the default is one of the spelled out enabling strigs, it returns the boolean True instead. The indication that the default is produced if a truthy string is given is restored to the manpage (it was never dropped from the User Guide). Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test')
-rw-r--r--test/Variables/PackageVariable.py40
1 files changed, 34 insertions, 6 deletions
diff --git a/test/Variables/PackageVariable.py b/test/Variables/PackageVariable.py
index e87164c..1e32eee 100644
--- a/test/Variables/PackageVariable.py
+++ b/test/Variables/PackageVariable.py
@@ -27,6 +27,8 @@
Test the PackageVariable canned Variable type.
"""
+import os
+from typing import List
import TestSCons
@@ -34,8 +36,9 @@ test = TestSCons.TestSCons()
SConstruct_path = test.workpath('SConstruct')
-def check(expect):
+def check(expect: List[str]) -> None:
result = test.stdout().split('\n')
+ # skip first line and any lines beyond the length of expect
assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect)
test.write(SConstruct_path, """\
@@ -44,11 +47,9 @@ from SCons.Variables import PackageVariable
opts = Variables(args=ARGUMENTS)
opts.AddVariables(
- PackageVariable('x11',
- 'use X11 installed here (yes = search some places',
- 'yes'),
+ PackageVariable('x11', 'use X11 installed here (yes = search some places', 'yes'),
PV('package', 'help for package', 'yes'),
- )
+)
_ = DefaultEnvironment(tools=[])
env = Environment(variables=opts, tools=[])
@@ -77,10 +78,37 @@ check([space_subdir])
expect_stderr = """
scons: *** Path does not exist for variable 'x11': '/non/existing/path/'
-""" + test.python_file_line(SConstruct_path, 13)
+""" + test.python_file_line(SConstruct_path, 11)
test.run(arguments='x11=/non/existing/path/', stderr=expect_stderr, status=2)
+# test that an enabling value produces the default value
+# as long as that's a path string
+tinycbor_path = test.workpath('path', 'to', 'tinycbor')
+test.subdir(tinycbor_path)
+SConstruct_pathstr = test.workpath('SConstruct.path')
+test.write(SConstruct_pathstr, f"""\
+from SCons.Variables import PackageVariable
+
+vars = Variables(args=ARGUMENTS)
+vars.Add(
+ PackageVariable(
+ 'tinycbor',
+ help="use 'tinycbor' at <path>",
+ default='{tinycbor_path}'
+ )
+)
+
+_ = DefaultEnvironment(tools=[])
+env = Environment(variables=vars, tools=[])
+
+print(env['tinycbor'])
+Default(env.Alias('dummy', None))
+""")
+
+test.run(arguments=['-f', 'SConstruct.path', 'tinycbor=yes'])
+check([tinycbor_path])
+
test.pass_test()
# Local Variables: