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 contents = open(sys.argv[2], 'rb').read()
42 file = open(sys.argv[1], 'wb')
49 subd_SConscript = os.path.join('subd', 'SConscript')
50 subd_foon_in = os.path.join('subd', 'foon.in')
51 subd_foox_in = os.path.join('subd', 'foox.in')
53 test.write('SConstruct', """
54 B = Builder(action = r'%(_python_)s build.py $TARGETS $SOURCES')
55 env = Environment(BUILDERS = { 'B' : B }, FOO = 'foo2')
56 env.B(target = 'foo1.out', source = 'foo1.in')
57 env.B(target = 'foo2.out', source = 'foo2.xxx')
58 foo2_xxx = env.B(target = 'foo2.xxx', source = 'foo2.in')
59 env.B(target = 'foo3.out', source = 'foo3.in')
60 SConscript('subd/SConscript')
61 Clean(foo2_xxx, ['aux1.x'])
62 env.Clean(['${FOO}.xxx'], ['aux2.x'])
66 test.write(['subd', 'SConscript'], """
70 test.write('foo1.in', "foo1.in\n")
71 test.write('foo2.in', "foo2.in\n")
72 test.write('foo3.in', "foo3.in\n")
73 test.write(['subd', 'foon.in'], "foon.in\n")
74 test.write(['subd', 'foox.in'], "foox.in\n")
75 test.write('aux1.x', "aux1.x\n")
76 test.write('aux2.x', "aux2.x\n")
80 expect = test.wrap_stdout("""Removed foo2.xxx
84 test.run(arguments = '-c foo2.xxx', stdout=expect)
85 test.must_match(test.workpath('foo1.out'), "foo1.in\n")
86 test.must_not_exist(test.workpath('foo2.xxx'))
87 test.must_match(test.workpath('foo2.out'), "foo2.in\n")
88 test.must_match(test.workpath('foo3.out'), "foo3.in\n")
90 expect = test.wrap_stdout("Removed %s\n" % subd_foox_in, cleaning = 1)
91 test.run(arguments = '-c subd', stdout=expect)
92 test.must_not_exist(test.workpath('foox.in'))
94 expect = test.wrap_stdout("""Removed foo1.out
98 Removed %(subd_SConscript)s
99 Removed %(subd_foon_in)s
100 Removed directory subd
101 """ % locals(), cleaning = 1)
102 test.run(arguments = '-c -n .', stdout=expect)
104 expect = test.wrap_stdout("""Removed foo1.out
107 Removed %(subd_SConscript)s
108 Removed %(subd_foon_in)s
109 Removed directory subd
110 """ % locals(), cleaning = 1)
111 test.run(arguments = '-c .', stdout=expect)
112 test.must_not_exist(test.workpath('subdir', 'foon.in'))
113 test.must_not_exist(test.workpath('subdir'))
119 # indent-tabs-mode:nil
121 # vim: set expandtab tabstop=4 shiftwidth=4: