Skip to content

Commit

Permalink
Add a test for the multiple outputs fix
Browse files Browse the repository at this point in the history
  • Loading branch information
qhuo committed Jun 14, 2011
1 parent edc4062 commit c505152
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/build_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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_;
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit c505152

Please sign in to comment.