Skip to content

Commit

Permalink
Merge pull request ninja-build#592 from nico/addtest
Browse files Browse the repository at this point in the history
Add test that proves `node->AddOutEdge(edge);` in `LoadDepFile()` is nee...
  • Loading branch information
nico committed Jun 6, 2013
2 parents 0f53fd3 + ca0f379 commit 46405b1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
25 changes: 24 additions & 1 deletion src/build_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1604,7 +1604,30 @@ TEST_F(BuildWithDepsLogTest, DepsIgnoredInDryRun) {
}

/// Check that a restat rule generating a header cancels compilations correctly.
TEST_F(BuildWithDepsLogTest, RestatDepfileDependency) {
TEST_F(BuildTest, RestatDepfileDependency) {
ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
"rule true\n"
" command = true\n" // Would be "write if out-of-date" in reality.
" restat = 1\n"
"build header.h: true header.in\n"
"build out: cat in1\n"
" depfile = in1.d\n"));

fs_.Create("header.h", "");
fs_.Create("in1.d", "out: header.h");
fs_.Tick();
fs_.Create("header.in", "");

string err;
EXPECT_TRUE(builder_.AddTarget("out", &err));
ASSERT_EQ("", err);
EXPECT_TRUE(builder_.Build(&err));
EXPECT_EQ("", err);
}

/// Check that a restat rule generating a header cancels compilations correctly,
/// depslog case.
TEST_F(BuildWithDepsLogTest, RestatDepfileDependencyDepsLog) {
string err;
// Note: in1 was created by the superclass SetUp().
const char* manifest =
Expand Down
7 changes: 4 additions & 3 deletions src/graph.cc
Original file line number Diff line number Diff line change
Expand Up @@ -417,9 +417,10 @@ bool ImplicitDepLoader::LoadDepsFromLog(Edge* edge, TimeStamp* deps_mtime,
vector<Node*>::iterator implicit_dep =
PreallocateSpace(edge, deps->node_count);
for (int i = 0; i < deps->node_count; ++i, ++implicit_dep) {
*implicit_dep = deps->nodes[i];
deps->nodes[i]->AddOutEdge(edge);
CreatePhonyInEdge(*implicit_dep);
Node* node = deps->nodes[i];
*implicit_dep = node;
node->AddOutEdge(edge);
CreatePhonyInEdge(node);
}
return true;
}
Expand Down

0 comments on commit 46405b1

Please sign in to comment.