summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2013-06-06 01:51:00 (GMT)
committerNico Weber <thakis@chromium.org>2013-06-06 01:51:00 (GMT)
commit456b0d4fdb206b692fb394f35bc626708b318981 (patch)
tree2a7ad722a64bf96e03e8d5a6be4d92ba3d6438e4 /src
parent46405b1fabb9a63f3b88db394b6e58ac9ea1332c (diff)
downloadNinja-456b0d4fdb206b692fb394f35bc626708b318981.zip
Ninja-456b0d4fdb206b692fb394f35bc626708b318981.tar.gz
Ninja-456b0d4fdb206b692fb394f35bc626708b318981.tar.bz2
Add a test for CreatePhonyInEdge() in depsmode path.
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.
Diffstat (limited to 'src')
-rw-r--r--src/build_test.cc61
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();
+ }
+}