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__"
28 Verify use of the Clean() function.
35 _python_
= TestSCons
._python
_
37 test
= TestSCons
.TestSCons()
39 test
.write('build.py', r
"""
41 with open(sys.argv[1], 'wb') as ofp, open(sys.argv[2], 'rb') as ifp:
47 subd_SConscript
= os
.path
.join('subd', 'SConscript')
48 subd_foon_in
= os
.path
.join('subd', 'foon.in')
49 subd_foox_in
= os
.path
.join('subd', 'foox.in')
51 test
.write('SConstruct', """
52 DefaultEnvironment(tools=[])
53 B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES')
54 env = Environment(tools=[], BUILDERS = { 'B' : B }, FOO = 'foo2')
55 env.B(target = 'foo1.out', source = 'foo1.in')
56 env.B(target = 'foo2.out', source = 'foo2.xxx')
57 foo2_xxx = env.B(target = 'foo2.xxx', source = 'foo2.in')
58 env.B(target = 'foo3.out', source = 'foo3.in')
59 SConscript('subd/SConscript')
60 Clean(foo2_xxx, ['aux1.x'])
61 env.Clean(['${FOO}.xxx'], ['aux2.x'])
65 test
.write(['subd', 'SConscript'], """
69 test
.write('foo1.in', "foo1.in\n")
70 test
.write('foo2.in', "foo2.in\n")
71 test
.write('foo3.in', "foo3.in\n")
72 test
.write(['subd', 'foon.in'], "foon.in\n")
73 test
.write(['subd', 'foox.in'], "foox.in\n")
74 test
.write('aux1.x', "aux1.x\n")
75 test
.write('aux2.x', "aux2.x\n")
79 expect
= test
.wrap_stdout("""Removed foo2.xxx
83 test
.run(arguments
= '-c foo2.xxx', stdout
=expect
)
84 test
.must_match(test
.workpath('foo1.out'), "foo1.in\n")
85 test
.must_not_exist(test
.workpath('foo2.xxx'))
86 test
.must_match(test
.workpath('foo2.out'), "foo2.in\n")
87 test
.must_match(test
.workpath('foo3.out'), "foo3.in\n")
89 expect
= test
.wrap_stdout("Removed %s\n" % subd_foox_in
, cleaning
= 1)
90 test
.run(arguments
= '-c subd', stdout
=expect
)
91 test
.must_not_exist(test
.workpath('foox.in'))
93 expect
= test
.wrap_stdout("""Removed foo1.out
97 Removed %(subd_SConscript)s
98 Removed %(subd_foon_in)s
99 Removed directory subd
100 """ % locals(), cleaning
= 1)
101 test
.run(arguments
= '-c -n .', stdout
=expect
)
103 expect
= test
.wrap_stdout("""Removed foo1.out
106 Removed %(subd_SConscript)s
107 Removed %(subd_foon_in)s
108 Removed directory subd
109 """ % locals(), cleaning
= 1)
110 test
.run(arguments
= '-c .', stdout
=expect
)
111 test
.must_not_exist(test
.workpath('subdir', 'foon.in'))
112 test
.must_not_exist(test
.workpath('subdir'))
118 # indent-tabs-mode:nil
120 # vim: set expandtab tabstop=4 shiftwidth=4: