summaryrefslogtreecommitdiff
path: root/test/Variables
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2022-10-22 10:49:23 -0600
committerMats Wichmann <mats@linux.com>2022-10-22 10:49:23 -0600
commit31dd7e91b4b5a0b303e975c0380fdbc313c2429c (patch)
tree1dbeb40368d4b0cc93f7ed5bf6cddea3d09dceae /test/Variables
parentff86dc857d9caa9c5ebb85f2fe37a1124c32eca5 (diff)
downloadscons-git-31dd7e91b4b5a0b303e975c0380fdbc313c2429c.tar.gz
Small cleanup in BoolVariable [skip appveyor]
For consistency, have BoolVariable usage use True and False instead of 0 and 1 - mainly this is tests and doc examples. Reformatted a few embedded test files. Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test/Variables')
-rw-r--r--test/Variables/BoolVariable.py21
-rw-r--r--test/Variables/help.py74
2 files changed, 52 insertions, 43 deletions
diff --git a/test/Variables/BoolVariable.py b/test/Variables/BoolVariable.py
index eaf496a70..9a95d859c 100644
--- a/test/Variables/BoolVariable.py
+++ b/test/Variables/BoolVariable.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
-# __COPYRIGHT__
+# MIT License
+#
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -20,9 +22,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
Test the BoolVariable canned Variable type.
@@ -40,18 +39,18 @@ def check(expect):
assert result[1:len(expect)+1] == expect, (result[1:len(expect)+1], expect)
-
test.write(SConstruct_path, """\
from SCons.Variables.BoolVariable import BoolVariable
+
BV = BoolVariable
from SCons.Variables import BoolVariable
opts = Variables(args=ARGUMENTS)
opts.AddVariables(
- BoolVariable('warnings', 'compilation with -Wall and similiar', 1),
- BV('profile', 'create profiling informations', 0),
- )
+ BoolVariable('warnings', 'compilation with -Wall and similiar', True),
+ BV('profile', 'create profiling informations', False),
+)
env = Environment(variables=opts)
Help(opts.GenerateHelpText(env))
@@ -62,8 +61,6 @@ print(env['profile'])
Default(env.Alias('dummy', None))
""")
-
-
test.run()
check([str(True), str(False)])
@@ -73,12 +70,10 @@ check([str(False), str(True)])
expect_stderr = """
scons: *** Error converting option: warnings
Invalid value for boolean option: irgendwas
-""" + test.python_file_line(SConstruct_path, 12)
+""" + test.python_file_line(SConstruct_path, 13)
test.run(arguments='warnings=irgendwas', stderr = expect_stderr, status=2)
-
-
test.pass_test()
# Local Variables:
diff --git a/test/Variables/help.py b/test/Variables/help.py
index bee60111d..cab7a6770 100644
--- a/test/Variables/help.py
+++ b/test/Variables/help.py
@@ -1,6 +1,8 @@
#!/usr/bin/env python
#
-# __COPYRIGHT__
+# MIT License
+#
+# Copyright The SCons Foundation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
@@ -20,9 +22,6 @@
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
Test the Variables help messages.
@@ -46,37 +45,52 @@ test.subdir(qtpath)
test.subdir(libpath)
test.write('SConstruct', """
-from SCons.Variables import BoolVariable, EnumVariable, ListVariable, \
- PackageVariable, PathVariable
+from SCons.Variables import (
+ BoolVariable,
+ EnumVariable,
+ ListVariable,
+ PackageVariable,
+ PathVariable,
+)
list_of_libs = Split('x11 gl qt ical')
qtdir = r'%(qtpath)s'
opts = Variables(args=ARGUMENTS)
opts.AddVariables(
- BoolVariable('warnings', 'compilation with -Wall and similiar', 1),
- BoolVariable('profile', 'create profiling informations', 0),
- EnumVariable('debug', 'debug output and symbols', 'no',
- allowed_values=('yes', 'no', 'full'),
- map={}, ignorecase=0), # case sensitive
- EnumVariable('guilib', 'gui lib to use', 'gtk',
- allowed_values=('motif', 'gtk', 'kde'),
- map={}, ignorecase=1), # case insensitive
- EnumVariable('some', 'some option', 'xaver',
- allowed_values=('xaver', 'eins'),
- map={}, ignorecase=2), # make lowercase
- ListVariable('shared',
- 'libraries to build as shared libraries',
- 'all',
- names = list_of_libs),
- PackageVariable('x11',
- 'use X11 installed here (yes = search some places)',
- 'yes'),
+ BoolVariable('warnings', 'compilation with -Wall and similiar', True),
+ BoolVariable('profile', 'create profiling informations', False),
+ EnumVariable(
+ 'debug',
+ 'debug output and symbols',
+ 'no',
+ allowed_values=('yes', 'no', 'full'),
+ map={},
+ ignorecase=0,
+ ), # case sensitive
+ EnumVariable(
+ 'guilib',
+ 'gui lib to use',
+ 'gtk',
+ allowed_values=('motif', 'gtk', 'kde'),
+ map={},
+ ignorecase=1,
+ ), # case insensitive
+ EnumVariable(
+ 'some',
+ 'some option',
+ 'xaver',
+ allowed_values=('xaver', 'eins'),
+ map={},
+ ignorecase=2,
+ ), # make lowercase
+ ListVariable(
+ 'shared', 'libraries to build as shared libraries', 'all', names=list_of_libs
+ ),
+ PackageVariable('x11', 'use X11 installed here (yes = search some places)', 'yes'),
PathVariable('qtdir', 'where the root of Qt is installed', qtdir),
- PathVariable('qt_libraries',
- 'where the Qt library is installed',
- r'%(libdirvar)s'),
- )
+ PathVariable('qt_libraries', 'where the Qt library is installed', r'%(libdirvar)s'),
+)
env = Environment(variables=opts)
Help(opts.GenerateHelpText(env))
@@ -96,11 +110,11 @@ scons: Reading SConscript files ...
scons: done reading SConscript files.
warnings: compilation with -Wall and similiar (yes|no)
- default: 1
+ default: True
actual: %(str_True)s
profile: create profiling informations (yes|no)
- default: 0
+ default: False
actual: %(str_False)s
debug: debug output and symbols (yes|no|full)