|
1 |
| -#!/usr/bin/env python |
2 |
| -# |
3 |
| -# __COPYRIGHT__ |
4 |
| -# |
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: |
12 |
| -# |
13 |
| -# The above copyright notice and this permission notice shall be included |
14 |
| -# in all copies or substantial portions of the Software. |
15 |
| -# |
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. |
23 |
| - |
24 |
| -""" |
25 |
| -Verify the help text when the AddOption() function is used (and when |
26 |
| -it's not). |
27 |
| -""" |
28 |
| - |
29 |
| -__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" |
30 |
| - |
31 |
| -import TestSCons |
32 |
| - |
33 |
| -test = TestSCons.TestSCons() |
34 |
| - |
35 |
| -test.write('SConstruct', """\ |
36 |
| -env = Environment() |
37 |
| -AddOption('--force', |
38 |
| - action="store_true", |
39 |
| - help='force installation (overwrite existing files)') |
40 |
| -AddOption('--prefix', |
41 |
| - nargs=1, |
42 |
| - dest='prefix', |
43 |
| - action='store', |
44 |
| - type='string', |
45 |
| - metavar='DIR', |
46 |
| - help='installation prefix') |
47 |
| -""") |
48 |
| - |
49 |
| -expected_lines = [ |
50 |
| - 'Local Options:', |
51 |
| - ' --force force installation (overwrite existing files)', |
52 |
| - ' --prefix=DIR installation prefix', |
53 |
| -] |
54 |
| - |
55 |
| -test.run(arguments = '-h') |
56 |
| -lines = test.stdout().split('\n') |
57 |
| -missing = [e for e in expected_lines if e not in lines] |
58 |
| - |
59 |
| -if missing: |
60 |
| - print("====== STDOUT:") |
61 |
| - print(test.stdout()) |
62 |
| - print("====== Missing the following lines in the above AddOption() help output:") |
63 |
| - print("\n".join(missing)) |
64 |
| - test.fail_test() |
65 |
| - |
66 |
| -test.unlink('SConstruct') |
67 |
| - |
68 |
| -test.run(arguments = '-h') |
69 |
| -lines = test.stdout().split('\n') |
70 |
| -unexpected = [e for e in expected_lines if e in lines] |
71 |
| - |
72 |
| -if unexpected: |
73 |
| - print("====== STDOUT:") |
74 |
| - print(test.stdout()) |
75 |
| - print("====== Unexpected lines in the above non-AddOption() help output:") |
76 |
| - print("\n".join(unexpected)) |
77 |
| - test.fail_test() |
78 |
| - |
79 |
| -test.pass_test() |
80 |
| - |
81 |
| -# Local Variables: |
82 |
| -# tab-width:4 |
83 |
| -# indent-tabs-mode:nil |
84 |
| -# End: |
85 |
| -# vim: set expandtab tabstop=4 shiftwidth=4: |
| 1 | +#!/usr/bin/env python |
| 2 | +# |
| 3 | +# MIT License |
| 4 | +# |
| 5 | +# Copyright The SCons Foundation |
| 6 | +# |
| 7 | +# Permission is hereby granted, free of charge, to any person obtaining |
| 8 | +# a copy of this software and associated documentation files (the |
| 9 | +# "Software"), to deal in the Software without restriction, including |
| 10 | +# without limitation the rights to use, copy, modify, merge, publish, |
| 11 | +# distribute, sublicense, and/or sell copies of the Software, and to |
| 12 | +# permit persons to whom the Software is furnished to do so, subject to |
| 13 | +# the following conditions: |
| 14 | +# |
| 15 | +# The above copyright notice and this permission notice shall be included |
| 16 | +# in all copies or substantial portions of the Software. |
| 17 | +# |
| 18 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY |
| 19 | +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE |
| 20 | +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 21 | +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 22 | +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 23 | +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 24 | +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 25 | + |
| 26 | +import TestSCons |
| 27 | + |
| 28 | +test = TestSCons.TestSCons() |
| 29 | + |
| 30 | +test.write('SConstruct', """\ |
| 31 | +DefaultEnvironment(tools=[]) |
| 32 | +env = Environment(tools=[]) |
| 33 | +AddOption('--force', |
| 34 | + action="store_true", |
| 35 | + help='force installation (overwrite existing files)') |
| 36 | +AddOption('--prefix', |
| 37 | + nargs=1, |
| 38 | + dest='prefix', |
| 39 | + action='store', |
| 40 | + type='string', |
| 41 | + metavar='DIR', |
| 42 | + help='installation prefix') |
| 43 | +""") |
| 44 | + |
| 45 | +expected_lines = [ |
| 46 | + 'Local Options:', |
| 47 | + ' --force force installation (overwrite existing files)', |
| 48 | + ' --prefix=DIR installation prefix', |
| 49 | +] |
| 50 | + |
| 51 | +test.run(arguments = '-h') |
| 52 | +lines = test.stdout().split('\n') |
| 53 | +missing = [e for e in expected_lines if e not in lines] |
| 54 | + |
| 55 | +if missing: |
| 56 | + print("====== STDOUT:") |
| 57 | + print(test.stdout()) |
| 58 | + print("====== Missing the following lines in the above AddOption() help output:") |
| 59 | + print("\n".join(missing)) |
| 60 | + test.fail_test() |
| 61 | + |
| 62 | +test.unlink('SConstruct') |
| 63 | + |
| 64 | +test.run(arguments = '-h') |
| 65 | +lines = test.stdout().split('\n') |
| 66 | +unexpected = [e for e in expected_lines if e in lines] |
| 67 | + |
| 68 | +if unexpected: |
| 69 | + print("====== STDOUT:") |
| 70 | + print(test.stdout()) |
| 71 | + print("====== Unexpected lines in the above non-AddOption() help output:") |
| 72 | + print("\n".join(unexpected)) |
| 73 | + test.fail_test() |
| 74 | + |
| 75 | +test.pass_test() |
| 76 | + |
| 77 | +# Local Variables: |
| 78 | +# tab-width:4 |
| 79 | +# indent-tabs-mode:nil |
| 80 | +# End: |
| 81 | +# vim: set expandtab tabstop=4 shiftwidth=4: |
0 commit comments