summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEvan Martin <martine@danga.com>2012-01-16 18:31:43 (GMT)
committerEvan Martin <martine@danga.com>2012-01-16 18:31:43 (GMT)
commit63013b3bd5ca79d454a95a6f985d98f16f21da1c (patch)
treef05edbc76e32b273bfd079df4cd097050e941cac /src
parent25a3bb074633dc1217f7fd2bc3702d12d20c1761 (diff)
parent63ccd6065504862963574dd93340a0e9c7ad35f6 (diff)
downloadNinja-63013b3bd5ca79d454a95a6f985d98f16f21da1c.zip
Ninja-63013b3bd5ca79d454a95a6f985d98f16f21da1c.tar.gz
Ninja-63013b3bd5ca79d454a95a6f985d98f16f21da1c.tar.bz2
Merge pull request #197 from doctorlove/simple_dry_run
Simple dry run
Diffstat (limited to 'src')
-rw-r--r--src/build.cc2
-rw-r--r--src/build_test.cc36
-rw-r--r--src/test.h1
-rw-r--r--src/util.h1
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());
+}
+
diff --git a/src/test.h b/src/test.h
index df544c6..d730151 100644
--- a/src/test.h
+++ b/src/test.h
@@ -19,6 +19,7 @@
#include "disk_interface.h"
#include "state.h"
+#include "util.h"
// Support utilites for tests.
diff --git a/src/util.h b/src/util.h
index 04f0a90..0ae2743 100644
--- a/src/util.h
+++ b/src/util.h
@@ -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();