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_);
52 fs_.files_removed_.clear();
61 "build in1: cat src1\n" 62 "build out1: cat in1\n" 63 "build in2: cat src2\n" 64 "build out2: cat in2\n"));
65 fs_.Create(
"in1",
"");
66 fs_.Create(
"out1",
"");
67 fs_.Create(
"in2",
"");
68 fs_.Create(
"out2",
"");
70 config_.dry_run =
true;
71 Cleaner cleaner(&state_, config_, &fs_);
84 fs_.files_removed_.clear();
93 "build in1: cat src1\n" 94 "build out1: cat in1\n" 95 "build in2: cat src2\n" 96 "build out2: cat in2\n"));
97 fs_.Create(
"in1",
"");
98 fs_.Create(
"out1",
"");
99 fs_.Create(
"in2",
"");
100 fs_.Create(
"out2",
"");
102 Cleaner cleaner(&state_, config_, &fs_);
107 EXPECT_EQ(2u, fs_.files_removed_.size());
115 fs_.files_removed_.clear();
119 EXPECT_EQ(0u, fs_.files_removed_.size());
124 "build in1: cat src1\n" 125 "build out1: cat in1\n" 126 "build in2: cat src2\n" 127 "build out2: cat in2\n"));
128 fs_.Create(
"in1",
"");
129 fs_.Create(
"out1",
"");
130 fs_.Create(
"in2",
"");
131 fs_.Create(
"out2",
"");
133 config_.dry_run =
true;
134 Cleaner cleaner(&state_, config_, &fs_);
139 EXPECT_EQ(0u, fs_.files_removed_.size());
147 fs_.files_removed_.clear();
151 EXPECT_EQ(0u, fs_.files_removed_.size());
157 " command = cat -e $in > $out\n" 158 "build in1: cat_e src1\n" 159 "build out1: cat in1\n" 160 "build in2: cat_e src2\n" 161 "build out2: cat in2\n"));
162 fs_.Create(
"in1",
"");
163 fs_.Create(
"out1",
"");
164 fs_.Create(
"in2",
"");
165 fs_.Create(
"out2",
"");
167 Cleaner cleaner(&state_, config_, &fs_);
172 EXPECT_EQ(2u, fs_.files_removed_.size());
180 fs_.files_removed_.clear();
184 EXPECT_EQ(0u, fs_.files_removed_.size());
190 " command = cat -e $in > $out\n" 191 "build in1: cat_e src1\n" 192 "build out1: cat in1\n" 193 "build in2: cat_e src2\n" 194 "build out2: cat in2\n"));
195 fs_.Create(
"in1",
"");
196 fs_.Create(
"out1",
"");
197 fs_.Create(
"in2",
"");
198 fs_.Create(
"out2",
"");
200 config_.dry_run =
true;
201 Cleaner cleaner(&state_, config_, &fs_);
206 EXPECT_EQ(0u, fs_.files_removed_.size());
214 fs_.files_removed_.clear();
218 EXPECT_EQ(0u, fs_.files_removed_.size());
224 " command = cat $in > $out\n" 226 "build out1: cat in1\n" 227 "build out2: regen in2\n"));
228 fs_.Create(
"out1",
"");
229 fs_.Create(
"out2",
"");
231 Cleaner cleaner(&state_, config_, &fs_);
234 EXPECT_EQ(1u, fs_.files_removed_.size());
236 fs_.Create(
"out1",
"");
240 EXPECT_EQ(2u, fs_.files_removed_.size());
246 " command = cc $in > $out\n" 247 " depfile = $out.d\n" 248 "build out1: cc in1\n"));
249 fs_.Create(
"out1",
"");
250 fs_.Create(
"out1.d",
"");
252 Cleaner cleaner(&state_, config_, &fs_);
255 EXPECT_EQ(2u, fs_.files_removed_.size());
261 " command = cc $in > $out\n" 262 " depfile = $out.d\n" 263 "build out1: cc in1\n"));
264 fs_.Create(
"out1",
"");
265 fs_.Create(
"out1.d",
"");
267 Cleaner cleaner(&state_, config_, &fs_);
270 EXPECT_EQ(2u, fs_.files_removed_.size());
276 " command = cc $in > $out\n" 277 " depfile = $out.d\n" 278 "build out1: cc in1\n"));
279 fs_.Create(
"out1",
"");
280 fs_.Create(
"out1.d",
"");
282 Cleaner cleaner(&state_, config_, &fs_);
285 EXPECT_EQ(2u, fs_.files_removed_.size());
291 " command = cc $in > $out\n" 292 " rspfile = $rspfile\n" 293 " rspfile_content=$in\n" 294 "build out1: cc in1\n" 295 " rspfile = cc1.rsp\n"));
296 fs_.Create(
"out1",
"");
297 fs_.Create(
"cc1.rsp",
"");
299 Cleaner cleaner(&state_, config_, &fs_);
302 EXPECT_EQ(2u, fs_.files_removed_.size());
308 " command = cat $rspfile > $out\n" 309 " rspfile = $rspfile\n" 310 " rspfile_content = $in\n" 311 "build in1: cat src1\n" 312 "build out1: cat in1\n" 313 "build in2: cat_rsp src2\n" 315 "build out2: cat_rsp in2\n" 316 " rspfile=out2.rsp\n" 318 fs_.Create(
"in1",
"");
319 fs_.Create(
"out1",
"");
320 fs_.Create(
"in2.rsp",
"");
321 fs_.Create(
"out2.rsp",
"");
322 fs_.Create(
"in2",
"");
323 fs_.Create(
"out2",
"");
325 Cleaner cleaner(&state_, config_, &fs_);
334 EXPECT_EQ(6u, fs_.files_removed_.size());
343 EXPECT_EQ(0, fs_.Stat(
"out2.rsp", &err));
348 "build dir: cat src1\n"));
350 Cleaner cleaner(&state_, config_, &fs_);
357 "build phony: phony t1 t2\n" 361 fs_.Create(
"phony",
"");
362 fs_.Create(
"t1",
"");
363 fs_.Create(
"t2",
"");
366 Cleaner cleaner(&state_, config_, &fs_);
371 fs_.Create(
"t1",
"");
372 fs_.Create(
"t2",
"");
383 " command = cc $in > $out\n" 384 " depfile = $out.d\n" 386 " command = cc $in > $out\n" 387 " rspfile = $out.rsp\n" 388 " rspfile_content = $in\n" 389 "build out$ 1: cc_dep in$ 1\n" 390 "build out$ 2: cc_rsp in$ 1\n" 392 fs_.Create(
"out 1",
"");
393 fs_.Create(
"out 2",
"");
394 fs_.Create(
"out 1.d",
"");
395 fs_.Create(
"out 2.rsp",
"");
397 Cleaner cleaner(&state_, config_, &fs_);
400 EXPECT_EQ(4u, fs_.files_removed_.size());
406 EXPECT_EQ(0, fs_.Stat(
"out 2.rsp", &err));
An implementation of DiskInterface that uses an in-memory representation of disk state.
void AssertParse(State *state, const char *input, ManifestParserOptions opts)
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.
int cleaned_files_count() const
TEST_F(CleanTest, CleanAll)
#define ASSERT_NO_FATAL_FAILURE(a)
Options (e.g. verbosity, parallelism) passed to a build.
int CleanTarget(Node *target)
Clean the given target and all the file built for it.