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 that the Delete() Action works.
35 test = TestSCons.TestSCons()
37 test.write('SConstruct', """
40 def cat(env, source, target):
41 target = str(target[0])
42 f = open(target, "wb")
44 f.write(open(str(src), "rb").read())
48 env.Command('f3.out', 'f3.in', [Cat, Delete("f4"), Delete("d5")])
49 env = Environment(FILE='f6', DIR='d7')
50 env.Command('f8.out', 'f8.in', [Delete("$FILE"), Delete("$DIR"), Cat])
51 env.Command('f9.out', 'f9.in', [Cat,
52 Delete("Delete-$SOURCE"),
53 Delete("$TARGET-Delete")])
55 env.Command('f10-nonexistent.out', 'f10.in',
56 [Delete("$TARGET"), Cat])
58 env.Command(Dir('d11-nonexistent.out'), 'd11.in',
59 [Delete("$TARGET"), Mkdir("$TARGET")])
61 env.Command('f12-nonexistent.out', 'f12.in',
62 [Delete("$TARGET", must_exist=0), Cat])
64 env.Command(Dir('d13-nonexistent.out'), 'd13.in',
65 [Delete("$TARGET", must_exist=0), Mkdir("$TARGET")])
67 # Make sure Delete works with a list of arguments
68 env = Environment(FILE='f14', DIR='d15')
69 env.Command('f16.out', 'f16.in', [Delete(["$FILE", "$DIR"]), Cat])
72 test.write('f1', "f1\n")
74 test.write(['d2', 'file'], "d2/file\n")
75 test.write('f3.in', "f3.in\n")
76 test.write('f4', "f4\n")
78 test.write(['d5', 'file'], "d5/file\n")
79 test.write('f6', "f6\n")
81 test.write(['d7', 'file'], "d7/file\n")
82 test.write('f8.in', "f8.in\n")
83 test.write('f9.in', "f9.in\n")
84 test.write('Delete-f9.in', "Delete-f9.in\n")
85 test.write('f9.out-Delete', "f9.out-Delete\n")
86 test.write('f10.in', "f10.in\n")
88 test.write('f12.in', "f12.in\n")
90 test.write('f14', "f14\n")
92 test.write('f16.in', "f16.in\n")
94 expect = test.wrap_stdout(read_str = """\
99 Delete("d11-nonexistent.out")
100 Mkdir("d11-nonexistent.out")
101 Delete("d13-nonexistent.out")
102 Mkdir("d13-nonexistent.out")
103 Delete("f10-nonexistent.out")
104 cat(["f10-nonexistent.out"], ["f10.in"])
105 Delete("f12-nonexistent.out")
106 cat(["f12-nonexistent.out"], ["f12.in"])
107 Delete(["f14", "d15"])
108 cat(["f16.out"], ["f16.in"])
109 cat(["f3.out"], ["f3.in"])
114 cat(["f8.out"], ["f8.in"])
115 cat(["f9.out"], ["f9.in"])
116 Delete("Delete-f9.in")
117 Delete("f9.out-Delete")
119 test.run(options = '-n', arguments = '.', stdout = expect)
121 test.must_exist('f1')
122 test.must_exist('d2')
123 test.must_exist(os.path.join('d2', 'file'))
124 test.must_not_exist('f3.out')
125 test.must_exist('f4')
126 test.must_exist('d5')
127 test.must_exist(os.path.join('d5', 'file'))
128 test.must_exist('f6')
129 test.must_exist('d7')
130 test.must_exist(os.path.join('d7', 'file'))
131 test.must_not_exist('f8.out')
132 test.must_not_exist('f9.out')
133 test.must_exist('Delete-f9.in')
134 test.must_exist('f9.out-Delete')
135 test.must_exist('f14')
136 test.must_exist('d15')
137 test.must_not_exist('f16.out')
141 test.must_not_exist('f1')
142 test.must_not_exist('d2')
143 test.must_not_exist(os.path.join('d2', 'file'))
144 test.must_match('f3.out', "f3.in\n")
145 test.must_not_exist('f4')
146 test.must_not_exist('d5')
147 test.must_not_exist(os.path.join('d5', 'file'))
148 test.must_not_exist('f6')
149 test.must_not_exist('d7')
150 test.must_not_exist(os.path.join('d7', 'file'))
151 test.must_match('f8.out', "f8.in\n")
152 test.must_match('f9.out', "f9.in\n")
153 test.must_not_exist('Delete-f9.in')
154 test.must_not_exist('f9.out-Delete')
155 test.must_exist('f10-nonexistent.out')
156 test.must_exist('d11-nonexistent.out')
157 test.must_exist('f12-nonexistent.out')
158 test.must_exist('d13-nonexistent.out')
159 test.must_not_exist('f14')
160 test.must_not_exist('d15')
161 test.must_match('f16.out', "f16.in\n")
163 test.write("SConstruct", """\
164 def cat(env, source, target):
165 target = str(target[0])
166 f = open(target, "wb")
168 f.write(open(str(src), "rb").read())
172 env.Command('f14-nonexistent.out', 'f14.in', [Delete("$TARGET", must_exist=1),
176 test.write('f14.in', "f14.in\n")
178 test.run(status=2, stderr=None)
181 "No such file or directory",
182 "The system cannot find the file specified",
183 "The system cannot find the path specified",
186 test.must_contain_any_line(test.stderr(), fail_strings)
192 # indent-tabs-mode:nil
194 # vim: set expandtab tabstop=4 shiftwidth=4: