Source

SCons / test / explain.py

Steven Knight 13e8680 





























Steven Knight a8e4e30 

Steven Knight 13e8680 


Steven Knight e2b47d1 
Steven Knight 13e8680 


Steven Knight a8e4e30 
Steven Knight e9b7ae5 

Steven Knight 13e8680 
Steven Knight a8e4e30 




Steven Knight 13e8680 























Steven Knight a8e4e30 
Steven Knight 13e8680 













Steven Knight e2b47d1 
Steven Knight 13e8680 










Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight a8e4e30 

Steven Knight 2a5303e 
Steven Knight a8e4e30 


Steven Knight 13e8680 



Steven Knight e2b47d1 


Steven Knight 13e8680 
Steven Knight a8e4e30 
Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight a8e4e30 

Steven Knight 13e8680 




Steven Knight a8e4e30 


Steven Knight 13e8680 
Steven Knight a8e4e30 
Steven Knight 13e8680 
Steven Knight a8e4e30 
Steven Knight 13e8680 





Steven Knight a8e4e30 
Steven Knight 13e8680 
Steven Knight a8e4e30 


Steven Knight 13e8680 
Steven Knight a8e4e30 
Steven Knight 13e8680 





Steven Knight a8e4e30 
Steven Knight 13e8680 
Steven Knight e45a25b 




Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight e45a25b 







Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight e45a25b 
Steven Knight e2b47d1 



Steven Knight 13e8680 
Steven Knight a8e4e30 

Steven Knight 13e8680 




Steven Knight a8e4e30 


Steven Knight 13e8680 









Steven Knight a8e4e30 



Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight 13e8680 


Steven Knight e2b47d1 
Steven Knight e45a25b 


Steven Knight 13e8680 
Steven Knight e45a25b 

Steven Knight e2b47d1 



Steven Knight 13e8680 
Steven Knight a8e4e30 

Steven Knight 13e8680 




Steven Knight a8e4e30 

Steven Knight 13e8680 







Steven Knight a8e4e30 
Steven Knight 13e8680 



Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight e2b47d1 



Steven Knight 13e8680 
Steven Knight a8e4e30 
Steven Knight 13e8680 

Steven Knight a8e4e30 
Steven Knight 13e8680 



Steven Knight e2b47d1 
Steven Knight 13e8680 
Steven Knight e2b47d1 



Steven Knight 13e8680 
Steven Knight a8e4e30 
Steven Knight 13e8680 

Steven Knight a8e4e30 
Steven Knight 13e8680 



Steven Knight e2b47d1 
Steven Knight 13e8680 


Steven Knight e2b47d1 



Steven Knight 13e8680 
Steven Knight a8e4e30 
Steven Knight 13e8680 

Steven Knight a8e4e30 
Steven Knight 13e8680 
Steven Knight 64b8b5e 

Steven Knight e2b47d1 

Steven Knight e45a25b 
Steven Knight 64b8b5e 
Steven Knight e2b47d1 
Steven Knight 64b8b5e 
Steven Knight e2b47d1 









Steven Knight 64b8b5e 









Steven Knight e2b47d1 

Steven Knight e45a25b 
Steven Knight 64b8b5e 
Steven Knight e2b47d1 
Steven Knight 64b8b5e 
Steven Knight e2b47d1 











Steven Knight 64b8b5e 







Steven Knight e2b47d1 


Steven Knight e45a25b 
Steven Knight 13e8680 
Steven Knight e2b47d1 
Steven Knight 64b8b5e 
Steven Knight e2b47d1 




Steven Knight 13e8680 
Steven Knight a8e4e30 












Steven Knight 13e8680 
Steven Knight 2a5303e 








Steven Knight e2b47d1 
Steven Knight 2a5303e 

Steven Knight e45a25b 
Steven Knight 2a5303e 































































Steven Knight e45a25b 



Steven Knight 2a5303e 

Steven Knight e2b47d1 
Steven Knight 2a5303e 
Steven Knight e2b47d1 
Steven Knight 2a5303e 


Steven Knight e2b47d1 
Steven Knight e45a25b 


Steven Knight 2a5303e 
Steven Knight e45a25b 

Steven Knight e2b47d1 
Steven Knight e45a25b 
Steven Knight 2a5303e 
















Steven Knight e9b7ae5 











Steven Knight 83d97c4 


Steven Knight e9b7ae5 
































Steven Knight 64b8b5e 


Steven Knight e9b7ae5 
Steven Knight 83d97c4 
Steven Knight e9b7ae5 
Steven Knight 64b8b5e 
Steven Knight e9b7ae5 




Steven Knight 13e8680 
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
#!/usr/bin/env python
#
# __COPYRIGHT__
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#

__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"

"""
Test the --debug=explain option.
"""

import os.path
import string
import sys
import TestSCons

_python_ = TestSCons._python_

test = TestSCons.TestSCons()

test.subdir('work1', ['work1', 'src'], ['work1', 'src', 'subdir'],
            'work4', ['work4', 'src'], ['work4', 'src', 'subdir'],
            'work5')

subdir_file6 = os.path.join('subdir', 'file6')
subdir_file6_in = os.path.join('subdir', 'file6.in')
cat_py = test.workpath('cat.py')

test.write(cat_py, r"""
import sys

def process(outfp, infp):
    for line in infp.readlines():
        if line[:8] == 'include ':
            file = line[8:-1]
            try:
                fp = open(file, 'rb')
            except IOError:
                import os
                print "os.getcwd() =", os.getcwd()
                raise
            process(outfp, fp)
        else:
            outfp.write(line)

outfp = open(sys.argv[1], 'wb')
for f in sys.argv[2:]:
    if f != '-':
        process(outfp, open(f, 'rb'))

sys.exit(0)
""")

SConstruct_contents = """\
import re

include_re = re.compile(r'^include\s+(\S+)$', re.M)

def kfile_scan(node, env, target, arg):
    contents = node.get_contents()
    includes = include_re.findall(contents)
    return includes

kscan = Scanner(name = 'kfile',
                function = kfile_scan,
                argument = None,
                skeys = ['.k'])

cat = Builder(action = r'%(_python_)s %(cat_py)s $TARGET $SOURCES')

env = Environment()
env.Append(BUILDERS = {'Cat':cat},
           SCANNERS = kscan)

Export("env")
SConscript('SConscript')
env.Install('../inc', 'aaa')
env.InstallAs('../inc/bbb.k', 'bbb.k')
env.Install('../inc', 'ddd')
env.InstallAs('../inc/eee', 'eee.in')
""" % locals()

args = '--debug=explain .'

#############################################################################
test.write(['work1', 'src', 'SConstruct'], SConstruct_contents)

test.write(['work1', 'src', 'SConscript'], """\
Import("env")
env.Cat('file1', 'file1.in')
env.Cat('file2', 'file2.k')
env.Cat('file3', ['xxx', 'yyy', 'zzz'])
env.Command('file4', 'file4.in',
             r'%(_python_)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES',
             FILE4FLAG='-')
env.Cat('file5', 'file5.k')
env.Cat('subdir/file6', 'subdir/file6.in')
""" % locals())

test.write(['work1', 'src', 'aaa'], "aaa 1\n")
test.write(['work1', 'src', 'bbb.k'], """\
bbb.k 1
include ccc
include ../inc/ddd
include ../inc/eee
""")
test.write(['work1', 'src', 'ccc'], "ccc 1\n")
test.write(['work1', 'src', 'ddd'], "ddd 1\n")
test.write(['work1', 'src', 'eee.in'], "eee.in 1\n")

test.write(['work1', 'src', 'file1.in'], "file1.in 1\n")

test.write(['work1', 'src', 'file2.k'], """\
file2.k 1 line 1
include xxx
include yyy
file2.k 1 line 4
""")

test.write(['work1', 'src', 'file4.in'], "file4.in 1\n")

test.write(['work1', 'src', 'xxx'], "xxx 1\n")
test.write(['work1', 'src', 'yyy'], "yyy 1\n")
test.write(['work1', 'src', 'zzz'], "zzz 1\n")

test.write(['work1', 'src', 'file5.k'], """\
file5.k 1 line 1
include ../inc/aaa
include ../inc/bbb.k
file5.k 1 line 4
""")

test.write(['work1', 'src', 'subdir', 'file6.in'], "subdir/file6.in 1\n")

work1_inc_aaa = test.workpath('work1', 'inc', 'aaa')
work1_inc_ddd = test.workpath('work1', 'inc', 'ddd')
work1_inc_eee = test.workpath('work1', 'inc', 'eee')
work1_inc_bbb_k = test.workpath('work1', 'inc', 'bbb.k')

#
expect = test.wrap_stdout("""\
scons: building `file1' because it doesn't exist
%(_python_)s %(cat_py)s file1 file1.in
scons: building `file2' because it doesn't exist
%(_python_)s %(cat_py)s file2 file2.k
scons: building `file3' because it doesn't exist
%(_python_)s %(cat_py)s file3 xxx yyy zzz
scons: building `file4' because it doesn't exist
%(_python_)s %(cat_py)s file4 - file4.in
scons: building `%(work1_inc_aaa)s' because it doesn't exist
Install file: "aaa" as "%(work1_inc_aaa)s"
scons: building `%(work1_inc_ddd)s' because it doesn't exist
Install file: "ddd" as "%(work1_inc_ddd)s"
scons: building `%(work1_inc_eee)s' because it doesn't exist
Install file: "eee.in" as "%(work1_inc_eee)s"
scons: building `%(work1_inc_bbb_k)s' because it doesn't exist
Install file: "bbb.k" as "%(work1_inc_bbb_k)s"
scons: building `file5' because it doesn't exist
%(_python_)s %(cat_py)s file5 file5.k
scons: building `%(subdir_file6)s' because it doesn't exist
%(_python_)s %(cat_py)s %(subdir_file6)s %(subdir_file6_in)s
""" % locals())

test.run(chdir='work1/src', arguments=args, stdout=expect)

test.must_match(['work1', 'src', 'file1'], "file1.in 1\n")
test.must_match(['work1', 'src', 'file2'], """\
file2.k 1 line 1
xxx 1
yyy 1
file2.k 1 line 4
""")
test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 1\nzzz 1\n")
test.must_match(['work1', 'src', 'file4'], "file4.in 1\n")
test.must_match(['work1', 'src', 'file5'], """\
file5.k 1 line 1
aaa 1
bbb.k 1
ccc 1
ddd 1
eee.in 1
file5.k 1 line 4
""")

#
test.write(['work1', 'src', 'file1.in'], "file1.in 2\n")
test.write(['work1', 'src', 'yyy'], "yyy 2\n")
test.write(['work1', 'src', 'zzz'], "zzz 2\n")
test.write(['work1', 'src', 'bbb.k'], "bbb.k 2\ninclude ccc\n")

expect = test.wrap_stdout("""\
scons: rebuilding `file1' because `file1.in' changed
%(_python_)s %(cat_py)s file1 file1.in
scons: rebuilding `file2' because `yyy' changed
%(_python_)s %(cat_py)s file2 file2.k
scons: rebuilding `file3' because:
           `yyy' changed
           `zzz' changed
%(_python_)s %(cat_py)s file3 xxx yyy zzz
scons: rebuilding `%(work1_inc_bbb_k)s' because:
           `%(work1_inc_ddd)s' is no longer a dependency
           `%(work1_inc_eee)s' is no longer a dependency
           `bbb.k' changed
Install file: "bbb.k" as "%(work1_inc_bbb_k)s"
scons: rebuilding `file5' because `%(work1_inc_bbb_k)s' changed
%(_python_)s %(cat_py)s file5 file5.k
""" % locals())

test.run(chdir='work1/src', arguments=args, stdout=expect)

test.must_match(['work1', 'src', 'file1'], "file1.in 2\n")
test.must_match(['work1', 'src', 'file2'], """\
file2.k 1 line 1
xxx 1
yyy 2
file2.k 1 line 4
""")
test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n")
test.must_match(['work1', 'src', 'file5'], """\
file5.k 1 line 1
aaa 1
bbb.k 2
ccc 1
file5.k 1 line 4
""")

#
test.write(['work1', 'src', 'SConscript'], """\
Import("env")
env.Cat('file3', ['xxx', 'yyy'])
""")

expect = test.wrap_stdout("""\
scons: rebuilding `file3' because `zzz' is no longer a dependency
%(_python_)s %(cat_py)s file3 xxx yyy
""" % locals())

test.run(chdir='work1/src', arguments=args, stdout=expect)

test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 2\n")

#
test.write(['work1', 'src', 'SConscript'], """\
Import("env")
env.Cat('file3', ['xxx', 'yyy', 'zzz'])
""")

expect = test.wrap_stdout("""\
scons: rebuilding `file3' because `zzz' is a new dependency
%(_python_)s %(cat_py)s file3 xxx yyy zzz
""" % locals())

test.run(chdir='work1/src', arguments=args, stdout=expect)

test.must_match(['work1', 'src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n")

#
test.write(['work1', 'src', 'SConscript'], """\
Import("env")
env.Cat('file3', ['zzz', 'yyy', 'xxx'])
""")

expect = test.wrap_stdout("""\
scons: rebuilding `file3' because the dependency order changed:
               old: ['xxx', 'yyy', 'zzz']
               new: ['zzz', 'yyy', 'xxx']
%(_python_)s %(cat_py)s file3 zzz yyy xxx
""" % locals())

test.run(chdir='work1/src', arguments=args, stdout=expect)

test.must_match(['work1', 'src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n")

#
test.write(['work1', 'src', 'SConscript'], """\
Import("env")
f3 = File('file3')
env.Cat(f3, ['zzz', 'yyy', 'xxx'])
env.AddPostAction(f3, r'%(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES yyy')
env.AddPreAction(f3, r'%(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES')
""" % locals())

expect = test.wrap_stdout("""\
scons: rebuilding `file3' because the build action changed:
               old: %(_python_)s %(cat_py)s $TARGET $SOURCES
               new: %(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES
                    %(_python_)s %(cat_py)s $TARGET $SOURCES
                    %(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES yyy
%(_python_)s %(cat_py)s file3.alt zzz yyy xxx
%(_python_)s %(cat_py)s file3 zzz yyy xxx
%(_python_)s %(cat_py)s file3.yyy zzz yyy xxx yyy
""" % locals())

test.run(chdir='work1/src', arguments=args, stdout=expect)

test.must_match(['work1', 'src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n")
test.must_match(['work1', 'src', 'file3.alt'], "zzz 2\nyyy 2\nxxx 1\n")
test.must_match(['work1', 'src', 'file3.yyy'], "zzz 2\nyyy 2\nxxx 1\nyyy 2\n")

#
test.write(['work1', 'src', 'SConscript'], """\
Import("env")
f3 = File('file3')
env.Cat(f3, ['zzz', 'yyy', 'xxx'])
env.AddPostAction(f3, r'%(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES xxx')
env.AddPreAction(f3, r'%(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES')
""" % locals())

expect = test.wrap_stdout("""\
scons: rebuilding `file3' because the build action changed:
               old: %(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES
                    %(_python_)s %(cat_py)s $TARGET $SOURCES
                    %(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES yyy
               new: %(_python_)s %(cat_py)s ${TARGET}.alt $SOURCES
                    %(_python_)s %(cat_py)s $TARGET $SOURCES
                    %(_python_)s %(cat_py)s ${TARGET}.yyy $SOURCES xxx
%(_python_)s %(cat_py)s file3.alt zzz yyy xxx
%(_python_)s %(cat_py)s file3 zzz yyy xxx
%(_python_)s %(cat_py)s file3.yyy zzz yyy xxx xxx
""" % locals())

test.run(chdir='work1/src', arguments=args, stdout=expect)

test.must_match(['work1', 'src', 'file3'], "zzz 2\nyyy 2\nxxx 1\n")
test.must_match(['work1', 'src', 'file3.alt'], "zzz 2\nyyy 2\nxxx 1\n")
test.must_match(['work1', 'src', 'file3.yyy'], "zzz 2\nyyy 2\nxxx 1\nxxx 1\n")

#
test.write(['work1', 'src', 'SConscript'], """\
Import("env")
env.Command('file4', 'file4.in',
            r'%(_python_)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES',
            FILE4FLAG='')
""" % locals())

expect = test.wrap_stdout("""\
scons: rebuilding `file4' because the contents of the build action changed
               action: %(_python_)s %(cat_py)s $TARGET $FILE4FLAG $SOURCES
%(_python_)s %(cat_py)s file4 file4.in
""" % locals())

test.run(chdir='work1/src',arguments=args, stdout=expect)

test.must_match(['work1', 'src', 'file4'], "file4.in 1\n")

test.up_to_date(chdir='work1/src',arguments='.')

# Test the transition when you turn ON SConsignFile().
# This will (or might) rebuild things, but we don't care what,
# we just want to make sure we don't blow up.
test.write(['work1', 'src', 'SConstruct'],
           "SConsignFile()\n" + SConstruct_contents)

test.run(chdir='work1/src', arguments=args)

test.up_to_date(chdir='work1/src',arguments='.')

#############################################################################
# Test that the --debug=explain information gets saved by default.
test.write(['work4', 'src', 'SConstruct'], SConstruct_contents)

test.write(['work4', 'src', 'SConscript'], """\
Import("env")
env.Cat('file1', 'file1.in')
env.Cat('file2', 'file2.k')
env.Cat('file3', ['xxx', 'yyy', 'zzz'])
env.Command('file4', 'file4.in', r'%(_python_)s %(cat_py)s $TARGET - $SOURCES')
env.Cat('file5', 'file5.k')
env.Cat('subdir/file6', 'subdir/file6.in')
""" % locals())

test.write(['work4', 'src', 'aaa'], "aaa 1\n")
test.write(['work4', 'src', 'bbb.k'], """\
bbb.k 1
include ccc
include ../inc/ddd
include ../inc/eee
""")
test.write(['work4', 'src', 'ccc'], "ccc 1\n")
test.write(['work4', 'src', 'ddd'], "ddd 1\n")
test.write(['work4', 'src', 'eee.in'], "eee.in 1\n")

test.write(['work4', 'src', 'file1.in'], "file1.in 1\n")

test.write(['work4', 'src', 'file2.k'], """\
file2.k 1 line 1
include xxx
include yyy
file2.k 1 line 4
""")

test.write(['work4', 'src', 'file4.in'], "file4.in 1\n")

test.write(['work4', 'src', 'xxx'], "xxx 1\n")
test.write(['work4', 'src', 'yyy'], "yyy 1\n")
test.write(['work4', 'src', 'zzz'], "zzz 1\n")

test.write(['work4', 'src', 'file5.k'], """\
file5.k 1 line 1
include ../inc/aaa
include ../inc/bbb.k
file5.k 1 line 4
""")

test.write(['work4', 'src', 'subdir', 'file6.in'], "subdir/file6.in 1\n")

#
test.run(chdir='work4/src', arguments='.')

test.must_match(['work4', 'src', 'file1'], "file1.in 1\n")
test.must_match(['work4', 'src', 'file2'], """\
file2.k 1 line 1
xxx 1
yyy 1
file2.k 1 line 4
""")
test.must_match(['work4', 'src', 'file3'], "xxx 1\nyyy 1\nzzz 1\n")
test.must_match(['work4', 'src', 'file4'], "file4.in 1\n")
test.must_match(['work4', 'src', 'file5'], """\
file5.k 1 line 1
aaa 1
bbb.k 1
ccc 1
ddd 1
eee.in 1
file5.k 1 line 4
""")

#
test.write(['work4', 'src', 'file1.in'], "file1.in 2\n")
test.write(['work4', 'src', 'yyy'], "yyy 2\n")
test.write(['work4', 'src', 'zzz'], "zzz 2\n")
test.write(['work4', 'src', 'bbb.k'], "bbb.k 2\ninclude ccc\n")

work4_inc_bbb_k = test.workpath('work4', 'inc', 'bbb.k')
work4_inc_ddd = test.workpath('work4', 'inc', 'ddd')
work4_inc_eee = test.workpath('work4', 'inc', 'eee')

test.run(chdir='work4/src', arguments=args, stdout=test.wrap_stdout("""\
scons: rebuilding `file1' because `file1.in' changed
%(_python_)s %(cat_py)s file1 file1.in
scons: rebuilding `file2' because `yyy' changed
%(_python_)s %(cat_py)s file2 file2.k
scons: rebuilding `file3' because:
           `yyy' changed
           `zzz' changed
%(_python_)s %(cat_py)s file3 xxx yyy zzz
scons: rebuilding `%(work4_inc_bbb_k)s' because:
           `%(work4_inc_ddd)s' is no longer a dependency
           `%(work4_inc_eee)s' is no longer a dependency
           `bbb.k' changed
Install file: "bbb.k" as "%(work4_inc_bbb_k)s"
scons: rebuilding `file5' because `%(work4_inc_bbb_k)s' changed
%(_python_)s %(cat_py)s file5 file5.k
""" % locals()))

test.must_match(['work4', 'src', 'file1'], "file1.in 2\n")
test.must_match(['work4', 'src', 'file2'], """\
file2.k 1 line 1
xxx 1
yyy 2
file2.k 1 line 4
""")
test.must_match(['work4', 'src', 'file3'], "xxx 1\nyyy 2\nzzz 2\n")
test.must_match(['work4', 'src', 'file5'], """\
file5.k 1 line 1
aaa 1
bbb.k 2
ccc 1
file5.k 1 line 4
""")



test.write(['work5', 'SConstruct'], """\
import shutil

env = Environment()
mode = int(ARGUMENTS.get('mode'))
if mode:
    def DifferentCopy(target, source, env):
        tgt = str(target[0])
        src = str(source[0])
        shutil.copy(src, tgt)
    def AltCopyStage2(target, source, env):
        pass
    MyCopy = Builder(action = [DifferentCopy, AltCopyStage2])

    def ChangingCopy(target, source, env):
        tgt = str(target[0])
        src = str(source[0])
        shutil.copy(src, tgt)
    ChangingCopy = Builder(action = ChangingCopy)
else:
    MyCopy = Builder(action = Copy('$TARGET', '$SOURCE'))
    def ChangingCopy(target, source, env):
        tgt = str(target[0].abspath)
        src = str(source[0].abspath)
        shutil.copy(src, tgt)
    ChangingCopy = Builder(action = ChangingCopy)

env['BUILDERS']['MyCopy'] = MyCopy
env['BUILDERS']['ChangingCopy'] = ChangingCopy

env.MyCopy('f1.out', 'f1.in')
env.ChangingCopy('f2.out', 'f2.in')
""")

test.write(['work5', 'f1.in'], "work5/f1.in\n")
test.write(['work5', 'f2.in'], "work5/f2.in\n")

test.run(chdir = 'work5', arguments = "mode=0 .")

test.must_match(['work5', 'f1.out'], "work5/f1.in\n")
test.must_match(['work5', 'f2.out'], "work5/f2.in\n")

test.run(chdir = 'work5',
         arguments = "--debug=explain mode=1 .",
         stdout = test.wrap_stdout("""\
scons: rebuilding `f1.out' because the build action changed:
               old: Copy("$TARGET", "$SOURCE")
               new: DifferentCopy(target, source, env)
                    AltCopyStage2(target, source, env)
DifferentCopy(["f1.out"], ["f1.in"])
AltCopyStage2(["f1.out"], ["f1.in"])
scons: rebuilding `f2.out' because the contents of the build action changed
               action: ChangingCopy(target, source, env)
ChangingCopy(["f2.out"], ["f2.in"])
"""))



test.pass_test()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.