[ci skip] Add note that this change may break SetOption() + ninja usage with fix
[scons.git] / test / Help.py
bloba090d42125e82d8e290542c92a31a9ea1000e781
1 #!/usr/bin/env python
3 # MIT License
5 # Copyright The SCons Foundation
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:
15 # The above copyright notice and this permission notice shall be included
16 # in all copies or substantial portions of the Software.
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.
26 import TestSCons
28 test = TestSCons.TestSCons()
30 wpath = test.workpath()
32 test.write('SConstruct', r"""
33 Help("Help text\ngoes here.\n")
34 """)
36 expect = """scons: Reading SConscript files ...
37 scons: done reading SConscript files.
38 Help text
39 goes here.
41 Use scons -H for help about SCons built-in command-line options.
42 """
44 test.run(arguments = '-h', stdout = expect)
46 test.write('SConstruct', r"""
47 env = Environment(MORE='more', HELP='help')
48 env.Help("\nEven $MORE\n$HELP text!\n")
49 """)
51 expect = """scons: Reading SConscript files ...
52 scons: done reading SConscript files.
54 Even more
55 help text!
57 Use scons -H for help about SCons built-in command-line options.
58 """
60 test.run(arguments = '-h', stdout = expect)
62 test.write('SConstruct', r"""
63 Help('\nMulti')
64 Help('line\n')
65 Help('''\
66 help
67 text!
68 ''')
69 """)
71 expect = """\
72 scons: Reading SConscript files ...
73 scons: done reading SConscript files.
75 Multiline
76 help
77 text!
79 Use scons -H for help about SCons built-in command-line options.
80 """
82 test.run(arguments = '-h', stdout = expect)
84 # Bug #2831 - append flag to Help doesn't wipe out addoptions and variables used together
85 test.write('SConstruct', r"""
87 AddOption(
88 '--debugging',
89 dest='debugging',
90 action='store_true',
91 default=False,
92 metavar='BDEBUGGING',
93 help='Compile with debugging symbols',
96 vars = Variables()
97 vars.Add(ListVariable('buildmod', 'List of modules to build', 'none', ['python']))
98 DefaultEnvironment(tools=[])
99 env = Environment()
100 Help(vars.GenerateHelpText(env), append=True)
101 """)
103 expect = ".*--debugging.*Compile with debugging symbols.*buildmod: List of modules to build.*"
104 test.run(arguments = '-h', stdout = expect, match=TestSCons.match_re_dotall)
106 # Bug 2831
107 # This test checks to verify that append=False doesn't include anything
108 # but the expected help for the specified Variable()
110 test.write('SConstruct', r"""
111 AddOption(
112 '--debugging',
113 dest='debugging',
114 action='store_true',
115 default=False,
116 metavar='BDEBUGGING',
117 help='Compile with debugging symbols',
120 vars = Variables()
121 vars.Add(ListVariable('buildmod', 'List of modules to build', 'none', ['python']))
123 DefaultEnvironment(tools=[])
124 env = Environment()
126 Help(vars.GenerateHelpText(env), append=False)
127 """)
129 expect = """\
130 scons: Reading SConscript files ...
131 scons: done reading SConscript files.
133 buildmod: List of modules to build
134 (all|none|comma-separated list of names)
135 allowed names: python
136 default: none
137 actual: None
139 Use scons -H for help about SCons built-in command-line options.
142 test.run(arguments='-h', stdout=expect)
144 # Enhancement: keep_local flag saves the AddOption help,
145 # but not SCons' own help.
146 test.write('SConstruct', r"""
147 AddOption(
148 '--debugging',
149 dest='debugging',
150 action='store_true',
151 default=False,
152 metavar='BDEBUGGING',
153 help='Compile with debugging symbols',
156 vars = Variables()
157 vars.Add(ListVariable('buildmod', 'List of modules to build', 'none', ['python']))
159 DefaultEnvironment(tools=[])
160 env = Environment()
162 Help(vars.GenerateHelpText(env), append=True, keep_local=True)
163 """)
165 expect = """\
166 scons: Reading SConscript files ...
167 scons: done reading SConscript files.
168 Local Options:
169 --debugging Compile with debugging symbols
171 buildmod: List of modules to build
172 (all|none|comma-separated list of names)
173 allowed names: python
174 default: none
175 actual: None
177 Use scons -H for help about SCons built-in command-line options.
180 test.run(arguments='-h', stdout=expect)
183 test.pass_test()
185 # Local Variables:
186 # tab-width:4
187 # indent-tabs-mode:nil
188 # End:
189 # vim: set expandtab tabstop=4 shiftwidth=4: