summaryrefslogtreecommitdiffstats
path: root/src/build_test.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-01-05 23:20:07 (GMT)
committerEvan Martin <martine@danga.com>2012-01-05 23:20:07 (GMT)
commitc633f316d74375b49808a0e98511ff224d519746 (patch)
tree0d880c4ecaecadc5106ee68ad45906584668888a /src/build_test.cc
parentd5165bafdabbfba23d33a5e0ceb9e0e680384183 (diff)
downloadNinja-c633f316d74375b49808a0e98511ff224d519746.zip
Ninja-c633f316d74375b49808a0e98511ff224d519746.tar.gz
Ninja-c633f316d74375b49808a0e98511ff224d519746.tar.bz2
adjust restat behavior around missing outputs
If a restat rule claims to write an output but doesn't, consider it "no change" (in the restat sense) if the output didn't exist beforehand. I.e. if the output didn't exist before and the output doesn't exist after, we don't need to run dependent rules.
Diffstat (limited to 'src/build_test.cc')
-rw-r--r--src/build_test.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/build_test.cc b/src/build_test.cc
index 40d116f..7f977a6 100644
--- a/src/build_test.cc
+++ b/src/build_test.cc
@@ -745,3 +745,30 @@ TEST_F(BuildWithLogTest, RestatTest) {
EXPECT_TRUE(builder_.Build(&err));
ASSERT_EQ(2u, commands_ran_.size());
}
+
+TEST_F(BuildWithLogTest, RestatMissingFile) {
+ // If a restat rule doesn't create its output, and the output didn't
+ // exist before the rule was run, consider that behavior equivalent
+ // to a rule that doesn't modify its existent output file.
+
+ ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"rule true\n"
+" command = true\n"
+" restat = 1\n"
+"rule cc\n"
+" command = cc\n"
+"build out1: true in\n"
+"build out2: cc out1\n"));
+
+ fs_.Create("in", now_, "");
+ fs_.Create("out2", now_, "");
+
+ // Run a build, expect only the first command to run.
+ // It doesn't touch its output (due to being the "true" command), so
+ // we shouldn't run the dependent build.
+ string err;
+ EXPECT_TRUE(builder_.AddTarget("out2", &err));
+ ASSERT_EQ("", err);
+ EXPECT_TRUE(builder_.Build(&err));
+ ASSERT_EQ(1u, commands_ran_.size());
+}