summaryrefslogtreecommitdiffstats
path: root/src/build_log_test.cc
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2011-09-19 01:56:15 (GMT)
committerPeter Collingbourne <peter@pcc.me.uk>2011-10-24 00:16:38 (GMT)
commit0efbbbf67a94452919084765e87106e7748274cb (patch)
tree21c8c5a13b70d7f287b2f569a35f6a03a7f1c19d /src/build_log_test.cc
parent386cbf6c7e49c88b87f54619b06670ea9f66c8a5 (diff)
downloadNinja-0efbbbf67a94452919084765e87106e7748274cb.zip
Ninja-0efbbbf67a94452919084765e87106e7748274cb.tar.gz
Ninja-0efbbbf67a94452919084765e87106e7748274cb.tar.bz2
Implement restat rules
A restat rule is a rule which is capable of pruning the build tree depending on the timestamps of its outputs before and after a build. After a restat rule is rebuilt, Ninja will re-stat each output file to obtain its current timestamp. If the timestamp is unchanged from when Ninja initially stat'ed the file before starting the build, Ninja will mark that output file as clean, and recursively for each reverse dependency of the output file, recompute its dirty status. Ninja then stores the most recent timestamp of any input file in the build log entry associated with the output file. This timestamp will be treated by future invocations of Ninja as the output file's modification time instead of the output file's actual modification time for the purpose of deciding whether it is dirty (but not whether its reverse dependencies are dirty).
Diffstat (limited to 'src/build_log_test.cc')
-rw-r--r--src/build_log_test.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/build_log_test.cc b/src/build_log_test.cc
index fdd2378..cf31c1d 100644
--- a/src/build_log_test.cc
+++ b/src/build_log_test.cc
@@ -115,3 +115,22 @@ TEST_F(BuildLogTest, Truncate) {
ASSERT_EQ("", err);
}
}
+
+TEST_F(BuildLogTest, UpgradeV2) {
+ FILE* f = fopen(kTestFilename, "wb");
+ fprintf(f, "# ninja log v2\n");
+ fprintf(f, "123 456 out command\n");
+ fclose(f);
+
+ string err;
+ BuildLog log;
+ EXPECT_TRUE(log.Load(kTestFilename, &err));
+ ASSERT_EQ("", err);
+
+ BuildLog::LogEntry* e = log.LookupByOutput("out");
+ ASSERT_TRUE(e);
+ ASSERT_EQ(123, e->start_time);
+ ASSERT_EQ(456, e->end_time);
+ ASSERT_EQ(0, e->restat_mtime);
+ ASSERT_EQ("command", e->command);
+}