summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMats Wichmann <mats@linux.com>2021-05-10 16:19:21 (GMT)
committerMats Wichmann <mats@linux.com>2021-05-10 16:19:21 (GMT)
commit29e5392ee9c7d99a01855ec47c492923d532c190 (patch)
treec8e56fa55f54b7d3446728b462fb43036ab65744 /test
parent88e9a2184bc28c6098abb48cb3c6b2a8e2ed94e8 (diff)
downloadSCons-29e5392ee9c7d99a01855ec47c492923d532c190.zip
SCons-29e5392ee9c7d99a01855ec47c492923d532c190.tar.gz
SCons-29e5392ee9c7d99a01855ec47c492923d532c190.tar.bz2
Add tests for SetOption failing on illegal options and values
Signed-off-by: Mats Wichmann <mats@linux.com>
Diffstat (limited to 'test')
-rw-r--r--test/GetOption/BadSetOption.py65
-rw-r--r--test/GetOption/GetSetOption.py (renamed from test/GetSetOption.py)7
-rw-r--r--test/GetOption/help.py7
3 files changed, 71 insertions, 8 deletions
diff --git a/test/GetOption/BadSetOption.py b/test/GetOption/BadSetOption.py
new file mode 100644
index 0000000..997ff15
--- /dev/null
+++ b/test/GetOption/BadSetOption.py
@@ -0,0 +1,65 @@
+#!/usr/bin/env python
+#
+# 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
+# "Software"), to deal in the Software without restriction, including
+# without limitation the rights to use, copy, modify, merge, publish,
+# distribute, sublicense, and/or sell copies of the Software, and to
+# permit persons to whom the Software is furnished to do so, subject to
+# the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
+# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+# 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.
+
+"""
+Test that invalid SetOption calls generate expected errors.
+"""
+
+import TestSCons
+from TestSCons import file_expr
+
+test = TestSCons.TestSCons()
+
+badopts = (
+ ("no_such_var", True, "This option is not settable from a SConscript file: no_such_var"),
+ ("num_jobs", -22, "A positive integer is required: -22"),
+ ("max_drift", "'Foo'", "An integer is required: 'Foo'"),
+ ("duplicate", "'cookie'", "Not a valid duplication style: cookie"),
+ ("diskcheck", "'off'", "Not a valid diskcheck value: off"),
+ ("md5_chunksize", "'big'", "An integer is required: 'big'"),
+ ("hash_chunksize", "'small'", "An integer is required: 'small'"),
+)
+
+for opt, value, expect in badopts:
+ SConstruct = "SC-" + opt
+ test.write(
+ SConstruct,
+ """\
+DefaultEnvironment(tools=[])
+SetOption("%(opt)s", %(value)s)
+"""
+ % locals(),
+ )
+ expect = r"scons: *** %s" % expect
+ test.run(arguments='-Q -f %s .' % SConstruct, stderr=None, status=2)
+ test.must_contain_all(test.stderr(), expect)
+
+test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4:
diff --git a/test/GetSetOption.py b/test/GetOption/GetSetOption.py
index 929f8d0..e773ec6 100644
--- a/test/GetSetOption.py
+++ b/test/GetOption/GetSetOption.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 getting and setting options through global functions
diff --git a/test/GetOption/help.py b/test/GetOption/help.py
index f83dc54..ebca99f 100644
--- a/test/GetOption/help.py
+++ b/test/GetOption/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 use of GetOption('help') to short-circuit work.