summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2013-04-22 15:05:01 (GMT)
committerEvan Martin <martine@danga.com>2013-04-22 15:05:01 (GMT)
commit722bfc52a2800502f0ac2a05d4760818ae2ef9e6 (patch)
tree2656b8059853392f494e351ca0915fafaa9a2799
parentc57fd1a903cb342dc414307088352cdb550d3641 (diff)
parent01ae2fbae0fc44171ecddcbdeee1a572b477a691 (diff)
downloadNinja-722bfc52a2800502f0ac2a05d4760818ae2ef9e6.zip
Ninja-722bfc52a2800502f0ac2a05d4760818ae2ef9e6.tar.gz
Ninja-722bfc52a2800502f0ac2a05d4760818ae2ef9e6.tar.bz2
Merge pull request #552 from nico/deps_dryrun
Don't record deps in dry runs.
-rw-r--r--src/build.cc2
-rw-r--r--src/build_test.cc31
2 files changed, 31 insertions, 2 deletions
diff --git a/src/build.cc b/src/build.cc
index fed3065..5cf9d27 100644
--- a/src/build.cc
+++ b/src/build.cc
@@ -787,7 +787,7 @@ void Builder::FinishCommand(CommandRunner::Result* result) {
restat_mtime);
}
- if (!deps_type.empty()) {
+ if (!deps_type.empty() && !config_.dry_run) {
assert(edge->outputs_.size() == 1 && "should have been rejected by parser");
Node* out = edge->outputs_[0];
TimeStamp deps_mtime = disk_interface_->Stat(out->path());
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();
+}