summaryrefslogtreecommitdiffstats
path: root/src/deps_log_test.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2013-01-07 18:59:27 (GMT)
committerEvan Martin <martine@danga.com>2013-04-08 22:01:36 (GMT)
commitab218230c4c6c3f0bb2a26215d1ac09e397e6065 (patch)
tree46bbac03e80bd3fedf223554d8585955af8f36c7 /src/deps_log_test.cc
parent58c7139b9f404e18097d4f3ef6adcd49a01e3d73 (diff)
downloadNinja-ab218230c4c6c3f0bb2a26215d1ac09e397e6065.zip
Ninja-ab218230c4c6c3f0bb2a26215d1ac09e397e6065.tar.gz
Ninja-ab218230c4c6c3f0bb2a26215d1ac09e397e6065.tar.bz2
don't write out deps entries if nothing changed
Shortcuts a common case.
Diffstat (limited to 'src/deps_log_test.cc')
-rw-r--r--src/deps_log_test.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/deps_log_test.cc b/src/deps_log_test.cc
index 3f47fef..e411e12 100644
--- a/src/deps_log_test.cc
+++ b/src/deps_log_test.cc
@@ -76,4 +76,50 @@ TEST_F(DepsLogTest, WriteRead) {
ASSERT_EQ("bar.h", deps->nodes[1]->path());
}
+// Verify that adding the same deps twice doesn't grow the file.
+TEST_F(DepsLogTest, DoubleEntry) {
+ // Write some deps to the file and grab its size.
+ int file_size;
+ {
+ State state;
+ DepsLog log;
+ string err;
+ EXPECT_TRUE(log.OpenForWrite(kTestFilename, &err));
+ ASSERT_EQ("", err);
+
+ vector<Node*> deps;
+ deps.push_back(state.GetNode("foo.h"));
+ deps.push_back(state.GetNode("bar.h"));
+ log.RecordDeps(state.GetNode("out.o"), 1, deps);
+ log.Close();
+
+ struct stat st;
+ ASSERT_EQ(0, stat(kTestFilename, &st));
+ file_size = (int)st.st_size;
+ ASSERT_GT(file_size, 0);
+ }
+
+ // Now reload the file, and readd the same deps.
+ {
+ State state;
+ DepsLog log;
+ string err;
+ EXPECT_TRUE(log.Load(kTestFilename, &state, &err));
+
+ EXPECT_TRUE(log.OpenForWrite(kTestFilename, &err));
+ ASSERT_EQ("", err);
+
+ vector<Node*> deps;
+ deps.push_back(state.GetNode("foo.h"));
+ deps.push_back(state.GetNode("bar.h"));
+ log.RecordDeps(state.GetNode("out.o"), 1, deps);
+ log.Close();
+
+ struct stat st;
+ ASSERT_EQ(0, stat(kTestFilename, &st));
+ int file_size_2 = (int)st.st_size;
+ ASSERT_EQ(file_size, file_size_2);
+ }
+}
+
} // anonymous namespace