From 337d059edc8c9ed6db83d04c7eeb5d38f2595f6c Mon Sep 17 00:00:00 2001 From: Frances Buontempo Date: Mon, 16 Jan 2012 13:53:08 +0000 Subject: Stop warning about chdir etc which are treated as errors on MSVC with the current settings --- src/test.h | 1 + src/util.h | 1 + 2 files changed, 2 insertions(+) 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(); -- cgit v0.12 From 63ccd6065504862963574dd93340a0e9c7ad35f6 Mon Sep 17 00:00:00 2001 From: Frances Buontempo Date: Mon, 16 Jan 2012 14:17:37 +0000 Subject: Add a test that dry run shows all commands that could be run (none cleaned) and a fix for this --- src/build.cc | 2 +- src/build_test.cc | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) 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::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()); +} + -- cgit v0.12