diff options
author | Nico Weber <nicolasweber@gmx.de> | 2013-04-22 00:55:10 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2013-04-22 00:56:43 (GMT) |
commit | a83020b750e7b3c8c801fcf79ebe94d7dd4840dd (patch) | |
tree | f5ec3fc917cd9ae39935c93edaafdef67ea721a0 /src | |
parent | c57fd1a903cb342dc414307088352cdb550d3641 (diff) | |
download | Ninja-a83020b750e7b3c8c801fcf79ebe94d7dd4840dd.zip Ninja-a83020b750e7b3c8c801fcf79ebe94d7dd4840dd.tar.gz Ninja-a83020b750e7b3c8c801fcf79ebe94d7dd4840dd.tar.bz2 |
Don't record deps in dry runs.
deps_log() is NULL during dry runs, so this fixes a crash. It also
matches ninja 1.2.0's behavior as far as I can tell.
Fixes issue #551.
Diffstat (limited to 'src')
-rw-r--r-- | src/build.cc | 4 | ||||
-rw-r--r-- | src/build_test.cc | 31 |
2 files changed, 33 insertions, 2 deletions
diff --git a/src/build.cc b/src/build.cc index fed3065..c9842ce 100644 --- a/src/build.cc +++ b/src/build.cc @@ -715,7 +715,9 @@ void Builder::FinishCommand(CommandRunner::Result* result) { // extraction itself can fail, which makes the command fail from a // build perspective. vector<Node*> deps_nodes; - string deps_type = edge->GetBinding("deps"); + string deps_type; + if (!config_.dry_run) + deps_type = edge->GetBinding("deps"); if (!deps_type.empty()) { string extract_err; if (!ExtractDeps(result, deps_type, &deps_nodes, &extract_err) && diff --git a/src/build_test.cc b/src/build_test.cc index 827998b..68a5142 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -1353,7 +1353,7 @@ TEST_F(BuildTest, PhonyWithNoInputs) { ASSERT_EQ(1u, command_runner_.commands_ran_.size()); } -TEST_F(BuildTest, DepsGccWithEmptyDeps) { +TEST_F(BuildTest, DepsGccWithEmptyDepfileErrorsOut) { ASSERT_NO_FATAL_FAILURE(AssertParse(&state_, "rule cc\n" " command = cc\n" @@ -1554,3 +1554,32 @@ TEST_F(BuildWithDepsLogTest, ObsoleteDeps) { builder.command_runner_.release(); } } + +TEST_F(BuildWithDepsLogTest, DepsIgnoredInDryRun) { + const char* manifest = + "build out: cat in1\n" + " deps = gcc\n" + " depfile = in1.d\n"; + + fs_.Create("out", ""); + fs_.Tick(); + fs_.Create("in1", ""); + + State state; + ASSERT_NO_FATAL_FAILURE(AddCatRule(&state)); + ASSERT_NO_FATAL_FAILURE(AssertParse(&state, manifest)); + + // The deps log is NULL in dry runs. + config_.dry_run = true; + Builder builder(&state, config_, NULL, NULL, &fs_); + builder.command_runner_.reset(&command_runner_); + command_runner_.commands_ran_.clear(); + + string err; + EXPECT_TRUE(builder.AddTarget("out", &err)); + ASSERT_EQ("", err); + EXPECT_TRUE(builder.Build(&err)); + ASSERT_EQ(1u, command_runner_.commands_ran_.size()); + + builder.command_runner_.release(); +} |