30 "build in1: cat src1\n"
31 "build out1: cat in1\n"
32 "build in2: cat src2\n"
33 "build out2: cat in2\n"));
34 fs_.Create(
"in1",
"");
35 fs_.Create(
"out1",
"");
36 fs_.Create(
"in2",
"");
37 fs_.Create(
"out2",
"");
39 Cleaner cleaner(&state_, config_, &fs_);
44 EXPECT_EQ(4u, fs_.files_removed_.size());
47 EXPECT_EQ(0, fs_.Stat(
"in1"));
48 EXPECT_EQ(0, fs_.Stat(
"out1"));
49 EXPECT_EQ(0, fs_.Stat(
"in2"));
50 EXPECT_EQ(0, fs_.Stat(
"out2"));
51 fs_.files_removed_.clear();
55 EXPECT_EQ(0u, fs_.files_removed_.size());
60 "build in1: cat src1\n"
61 "build out1: cat in1\n"
62 "build in2: cat src2\n"
63 "build out2: cat in2\n"));
64 fs_.Create(
"in1",
"");
65 fs_.Create(
"out1",
"");
66 fs_.Create(
"in2",
"");
67 fs_.Create(
"out2",
"");
69 config_.dry_run =
true;
70 Cleaner cleaner(&state_, config_, &fs_);
75 EXPECT_EQ(0u, fs_.files_removed_.size());
78 EXPECT_NE(0, fs_.Stat(
"in1"));
79 EXPECT_NE(0, fs_.Stat(
"out1"));
80 EXPECT_NE(0, fs_.Stat(
"in2"));
81 EXPECT_NE(0, fs_.Stat(
"out2"));
82 fs_.files_removed_.clear();
86 EXPECT_EQ(0u, fs_.files_removed_.size());
91 "build in1: cat src1\n"
92 "build out1: cat in1\n"
93 "build in2: cat src2\n"
94 "build out2: cat in2\n"));
95 fs_.Create(
"in1",
"");
96 fs_.Create(
"out1",
"");
97 fs_.Create(
"in2",
"");
98 fs_.Create(
"out2",
"");
100 Cleaner cleaner(&state_, config_, &fs_);
105 EXPECT_EQ(2u, fs_.files_removed_.size());
108 EXPECT_EQ(0, fs_.Stat(
"in1"));
109 EXPECT_EQ(0, fs_.Stat(
"out1"));
110 EXPECT_NE(0, fs_.Stat(
"in2"));
111 EXPECT_NE(0, fs_.Stat(
"out2"));
112 fs_.files_removed_.clear();
116 EXPECT_EQ(0u, fs_.files_removed_.size());
121 "build in1: cat src1\n"
122 "build out1: cat in1\n"
123 "build in2: cat src2\n"
124 "build out2: cat in2\n"));
125 fs_.Create(
"in1",
"");
126 fs_.Create(
"out1",
"");
127 fs_.Create(
"in2",
"");
128 fs_.Create(
"out2",
"");
130 config_.dry_run =
true;
131 Cleaner cleaner(&state_, config_, &fs_);
136 EXPECT_EQ(0u, fs_.files_removed_.size());
139 EXPECT_NE(0, fs_.Stat(
"in1"));
140 EXPECT_NE(0, fs_.Stat(
"out1"));
141 EXPECT_NE(0, fs_.Stat(
"in2"));
142 EXPECT_NE(0, fs_.Stat(
"out2"));
143 fs_.files_removed_.clear();
147 EXPECT_EQ(0u, fs_.files_removed_.size());
153 " command = cat -e $in > $out\n"
154 "build in1: cat_e src1\n"
155 "build out1: cat in1\n"
156 "build in2: cat_e src2\n"
157 "build out2: cat in2\n"));
158 fs_.Create(
"in1",
"");
159 fs_.Create(
"out1",
"");
160 fs_.Create(
"in2",
"");
161 fs_.Create(
"out2",
"");
163 Cleaner cleaner(&state_, config_, &fs_);
166 ASSERT_EQ(0, cleaner.
CleanRule(
"cat_e"));
168 EXPECT_EQ(2u, fs_.files_removed_.size());
171 EXPECT_EQ(0, fs_.Stat(
"in1"));
172 EXPECT_NE(0, fs_.Stat(
"out1"));
173 EXPECT_EQ(0, fs_.Stat(
"in2"));
174 EXPECT_NE(0, fs_.Stat(
"out2"));
175 fs_.files_removed_.clear();
177 ASSERT_EQ(0, cleaner.
CleanRule(
"cat_e"));
179 EXPECT_EQ(0u, fs_.files_removed_.size());
185 " command = cat -e $in > $out\n"
186 "build in1: cat_e src1\n"
187 "build out1: cat in1\n"
188 "build in2: cat_e src2\n"
189 "build out2: cat in2\n"));
190 fs_.Create(
"in1",
"");
191 fs_.Create(
"out1",
"");
192 fs_.Create(
"in2",
"");
193 fs_.Create(
"out2",
"");
195 config_.dry_run =
true;
196 Cleaner cleaner(&state_, config_, &fs_);
199 ASSERT_EQ(0, cleaner.
CleanRule(
"cat_e"));
201 EXPECT_EQ(0u, fs_.files_removed_.size());
204 EXPECT_NE(0, fs_.Stat(
"in1"));
205 EXPECT_NE(0, fs_.Stat(
"out1"));
206 EXPECT_NE(0, fs_.Stat(
"in2"));
207 EXPECT_NE(0, fs_.Stat(
"out2"));
208 fs_.files_removed_.clear();
210 ASSERT_EQ(0, cleaner.
CleanRule(
"cat_e"));
212 EXPECT_EQ(0u, fs_.files_removed_.size());
218 " command = cat $in > $out\n"
220 "build out1: cat in1\n"
221 "build out2: regen in2\n"));
222 fs_.Create(
"out1",
"");
223 fs_.Create(
"out2",
"");
225 Cleaner cleaner(&state_, config_, &fs_);
228 EXPECT_EQ(1u, fs_.files_removed_.size());
230 fs_.Create(
"out1",
"");
232 EXPECT_EQ(0, cleaner.
CleanAll(
true));
234 EXPECT_EQ(2u, fs_.files_removed_.size());
240 " command = cc $in > $out\n"
241 " depfile = $out.d\n"
242 "build out1: cc in1\n"));
243 fs_.Create(
"out1",
"");
244 fs_.Create(
"out1.d",
"");
246 Cleaner cleaner(&state_, config_, &fs_);
249 EXPECT_EQ(2u, fs_.files_removed_.size());
255 " command = cc $in > $out\n"
256 " depfile = $out.d\n"
257 "build out1: cc in1\n"));
258 fs_.Create(
"out1",
"");
259 fs_.Create(
"out1.d",
"");
261 Cleaner cleaner(&state_, config_, &fs_);
264 EXPECT_EQ(2u, fs_.files_removed_.size());
270 " command = cc $in > $out\n"
271 " depfile = $out.d\n"
272 "build out1: cc in1\n"));
273 fs_.Create(
"out1",
"");
274 fs_.Create(
"out1.d",
"");
276 Cleaner cleaner(&state_, config_, &fs_);
279 EXPECT_EQ(2u, fs_.files_removed_.size());
285 " command = cc $in > $out\n"
286 " rspfile = $rspfile\n"
287 " rspfile_content=$in\n"
288 "build out1: cc in1\n"
289 " rspfile = cc1.rsp\n"
290 " rspfile_content=$in\n"));
291 fs_.Create(
"out1",
"");
292 fs_.Create(
"cc1.rsp",
"");
294 Cleaner cleaner(&state_, config_, &fs_);
297 EXPECT_EQ(2u, fs_.files_removed_.size());
303 " command = cat $rspfile > $out\n"
304 " rspfile = $rspfile\n"
305 " rspfile_content = $in\n"
306 "build in1: cat src1\n"
307 "build out1: cat in1\n"
308 "build in2: cat_rsp src2\n"
310 " rspfile_content=$in\n"
311 "build out2: cat_rsp in2\n"
312 " rspfile=out2.rsp\n"
313 " rspfile_content=$in\n"));
314 fs_.Create(
"in1",
"");
315 fs_.Create(
"out1",
"");
316 fs_.Create(
"in2.rsp",
"");
317 fs_.Create(
"out2.rsp",
"");
318 fs_.Create(
"in2",
"");
319 fs_.Create(
"out2",
"");
321 Cleaner cleaner(&state_, config_, &fs_);
327 ASSERT_EQ(0, cleaner.
CleanRule(
"cat_rsp"));
330 EXPECT_EQ(6u, fs_.files_removed_.size());
333 EXPECT_EQ(0, fs_.Stat(
"in1"));
334 EXPECT_EQ(0, fs_.Stat(
"out1"));
335 EXPECT_EQ(0, fs_.Stat(
"in2"));
336 EXPECT_EQ(0, fs_.Stat(
"out2"));
337 EXPECT_EQ(0, fs_.Stat(
"in2.rsp"));
338 EXPECT_EQ(0, fs_.Stat(
"out2.rsp"));
340 fs_.files_removed_.clear();
345 "build dir: cat src1\n"));
347 Cleaner cleaner(&state_, config_, &fs_);
353 "build phony: phony t1 t2\n"
357 fs_.Create(
"phony",
"");
358 fs_.Create(
"t1",
"");
359 fs_.Create(
"t2",
"");
362 Cleaner cleaner(&state_, config_, &fs_);
365 EXPECT_NE(0, fs_.Stat(
"phony"));
367 fs_.Create(
"t1",
"");
368 fs_.Create(
"t2",
"");
373 EXPECT_NE(0, fs_.Stat(
"phony"));
An implementation of DiskInterface that uses an in-memory representation of disk state.
void AssertParse(State *state, const char *input)
A base test fixture that includes a State object with a builtin "cat" rule.
int CleanAll(bool generator=false)
Clean all built files, except for files created by generator rules.
int CleanRule(const Rule *rule)
Clean all the file built with the given rule rule.
TEST_F(CleanTest, CleanAll)
Options (e.g. verbosity, parallelism) passed to a build.
int cleaned_files_count() const
int CleanTarget(Node *target)
Clean the given target and all the file built for it.