diff options
author | Evan Martin <martine@danga.com> | 2013-06-06 17:54:53 (GMT) |
---|---|---|
committer | Evan Martin <martine@danga.com> | 2013-06-06 17:54:53 (GMT) |
commit | 75918b84f78aaca2133f21622374019cd2ef17ee (patch) | |
tree | 2a7ad722a64bf96e03e8d5a6be4d92ba3d6438e4 | |
parent | 46405b1fabb9a63f3b88db394b6e58ac9ea1332c (diff) | |
parent | 456b0d4fdb206b692fb394f35bc626708b318981 (diff) | |
download | Ninja-75918b84f78aaca2133f21622374019cd2ef17ee.zip Ninja-75918b84f78aaca2133f21622374019cd2ef17ee.tar.gz Ninja-75918b84f78aaca2133f21622374019cd2ef17ee.tar.bz2 |
Merge pull request #593 from nico/moretest
Add a test for CreatePhonyInEdge() in depsmode path.
-rw-r--r-- | src/build_test.cc | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/src/build_test.cc b/src/build_test.cc index 5089607..313a386 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -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(); + } +} |