diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2012-03-05 01:35:44 (GMT) |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2012-03-05 01:53:54 (GMT) |
commit | b70b3ad28279e9d8a56d3f52c2057978a81f65f1 (patch) | |
tree | 0c9f76d9e1fdf3cdbedc0ad0a45b863bfc064583 /src/build_test.cc | |
parent | 2338d9340bb2c13746805b4b878c889008850962 (diff) | |
download | Ninja-b70b3ad28279e9d8a56d3f52c2057978a81f65f1.zip Ninja-b70b3ad28279e9d8a56d3f52c2057978a81f65f1.tar.gz Ninja-b70b3ad28279e9d8a56d3f52c2057978a81f65f1.tar.bz2 |
Mark a phony target with no inputs as outputs-ready
Even if such a target is dirty (i.e. the file does not exist), it
has nothing to do, which makes it safe to mark as outputs-ready.
Without this change, ninja will print no output when rebuilding the
target (or an order-only dependency thereof), instead of reporting
it has "no work to do".
Diffstat (limited to 'src/build_test.cc')
-rw-r--r-- | src/build_test.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/build_test.cc b/src/build_test.cc index ca74ab6..5b35513 100644 --- a/src/build_test.cc +++ b/src/build_test.cc @@ -996,3 +996,29 @@ TEST_F(BuildTest, InterruptCleanup) { builder_.Cleanup(); EXPECT_EQ(0, fs_.Stat("out2")); } + +TEST_F(BuildTest, PhonyWithNoInputs) { + ASSERT_NO_FATAL_FAILURE(AssertParse(&state_, +"build nonexistent: phony\n" +"build out1: cat || nonexistent\n" +"build out2: cat nonexistent\n")); + fs_.Create("out1", now_, ""); + fs_.Create("out2", now_, ""); + + // out1 should be up to date even though its input is dirty, because its + // order-only dependency has nothing to do. + string err; + EXPECT_TRUE(builder_.AddTarget("out1", &err)); + ASSERT_EQ("", err); + EXPECT_TRUE(builder_.AlreadyUpToDate()); + + // out2 should still be out of date though, because its input is dirty. + err.clear(); + commands_ran_.clear(); + state_.Reset(); + EXPECT_TRUE(builder_.AddTarget("out2", &err)); + ASSERT_EQ("", err); + EXPECT_TRUE(builder_.Build(&err)); + EXPECT_EQ("", err); + ASSERT_EQ(1u, commands_ran_.size()); +} |