diff options
author | William Deegan <bill@baddogconsulting.com> | 2021-05-17 00:52:19 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-17 00:52:19 (GMT) |
commit | 0d9a99d630169277689e95e39ae64ccf9b9215bf (patch) | |
tree | 53994872c71922beffe0b40f84450347c245415d /test | |
parent | a657eb4c10def8d248d5f9d3c70d06a2aeb64283 (diff) | |
parent | 91d46fc9be159ad0455b03eb00916bee3d2c3ee6 (diff) | |
download | SCons-0d9a99d630169277689e95e39ae64ccf9b9215bf.zip SCons-0d9a99d630169277689e95e39ae64ccf9b9215bf.tar.gz SCons-0d9a99d630169277689e95e39ae64ccf9b9215bf.tar.bz2 |
Merge pull request #3948 from mwichmann/setoption-tests
Add tests for SetOption failing on illegal options and values
Diffstat (limited to 'test')
-rw-r--r-- | test/GetOption/BadSetOption.py | 64 | ||||
-rw-r--r-- | test/GetOption/GetSetOption.py (renamed from test/GetSetOption.py) | 10 | ||||
-rw-r--r-- | test/GetOption/help.py | 13 |
3 files changed, 75 insertions, 12 deletions
diff --git a/test/GetOption/BadSetOption.py b/test/GetOption/BadSetOption.py new file mode 100644 index 0000000..7b0a33d --- /dev/null +++ b/test/GetOption/BadSetOption.py @@ -0,0 +1,64 @@ +#!/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 + +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..3ab3e7b 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 @@ -33,7 +32,8 @@ import TestSCons test = TestSCons.TestSCons() test.write('SConstruct', """ -env = Environment() +DefaultEnvironment(tools=[]) +env = Environment(tools=[]) option_list = ['clean', 'implicit_cache', 'max_drift', 'num_jobs'] val = 1 for option in option_list: diff --git a/test/GetOption/help.py b/test/GetOption/help.py index f83dc54..4db4bc8 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. @@ -40,14 +39,14 @@ else: print("no help for you") """) -test.run(arguments = '-q -Q', stdout = "no help for you\n") +test.run(arguments='-q -Q', stdout="no help for you\n") expect = "GetOption('help') set" -test.run(arguments = '-q -Q -h') +test.run(arguments='-q -Q -h') test.fail_test(test.stdout().split('\n')[0] != expect) -test.run(arguments = '-q -Q --help') +test.run(arguments='-q -Q --help') test.fail_test(test.stdout().split('\n')[0] != expect) test.pass_test() |