summaryrefslogtreecommitdiffstats
path: root/src/disk_interface_test.cc
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-09-02 18:03:01 (GMT)
committerEvan Martin <martine@danga.com>2012-09-02 18:05:51 (GMT)
commitfd91e0dc26d18209f7625730bb0e653f8321fff9 (patch)
tree3220f1082693486d0b2ba196afe3e791aecff3c7 /src/disk_interface_test.cc
parentdf6d995790ee15317fd9ddb47c9d59f30265afe5 (diff)
downloadNinja-fd91e0dc26d18209f7625730bb0e653f8321fff9.zip
Ninja-fd91e0dc26d18209f7625730bb0e653f8321fff9.tar.gz
Ninja-fd91e0dc26d18209f7625730bb0e653f8321fff9.tar.bz2
split out dirty recomputation logic from Edge class
Rather than passing States and DiskInterfaces through all the calls, put the necessary ambient information in a new DependencyScan object and move the code accordingly. Note: I didn't move the source location of the functions to preserve history, though this does result in a sort of weird order for the functions in graph.cc.
Diffstat (limited to 'src/disk_interface_test.cc')
-rw-r--r--src/disk_interface_test.cc11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/disk_interface_test.cc b/src/disk_interface_test.cc
index 985e991..68a6ca9 100644
--- a/src/disk_interface_test.cc
+++ b/src/disk_interface_test.cc
@@ -105,6 +105,8 @@ TEST_F(DiskInterfaceTest, RemoveFile) {
struct StatTest : public StateTestWithBuiltinRules,
public DiskInterface {
+ StatTest() : scan_(&state_, this) {}
+
// DiskInterface implementation.
virtual TimeStamp Stat(const string& path);
virtual bool WriteFile(const string& path, const string& contents) {
@@ -124,6 +126,7 @@ struct StatTest : public StateTestWithBuiltinRules,
return 0;
}
+ DependencyScan scan_;
map<string, TimeStamp> mtimes_;
vector<string> stats_;
};
@@ -143,7 +146,7 @@ TEST_F(StatTest, Simple) {
Node* out = GetNode("out");
out->Stat(this);
ASSERT_EQ(1u, stats_.size());
- out->in_edge()->RecomputeDirty(NULL, this, NULL);
+ scan_.RecomputeDirty(out->in_edge(), NULL);
ASSERT_EQ(2u, stats_.size());
ASSERT_EQ("out", stats_[0]);
ASSERT_EQ("in", stats_[1]);
@@ -157,7 +160,7 @@ TEST_F(StatTest, TwoStep) {
Node* out = GetNode("out");
out->Stat(this);
ASSERT_EQ(1u, stats_.size());
- out->in_edge()->RecomputeDirty(NULL, this, NULL);
+ scan_.RecomputeDirty(out->in_edge(), NULL);
ASSERT_EQ(3u, stats_.size());
ASSERT_EQ("out", stats_[0]);
ASSERT_TRUE(GetNode("out")->dirty());
@@ -175,7 +178,7 @@ TEST_F(StatTest, Tree) {
Node* out = GetNode("out");
out->Stat(this);
ASSERT_EQ(1u, stats_.size());
- out->in_edge()->RecomputeDirty(NULL, this, NULL);
+ scan_.RecomputeDirty(out->in_edge(), NULL);
ASSERT_EQ(1u + 6u, stats_.size());
ASSERT_EQ("mid1", stats_[1]);
ASSERT_TRUE(GetNode("mid1")->dirty());
@@ -194,7 +197,7 @@ TEST_F(StatTest, Middle) {
Node* out = GetNode("out");
out->Stat(this);
ASSERT_EQ(1u, stats_.size());
- out->in_edge()->RecomputeDirty(NULL, this, NULL);
+ scan_.RecomputeDirty(out->in_edge(), NULL);
ASSERT_FALSE(GetNode("in")->dirty());
ASSERT_TRUE(GetNode("mid")->dirty());
ASSERT_TRUE(GetNode("out")->dirty());