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__"
31 _python_ = TestSCons._python_
33 test = TestSCons.TestSCons()
35 isStackSizeAvailable = False
38 isStackSizeAvailable = hasattr(threading,'stack_size')
42 test.subdir('work1', 'work2')
44 test.write('build.py', r"""
46 contents = open(sys.argv[2], 'rb').read()
47 file = open(sys.argv[1], 'wb')
53 test.write(['work1', 'SConstruct'], """
54 B = Builder(action = r'%(_python_)s ../build.py $TARGETS $SOURCES')
55 env = Environment(BUILDERS = { 'B' : B })
56 f1 = env.B(target = 'f1.out', source = 'f1.in')
57 f2 = env.B(target = 'f2.out', source = 'f2.in')
61 test.write(['work1', 'f1.in'], "f1.in\n")
62 test.write(['work1', 'f2.in'], "f2.in\n")
65 test.write(['work2', 'SConstruct'], """
66 SetOption('stack_size', 128)
67 B = Builder(action = r'%(_python_)s ../build.py $TARGETS $SOURCES')
68 env = Environment(BUILDERS = { 'B' : B })
69 f1 = env.B(target = 'f1.out', source = 'f1.in')
70 f2 = env.B(target = 'f2.out', source = 'f2.in')
74 test.write(['work2', 'f1.in'], "f1.in\n")
75 test.write(['work2', 'f2.in'], "f2.in\n")
79 expected_stdout = test.wrap_stdout("""\
80 %(_python_)s ../build.py f1.out f1.in
81 %(_python_)s ../build.py f2.out f2.in
84 re_expected_stdout = string.replace(expected_stdout, '\\', '\\\\')
86 expect_unsupported = """
87 scons: warning: Setting stack size is unsupported by this version of Python:
88 (('module' object|'threading' module) has no attribute 'stack_size'|stack_size)
94 # Test without any options
96 test.run(chdir='work1',
98 stdout=expected_stdout,
100 test.must_exist(['work1', 'f1.out'])
101 test.must_exist(['work1', 'f2.out'])
103 test.run(chdir='work1',
105 test.must_not_exist(['work1', 'f1.out'])
106 test.must_not_exist(['work1', 'f2.out'])
111 test.run(chdir='work1',
113 stdout=expected_stdout,
115 test.must_exist(['work1', 'f1.out'])
116 test.must_exist(['work1', 'f2.out'])
118 test.run(chdir='work1',
119 arguments = '-j2 -c .')
120 test.must_not_exist(['work1', 'f1.out'])
121 test.must_not_exist(['work1', 'f2.out'])
125 # Test with --stack-size
127 test.run(chdir='work1',
128 arguments = '--stack-size=128 .',
129 stdout=expected_stdout,
131 test.must_exist(['work1', 'f1.out'])
132 test.must_exist(['work1', 'f2.out'])
134 test.run(chdir='work1',
135 arguments = '--stack-size=128 -c .')
136 test.must_not_exist(['work1', 'f1.out'])
137 test.must_not_exist(['work1', 'f2.out'])
140 # Test with SetOption('stack_size', 128)
142 test.run(chdir='work2',
144 stdout=expected_stdout,
146 test.must_exist(['work2', 'f1.out'])
147 test.must_exist(['work2', 'f2.out'])
149 test.run(chdir='work2',
150 arguments = '--stack-size=128 -c .')
151 test.must_not_exist(['work2', 'f1.out'])
152 test.must_not_exist(['work2', 'f2.out'])
154 if isStackSizeAvailable:
156 # Test with -j2 --stack-size=128
158 test.run(chdir='work1',
159 arguments = '-j2 --stack-size=128 .',
160 stdout=expected_stdout,
162 test.must_exist(['work1', 'f1.out'])
163 test.must_exist(['work1', 'f2.out'])
165 test.run(chdir='work1',
166 arguments = '-j2 --stack-size=128 -c .')
167 test.must_not_exist(['work1', 'f1.out'])
168 test.must_not_exist(['work1', 'f2.out'])
171 # Test with -j2 --stack-size=16
173 test.run(chdir='work1',
174 arguments = '-j2 --stack-size=16 .',
175 match=TestSCons.match_re,
176 stdout=re_expected_stdout,
178 scons: warning: Setting stack size failed:
179 size not valid: 16384 bytes
182 test.must_exist(['work1', 'f1.out'])
183 test.must_exist(['work1', 'f2.out'])
185 test.run(chdir='work1',
186 arguments = '-j2 --stack-size=16 -c .',
187 match=TestSCons.match_re,
189 scons: warning: Setting stack size failed:
190 size not valid: 16384 bytes
193 test.must_not_exist(['work1', 'f1.out'])
194 test.must_not_exist(['work1', 'f2.out'])
197 # Test with -j2 SetOption('stack_size', 128)
199 test.run(chdir='work2',
201 stdout=expected_stdout,
203 test.must_exist(['work2', 'f1.out'])
204 test.must_exist(['work2', 'f2.out'])
206 test.run(chdir='work2',
207 arguments = '-j2 -c .')
208 test.must_not_exist(['work2', 'f1.out'])
209 test.must_not_exist(['work2', 'f2.out'])
212 # Test with -j2 --stack-size=128 --warn=no-stack-size
214 test.run(chdir='work1',
215 arguments = '-j2 --stack-size=128 --warn=no-stack-size .',
216 stdout=expected_stdout,
218 test.must_exist(['work1', 'f1.out'])
219 test.must_exist(['work1', 'f2.out'])
221 test.run(chdir='work1',
222 arguments = '-j2 --stack-size=128 --warn=no-stack-size -c .')
223 test.must_not_exist(['work1', 'f1.out'])
224 test.must_not_exist(['work1', 'f2.out'])
227 # Test with -j2 --stack-size=16 --warn=no-stack-size
229 test.run(chdir='work1',
230 arguments = '-j2 --stack-size=16 --warn=no-stack-size .',
231 stdout=expected_stdout,
233 test.must_exist(['work1', 'f1.out'])
234 test.must_exist(['work1', 'f2.out'])
236 test.run(chdir='work1',
237 arguments = '-j2 --stack-size=16 --warn=no-stack-size -c .')
238 test.must_not_exist(['work1', 'f1.out'])
239 test.must_not_exist(['work1', 'f2.out'])
242 # Test with -j2 --warn=no-stack-size SetOption('stack_size', 128)
244 test.run(chdir='work2',
245 arguments = '-j2 --warn=no-stack-size .',
246 stdout=expected_stdout,
248 test.must_exist(['work2', 'f1.out'])
249 test.must_exist(['work2', 'f2.out'])
251 test.run(chdir='work2',
252 arguments = '-j2 --warn=no-stack-size -c .')
253 test.must_not_exist(['work2', 'f1.out'])
254 test.must_not_exist(['work2', 'f2.out'])
259 # Test with -j2 --stack-size=128
261 test.run(chdir='work1',
262 arguments = '-j2 --stack-size=128 .',
263 match=TestSCons.match_re,
264 stdout=re_expected_stdout,
265 stderr=expect_unsupported)
266 test.must_exist(['work1', 'f1.out'])
267 test.must_exist(['work1', 'f2.out'])
269 test.run(chdir='work1',
270 arguments = '-j2 --stack-size=128 -c .',
271 match=TestSCons.match_re,
272 stderr=expect_unsupported)
273 test.must_not_exist(['work1', 'f1.out'])
274 test.must_not_exist(['work1', 'f2.out'])
277 # Test with -j2 --stack-size=16
279 test.run(chdir='work1',
280 arguments = '-j2 --stack-size=16 .',
281 match=TestSCons.match_re,
282 stdout=re_expected_stdout,
283 stderr=expect_unsupported)
284 test.must_exist(['work1', 'f1.out'])
285 test.must_exist(['work1', 'f2.out'])
287 test.run(chdir='work1',
288 arguments = '-j2 --stack-size=16 -c .',
289 match=TestSCons.match_re,
290 stderr=expect_unsupported)
291 test.must_not_exist(['work1', 'f1.out'])
292 test.must_not_exist(['work1', 'f2.out'])
295 # Test with -j2 SetOption('stack_size', 128)
297 test.run(chdir='work2',
299 match=TestSCons.match_re,
300 stdout=re_expected_stdout,
301 stderr=expect_unsupported)
302 test.must_exist(['work2', 'f1.out'])
303 test.must_exist(['work2', 'f2.out'])
305 test.run(chdir='work2',
306 arguments = '-j2 -c .',
307 match=TestSCons.match_re,
308 stderr=expect_unsupported)
309 test.must_not_exist(['work2', 'f1.out'])
310 test.must_not_exist(['work2', 'f2.out'])
313 # Test with -j2 --stack-size=128 --warn=no-stack-size
315 test.run(chdir='work1',
316 arguments = '-j2 --stack-size=128 --warn=no-stack-size .',
317 stdout=expected_stdout,
319 test.must_exist(['work1', 'f1.out'])
320 test.must_exist(['work1', 'f2.out'])
322 test.run(chdir='work1',
323 arguments = '-j2 --stack-size=128 --warn=no-stack-size -c .')
324 test.must_not_exist(['work1', 'f1.out'])
325 test.must_not_exist(['work1', 'f2.out'])
328 # Test with -j2 --stack-size=16 --warn=no-stack-size
330 test.run(chdir='work1',
331 arguments = '-j2 --stack-size=16 --warn=no-stack-size .',
332 stdout=expected_stdout,
334 test.must_exist(['work1', 'f1.out'])
335 test.must_exist(['work1', 'f2.out'])
337 test.run(chdir='work1',
338 arguments = '-j2 --stack-size=16 --warn=no-stack-size -c .')
339 test.must_not_exist(['work1', 'f1.out'])
340 test.must_not_exist(['work1', 'f2.out'])
343 # Test with -j2 --warn=no-stack-size SetOption('stack_size', 128)
345 test.run(chdir='work2',
346 arguments = '-j2 --warn=no-stack-size .',
347 stdout=expected_stdout,
349 test.must_exist(['work2', 'f1.out'])
350 test.must_exist(['work2', 'f2.out'])
352 test.run(chdir='work2',
353 arguments = '-j2 --warn=no-stack-size -c .')
354 test.must_not_exist(['work2', 'f1.out'])
355 test.must_not_exist(['work2', 'f2.out'])