3 # Copyright The SCons Foundation
5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 Test ValidateOptions().
30 test
= TestSCons
.TestSCons()
31 # ref: test/fixture/SConstruct-check-valid-options
32 test
.file_fixture('fixture/SConstruct-check-valid-options', 'SConstruct')
34 # Should see "This is in SConstruct" because all options specified (none)
35 # are valid and so ValidatedOptions() won't exit before it's printed.
37 test
.must_contain_single_instance_of(test
.stdout(), ["This is in SConstruct"])
39 # Should see "This is in SConstruct" because all options specified
40 # (--testing=abc) are valid and so ValidatedOptions() won't exit before
42 test
.run(arguments
="--testing=abc")
43 test
.must_contain_single_instance_of(test
.stdout(), ["This is in SConstruct"])
45 # Should not see "This is in SConstruct" because the option specified
46 # (--garbage=xyz) is invalid and so ValidatedOptions() will exit
47 # before it's printed.
49 arguments
="--garbage=xyz",
51 stderr
=".*SCons Error: no such option: --garbage.*",
52 match
=TestSCons
.match_re_dotall
,
55 ("This is in SConstruct" in test
.stdout()),
56 message
='"This is in SConstruct" should not be output. This means ValidateOptions() did not error out before this was printed',
59 # Now we'll test having ValidateOptions raise a SConsBadOptionError exception
61 arguments
="--garbage=xyz raise=1",
63 stderr
=".*SConsBadOptionError: no such option: no such option: --garbage.*",
64 match
=TestSCons
.match_re_dotall
,
67 ("This is in SConstruct" in test
.stdout()),
68 message
='"This is in SConstruct" should not be output. This means ValidateOptions() did not error out before this was printed',
71 # Now we'll test having ValidateOptions raise a SConsBadOptionError
72 # exception and catching that exception
74 arguments
="--garbage=xyz raise=2",
76 stdout
=".*Parser is SConsOptionParser: True.*Message is. no such option. --garbage.*",
77 match
=TestSCons
.match_re_dotall
,
80 ("This is in SConstruct" in test
.stdout()),
81 message
='"This is in SConstruct" should not be output. This means ValidateOptions() did not error out before this was printed',
88 # indent-tabs-mode:nil
90 # vim: set expandtab tabstop=4 shiftwidth=4: