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 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
33 test = TestSCons.TestSCons(match = TestCmd.match_re_dotall)
35 # How to warn about deprecated features (whenever we have one again).
37 #test.write("SConstruct","""
38 #b=Builder(name='b', action='foo')
41 #test.run(arguments='.', stderr=r"""
42 #scons: warning: The use of the 'name' parameter to Builder\(\) is deprecated\.
43 #File "SConstruct", line 2, in \?
46 #test.run(arguments='--warn=no-deprecated .', stderr='')
48 #test.run(arguments='--warn=no-all .', stderr='')
50 #test.run(arguments='--warn=no-all --warn=deprecated .', stderr=r"""
51 #scons: warning: The use of the 'name' parameter to Builder\(\) is deprecated\.
52 #File "SConstruct", line 2, in \?
57 test.write("SConstruct", """\
60 def build(target, source, env):
64 env['BUILDERS']['test'] = Builder(action=build,
65 source_scanner=SCons.Defaults.ObjSourceScan)
66 env.test(target='foo', source='foo.c')
69 test.write("foo.c","""
70 #include "not_there.h"
73 test.run(arguments='--warn=dependency .', stderr=r"""
74 scons: warning: No dependency generated for file: not_there\.h \(included from: foo\.c\) \-\- file not found
75 """ + TestSCons.file_expr)
77 test.run(arguments='--warn=all .', stderr=r"""
78 scons: warning: No dependency generated for file: not_there\.h \(included from: foo\.c\) \-\- file not found
79 """ + TestSCons.file_expr)
81 test.run(arguments='--warn=all --warn=no-dependency .', stderr="")
83 test.run(arguments='--warn=no-dependency --warn=all .', stderr=r"""
84 scons: warning: No dependency generated for file: not_there\.h \(included from: foo\.c\) \-\- file not found
85 """ + TestSCons.file_expr)
89 test.write("SConstruct", """\
90 def build(target, source, env):
94 env['BUILDERS']['test'] = Builder(action=build)
95 env.test(target='foo', source='foo.c')
96 SConscript('no_such_file')
99 test.run(arguments = '--warn=missing-sconscript .', stderr = r"""
100 scons: warning: Ignoring missing SConscript 'no_such_file'
101 """ + TestSCons.file_expr)
103 test.run(arguments = '--warn=no-missing-sconscript .', stderr = "")
107 test.write('SConstruct', """
108 def build(env, target, source):
109 file = open(str(target[0]), 'wb')
111 file.write(open(str(s), 'rb').read())
113 B = Builder(action=build, multi=1)
114 env = Environment(BUILDERS = { 'B' : B })
115 env2 = env.Clone(DIFFERENT_VARIABLE = 'true')
116 env.B(target = 'file1.out', source = 'file1a.in')
117 env2.B(target = 'file1.out', source = 'file1b.in')
120 test.write('file1a.in', 'file1a.in\n')
121 test.write('file1b.in', 'file1b.in\n')
123 test.run(arguments='file1.out',
125 scons: warning: Two different environments were specified for target file1.out,
126 \tbut they appear to have the same action: build\(target, source, env\)
127 """ + TestSCons.file_expr)
129 test.must_match('file1.out', "file1a.in\nfile1b.in\n")
131 test.run(arguments='--warn=duplicate-environment file1.out',
133 scons: warning: Two different environments were specified for target file1.out,
134 \tbut they appear to have the same action: build\(target, source, env\)
135 """ + TestSCons.file_expr)
137 test.run(arguments='--warn=no-duplicate-environment file1.out')
141 test.write('SConstruct', """
142 def build(env, target, source):
143 file = open(str(target[0]), 'wb')
145 file.write(open(str(s), 'rb').read())
147 B = Builder(action=build, multi=1)
148 env = Environment(BUILDERS = { 'B' : B })
149 env.B(targets = 'file3a.out', source = 'file3a.in')
150 env.B(target = 'file3b.out', sources = 'file3b.in')
153 test.write('file3a.in', 'file3a.in\n')
154 test.write('file3b.out', 'file3b.out\n')
156 test.run(arguments='.',
158 scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\?
159 """ + TestSCons.file_expr + r"""
160 scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\?
161 """ + TestSCons.file_expr)
163 test.must_match(['file3a'], 'file3a.in\n')
164 test.must_match(['file3b'], 'file3b.out\n')
166 test.run(arguments='--warn=misleading-keywords .',
168 scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\?
169 """ + TestSCons.file_expr + r"""\
170 scons: warning: Did you mean to use `(target|source)' instead of `(targets|sources)'\?
171 """ + TestSCons.file_expr)
173 test.run(arguments='--warn=no-misleading-keywords .')