From c5051522f39a3d58c85e0e110ea2a14dc2b17927 Mon Sep 17 00:00:00 2001
From: Qingning Huo <qingninghuo@gmail.com>
Date: Tue, 14 Jun 2011 22:54:30 +0100
Subject: Add a test for the multiple outputs fix

---
 src/build_test.cc | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/src/build_test.cc b/src/build_test.cc
index 813521c..282e4b7 100644
--- a/src/build_test.cc
+++ b/src/build_test.cc
@@ -246,7 +246,8 @@ bool BuildTest::CanRunMore() {
 bool BuildTest::StartCommand(Edge* edge) {
   assert(!last_command_);
   commands_ran_.push_back(edge->EvaluateCommand());
-  if (edge->rule_->name_ == "cat" || edge->rule_->name_ == "cc") {
+  if (edge->rule_->name_ == "cat" || edge->rule_->name_ == "cc" ||
+        edge->rule_->name_ == "touch") {
     for (vector<Node*>::iterator out = edge->outputs_.begin();
          out != edge->outputs_.end(); ++out) {
       (*out)->file_->mtime_ = now_;
@@ -339,6 +340,23 @@ TEST_F(BuildTest, TwoStep) {
   EXPECT_EQ("cat cat1 cat2 > cat12", commands_ran_[4]);
 }
 
+TEST_F(BuildTest, TwoOutputs) {
+  ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"rule touch\n"
+"  command = touch $out\n"
+"build out1 out2: touch in.txt\n"));
+
+  fs_.Create("in.txt", now_, "");
+
+  string err;
+  EXPECT_TRUE(builder_.AddTarget("out1", &err));
+  ASSERT_EQ("", err);
+  EXPECT_TRUE(builder_.Build(&err));
+  EXPECT_EQ("", err);
+  ASSERT_EQ(1u, commands_ran_.size());
+  EXPECT_EQ("touch out1 out2", commands_ran_[0]);
+}
+
 TEST_F(BuildTest, Chain) {
   ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
 "build c2: cat c1\n"
-- 
cgit v0.12

