summaryrefslogtreecommitdiffstats
path: root/src/clean_test.cc
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-02-12 14:16:50 (GMT)
committerBrad King <brad.king@kitware.com>2019-04-18 12:21:44 (GMT)
commita3cbb4d4ddbd3661720603cc26b25cad6177b4c8 (patch)
tree77c2fbdb481653ae300342b025d2af9438f3e9a9 /src/clean_test.cc
parentc21f3f2a1d8cb0aea45804ffc788947c4096281b (diff)
downloadNinja-a3cbb4d4ddbd3661720603cc26b25cad6177b4c8.zip
Ninja-a3cbb4d4ddbd3661720603cc26b25cad6177b4c8.tar.gz
Ninja-a3cbb4d4ddbd3661720603cc26b25cad6177b4c8.tar.bz2
clean: remove outputs specified by dyndep files
Some outputs may not be known in the main build manifest and are instead discovered through a dyndep binding. Load dyndep files that are available during cleaning so that we can clean these outputs too.
Diffstat (limited to 'src/clean_test.cc')
-rw-r--r--src/clean_test.cc49
1 files changed, 49 insertions, 0 deletions
diff --git a/src/clean_test.cc b/src/clean_test.cc
index 63734ac..45187f4 100644
--- a/src/clean_test.cc
+++ b/src/clean_test.cc
@@ -285,6 +285,55 @@ TEST_F(CleanTest, CleanDepFileOnCleanRule) {
EXPECT_EQ(2u, fs_.files_removed_.size());
}
+TEST_F(CleanTest, CleanDyndep) {
+ // Verify that a dyndep file can be loaded to discover a new output
+ // to be cleaned.
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"build out: cat in || dd\n"
+" dyndep = dd\n"
+ ));
+ fs_.Create("in", "");
+ fs_.Create("dd",
+"ninja_dyndep_version = 1\n"
+"build out | out.imp: dyndep\n"
+);
+ fs_.Create("out", "");
+ fs_.Create("out.imp", "");
+
+ Cleaner cleaner(&state_, config_, &fs_);
+
+ ASSERT_EQ(0, cleaner.cleaned_files_count());
+ EXPECT_EQ(0, cleaner.CleanAll());
+ EXPECT_EQ(2, cleaner.cleaned_files_count());
+ EXPECT_EQ(2u, fs_.files_removed_.size());
+
+ string err;
+ EXPECT_EQ(0, fs_.Stat("out", &err));
+ EXPECT_EQ(0, fs_.Stat("out.imp", &err));
+}
+
+TEST_F(CleanTest, CleanDyndepMissing) {
+ // Verify that a missing dyndep file is tolerated.
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"build out: cat in || dd\n"
+" dyndep = dd\n"
+ ));
+ fs_.Create("in", "");
+ fs_.Create("out", "");
+ fs_.Create("out.imp", "");
+
+ Cleaner cleaner(&state_, config_, &fs_);
+
+ ASSERT_EQ(0, cleaner.cleaned_files_count());
+ EXPECT_EQ(0, cleaner.CleanAll());
+ EXPECT_EQ(1, cleaner.cleaned_files_count());
+ EXPECT_EQ(1u, fs_.files_removed_.size());
+
+ string err;
+ EXPECT_EQ(0, fs_.Stat("out", &err));
+ EXPECT_EQ(1, fs_.Stat("out.imp", &err));
+}
+
TEST_F(CleanTest, CleanRspFile) {
ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
"rule cc\n"