Skip to content

Commit

Permalink
Add a test for CreatePhonyInEdge() in depsmode path.
Browse files Browse the repository at this point in the history
Removing the `CreatePhonyInEdge(node);` line in
`ImplicitDepLoader::LoadDepsFromLog()` made no tests fail before this change.
The new test is a port to depsmode of the existing DepFileOK test.
  • Loading branch information
nico committed Jun 6, 2013
1 parent 46405b1 commit 456b0d4
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions src/build_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1689,3 +1689,64 @@ TEST_F(BuildWithDepsLogTest, RestatDepfileDependencyDepsLog) {
builder.command_runner_.release();
}
}

TEST_F(BuildWithDepsLogTest, DepFileOKDepsLog) {
string err;
const char* manifest =
"rule cc\n command = cc $in\n depfile = $out.d\n deps = gcc\n"
"build foo.o: cc foo.c\n";

fs_.Create("foo.c", "");

{
State state;
ASSERT_NO_FATAL_FAILURE(AssertParse(&state, manifest));

// Run the build once, everything should be ok.
DepsLog deps_log;
ASSERT_TRUE(deps_log.OpenForWrite("ninja_deps", &err));
ASSERT_EQ("", err);

Builder builder(&state, config_, NULL, &deps_log, &fs_);
builder.command_runner_.reset(&command_runner_);
EXPECT_TRUE(builder.AddTarget("foo.o", &err));
ASSERT_EQ("", err);
fs_.Create("foo.o.d", "foo.o: blah.h bar.h\n");
EXPECT_TRUE(builder.Build(&err));
EXPECT_EQ("", err);

deps_log.Close();
builder.command_runner_.release();
}

{
State state;
ASSERT_NO_FATAL_FAILURE(AssertParse(&state, manifest));

DepsLog deps_log;
ASSERT_TRUE(deps_log.Load("ninja_deps", &state, &err));
ASSERT_TRUE(deps_log.OpenForWrite("ninja_deps", &err));
ASSERT_EQ("", err);

Builder builder(&state, config_, NULL, &deps_log, &fs_);
builder.command_runner_.reset(&command_runner_);

Edge* edge = state.edges_.back();

state.GetNode("bar.h")->MarkDirty(); // Mark bar.h as missing.
EXPECT_TRUE(builder.AddTarget("foo.o", &err));
ASSERT_EQ("", err);

// Expect three new edges: one generating foo.o, and two more from
// loading the depfile.
ASSERT_EQ(3, (int)state.edges_.size());
// Expect our edge to now have three inputs: foo.c and two headers.
ASSERT_EQ(3u, edge->inputs_.size());

// Expect the command line we generate to only use the original input.
ASSERT_EQ("cc foo.c", edge->EvaluateCommand());

deps_log.Close();
builder.command_runner_.release();
}
}

0 comments on commit 456b0d4

Please sign in to comment.