diff options
-rw-r--r-- | src/build.cc | 2 | ||||
-rw-r--r-- | src/build_test.cc | 36 | ||||
-rw-r--r-- | src/test.h | 1 | ||||
-rw-r--r-- | src/util.h | 1 |
4 files changed, 39 insertions, 1 deletions
diff --git a/src/build.cc b/src/build.cc index ebf63b2..94c9d77 100644 --- a/src/build.cc +++ b/src/build.cc @@ -572,7 +572,7 @@ void Builder::FinishEdge(Edge* edge, bool success, const string& output) { TimeStamp restat_mtime = 0; if (success) { - if (edge->rule().restat()) { + if (edge->rule().restat() && !config_.dry_run) { bool node_cleaned = false; for (vector<Node*>::iterator i = edge->outputs_.begin(); diff --git a/src/build_test.cc b/src/build_test.cc index 7f977a6..497faa4 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -772,3 +772,39 @@ TEST_F(BuildWithLogTest, RestatMissingFile) { EXPECT_TRUE(builder_.Build(&err)); ASSERT_EQ(1u, commands_ran_.size()); } + +struct BuildDryRun : public BuildWithLogTest { + BuildDryRun() { + config_.dry_run = true; + } +}; + +TEST_F(BuildDryRun, AllCommandsShown) { + ASSERT_NO_FATAL_FAILURE(AssertParse(&state_, +"rule true\n" +" command = true\n" +" restat = 1\n" +"rule cc\n" +" command = cc\n" +" restat = 1\n" +"build out1: cc in\n" +"build out2: true out1\n" +"build out3: cat out2\n")); + + fs_.Create("out1", now_, ""); + fs_.Create("out2", now_, ""); + fs_.Create("out3", now_, ""); + + now_++; + + fs_.Create("in", now_, ""); + + // "cc" touches out1, so we should build out2. But because "true" does not + // touch out2, we should cancel the build of out3. + string err; + EXPECT_TRUE(builder_.AddTarget("out3", &err)); + ASSERT_EQ("", err); + EXPECT_TRUE(builder_.Build(&err)); + ASSERT_EQ(3u, commands_ran_.size()); +} + @@ -19,6 +19,7 @@ #include "disk_interface.h" #include "state.h" +#include "util.h" // Support utilites for tests. @@ -69,6 +69,7 @@ const char* SpellcheckString(const string& text, ...); #define snprintf _snprintf #define fileno _fileno #define unlink _unlink +#define chdir _chdir /// Convert the value returned by GetLastError() into a string. string GetLastErrorString(); |