Merge pull request #4359 from mwichmann/maint/dead-sigstuff
[scons.git] / test / ValidateOptions.py
blob5dff386e265ce3c31f3080d57657880efbd93cea
1 # MIT License
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.
24 """
25 Test ValidateOptions().
26 """
28 import TestSCons
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.
36 test.run()
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
41 # it's printed.
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.
48 test.run(
49 arguments="--garbage=xyz",
50 status=2,
51 stderr=".*SCons Error: no such option: --garbage.*",
52 match=TestSCons.match_re_dotall,
54 test.fail_test(
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
60 test.run(
61 arguments="--garbage=xyz raise=1",
62 status=2,
63 stderr=".*SConsBadOptionError: no such option: no such option: --garbage.*",
64 match=TestSCons.match_re_dotall,
66 test.fail_test(
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
73 test.run(
74 arguments="--garbage=xyz raise=2",
75 status=3,
76 stdout=".*Parser is SConsOptionParser: True.*Message is. no such option. --garbage.*",
77 match=TestSCons.match_re_dotall,
79 test.fail_test(
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',
84 test.pass_test()
86 # Local Variables:
87 # tab-width:4
88 # indent-tabs-mode:nil
89 # End:
90 # vim: set expandtab tabstop=4 shiftwidth=4: