diff options
author | Frances Buontempo <frances.buontempo@gmail.com> | 2012-01-16 14:17:37 (GMT) |
---|---|---|
committer | Frances Buontempo <frances.buontempo@gmail.com> | 2012-01-16 14:17:37 (GMT) |
commit | 63ccd6065504862963574dd93340a0e9c7ad35f6 (patch) | |
tree | f05edbc76e32b273bfd079df4cd097050e941cac /src | |
parent | 337d059edc8c9ed6db83d04c7eeb5d38f2595f6c (diff) | |
download | Ninja-63ccd6065504862963574dd93340a0e9c7ad35f6.zip Ninja-63ccd6065504862963574dd93340a0e9c7ad35f6.tar.gz Ninja-63ccd6065504862963574dd93340a0e9c7ad35f6.tar.bz2 |
Add a test that dry run shows all commands that could be run (none
cleaned) and a fix for this
Diffstat (limited to 'src')
-rw-r--r-- | src/build.cc | 2 | ||||
-rw-r--r-- | src/build_test.cc | 36 |
2 files changed, 37 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()); +} + |