diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2011-09-11 21:54:00 (GMT) |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2011-09-14 02:01:11 (GMT) |
commit | 22c309760a5a38ccc88a6f700e101868236ce4ab (patch) | |
tree | 520bdb2cac679773f6cb5870756b26a9cd061ea3 | |
parent | 3fbb25b2cc66f236a39b728d20e5d44da23612ac (diff) | |
download | Ninja-22c309760a5a38ccc88a6f700e101868236ce4ab.zip Ninja-22c309760a5a38ccc88a6f700e101868236ce4ab.tar.gz Ninja-22c309760a5a38ccc88a6f700e101868236ce4ab.tar.bz2 |
Modify the build tests to use the virtual file system
-rw-r--r-- | src/build_test.cc | 21 | ||||
-rw-r--r-- | src/stat_cache.cc | 5 | ||||
-rw-r--r-- | src/stat_cache.h | 2 |
3 files changed, 21 insertions, 7 deletions
diff --git a/src/build_test.cc b/src/build_test.cc index c8d338b..752a4b4 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -250,8 +250,7 @@ bool BuildTest::StartCommand(Edge* edge) { edge->rule_->name_ == "touch") { for (vector<Node*>::iterator out = edge->outputs_.begin(); out != edge->outputs_.end(); ++out) { - (*out)->file_->mtime_ = now_; - (*out)->dirty_ = false; + fs_.Create((*out)->file_->path_, now_, ""); } } else if (edge->rule_->name_ == "fail") { // Don't do anything. @@ -373,14 +372,17 @@ TEST_F(BuildTest, Chain) { err.clear(); commands_ran_.clear(); + state_.stat_cache_.Invalidate(); EXPECT_TRUE(builder_.AddTarget("c5", &err)); ASSERT_EQ("", err); EXPECT_TRUE(builder_.AlreadyUpToDate()); - GetNode("c4")->dirty_ = true; - GetNode("c5")->dirty_ = true; + now_++; + + fs_.Create("c3", now_, ""); err.clear(); commands_ran_.clear(); + state_.stat_cache_.Invalidate(); EXPECT_TRUE(builder_.AddTarget("c5", &err)); ASSERT_EQ("", err); EXPECT_FALSE(builder_.AlreadyUpToDate()); @@ -510,17 +512,24 @@ TEST_F(BuildTest, OrderOnlyDeps) { ASSERT_EQ("", err); ASSERT_EQ(1u, commands_ran_.size()); + now_++; + // implicit dep dirty, expect a rebuild. + fs_.Create("blah.h", now_, ""); + fs_.Create("bar.h", now_, ""); commands_ran_.clear(); - GetNode("blah.h")->dirty_ = true; + state_.stat_cache_.Invalidate(); EXPECT_TRUE(builder_.AddTarget("foo.o", &err)); EXPECT_TRUE(builder_.Build(&err)); ASSERT_EQ("", err); ASSERT_EQ(1u, commands_ran_.size()); + now_++; + // order only dep dirty, no rebuild. + fs_.Create("otherfile", now_, ""); commands_ran_.clear(); - GetNode("otherfile")->dirty_ = true; + state_.stat_cache_.Invalidate(); EXPECT_TRUE(builder_.AddTarget("foo.o", &err)); EXPECT_EQ("", err); EXPECT_TRUE(builder_.AlreadyUpToDate()); diff --git a/src/stat_cache.cc b/src/stat_cache.cc index 75248be..0b717b4 100644 --- a/src/stat_cache.cc +++ b/src/stat_cache.cc @@ -36,3 +36,8 @@ void StatCache::Dump() { : "unknown"); } } + +void StatCache::Invalidate() { + for (Paths::iterator i = paths_.begin(); i != paths_.end(); ++i) + i->second->mtime_ = -1; +} diff --git a/src/stat_cache.h b/src/stat_cache.h index 9cb3eff..f071e59 100644 --- a/src/stat_cache.h +++ b/src/stat_cache.h @@ -29,7 +29,7 @@ struct StatCache { /// Dump the mapping to stdout (useful for debugging). void Dump(); - void Reload(); + void Invalidate(); typedef ExternalStringHashMap<FileStat*>::Type Paths; Paths paths_; |