check in failing chain test
authorEvan Martin <martine@danga.com>
Wed, 20 Oct 2010 07:03:09 +0000 (00:03 -0700)
committerEvan Martin <martine@danga.com>
Wed, 20 Oct 2010 07:03:09 +0000 (00:03 -0700)
ninja.h
ninja_test.cc

diff --git a/ninja.h b/ninja.h
index 3db903c..a7728b5 100644 (file)
--- a/ninja.h
+++ b/ninja.h
@@ -13,12 +13,16 @@ using namespace std;
 
 struct Node;
 struct FileStat {
-  FileStat(const string& path) : path_(path), mtime_(0), node_(NULL) {}
+  FileStat(const string& path) : path_(path), mtime_(-1), node_(NULL) {}
   void Touch(int mtime);
   // Return true if the file exists (mtime_ got a value).
   bool Stat();
 
   string path_;
+  // Possible values of mtime_:
+  //   -1: file hasn't been examined
+  //   0:  we looked, and file doesn't exist
+  //   >0: actual file's mtime
   time_t mtime_;
   Node* node_;
 };
index 95bfa32..1f466c1 100644 (file)
@@ -156,7 +156,12 @@ void BuildTest::LoadManifest() {
 "\n"
 "build cat1: cat in1\n"
 "build cat2: cat in1 in2\n"
-"build cat12: cat cat1 cat2\n",
+"build cat12: cat cat1 cat2\n"
+"\n"
+"build c2: cat c1\n"
+"build c3: cat c2\n"
+"build c4: cat c3\n"
+"build c5: cat c4\n",
       &err));
   ASSERT_EQ("", err);
 }
@@ -237,3 +242,11 @@ TEST_F(BuildTest, TwoStep) {
   EXPECT_EQ("cat in1 in2 > cat2", commands_ran_[3]);
   EXPECT_EQ("cat cat1 cat2 > cat12", commands_ran_[4]);
 }
+
+TEST_F(BuildTest, Chain) {
+  string err;
+  builder_.AddTarget("c5");
+  EXPECT_TRUE(builder_.Build(this, &err));
+  EXPECT_EQ("", err);
+  ASSERT_EQ(5, commands_ran_.size());
+}