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.
27 Verify use of the Clean() function.
34 _python_
= TestSCons
._python
_
36 test
= TestSCons
.TestSCons()
38 test
.write('build.py', r
"""
40 with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp:
46 subd_SConscript
= os
.path
.join('subd', 'SConscript')
47 subd_foon_in
= os
.path
.join('subd', 'foon.in')
48 subd_foox_in
= os
.path
.join('subd', 'foox.in')
50 test
.write('SConstruct', """
51 DefaultEnvironment(tools=[])
52 B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES')
53 env = Environment(tools=[], BUILDERS = { 'B' : B }, FOO = 'foo2')
54 env.B(target = 'foo1.out', source = 'foo1.in')
55 env.B(target = 'foo2.out', source = 'foo2.xxx')
56 foo2_xxx = env.B(target = 'foo2.xxx', source = 'foo2.in')
57 env.B(target = 'foo3.out', source = 'foo3.in')
58 SConscript('subd/SConscript')
59 Clean(foo2_xxx, ['aux1.x'])
60 env.Clean(['${FOO}.xxx'], ['aux2.x'])
64 test
.write(['subd', 'SConscript'], """
68 test
.write('foo1.in', "foo1.in\n")
69 test
.write('foo2.in', "foo2.in\n")
70 test
.write('foo3.in', "foo3.in\n")
71 test
.write(['subd', 'foon.in'], "foon.in\n")
72 test
.write(['subd', 'foox.in'], "foox.in\n")
73 test
.write('aux1.x', "aux1.x\n")
74 test
.write('aux2.x', "aux2.x\n")
78 expect
= test
.wrap_stdout("""Removed foo2.xxx
82 test
.run(arguments
= '-c foo2.xxx', stdout
=expect
)
83 test
.must_match(test
.workpath('foo1.out'), "foo1.in\n")
84 test
.must_not_exist(test
.workpath('foo2.xxx'))
85 test
.must_match(test
.workpath('foo2.out'), "foo2.in\n")
86 test
.must_match(test
.workpath('foo3.out'), "foo3.in\n")
88 expect
= test
.wrap_stdout("Removed %s\n" % subd_foox_in
, cleaning
= 1)
89 test
.run(arguments
= '-c subd', stdout
=expect
)
90 test
.must_not_exist(test
.workpath('foox.in'))
92 expect
= test
.wrap_stdout("""Removed foo1.out
96 Removed %(subd_SConscript)s
97 Removed %(subd_foon_in)s
98 Removed directory subd
99 """ % locals(), cleaning
= 1)
100 test
.run(arguments
= '-c -n .', stdout
=expect
)
102 expect
= test
.wrap_stdout("""Removed foo1.out
105 Removed %(subd_SConscript)s
106 Removed %(subd_foon_in)s
107 Removed directory subd
108 """ % locals(), cleaning
= 1)
109 test
.run(arguments
= '-c .', stdout
=expect
)
110 test
.must_not_exist(test
.workpath('subdir', 'foon.in'))
111 test
.must_not_exist(test
.workpath('subdir'))
117 # indent-tabs-mode:nil
119 # vim: set expandtab tabstop=4 shiftwidth=4: