Add another test case covering pool release on edge failure
authorDavid Emett <dave@sp4m.net>
Sun, 20 Sep 2015 13:43:01 +0000 (14:43 +0100)
committerBrad King <brad.king@kitware.com>
Wed, 6 Apr 2016 15:24:46 +0000 (11:24 -0400)
With this build file:

    pool failpool
      depth = 1
    rule fail
      command = fail
      pool = failpool
    build out1: fail
    build out2: fail
    build out3: fail
    build final: phony out1 out2 out3

Running `ninja -k 0` should run out1..3 sequentially before failing, but
until recently we would fail after just running out1.  Add a test
covering this case.

src/build_test.cc

index 261268a..90d500c 100644 (file)
@@ -1153,6 +1153,30 @@ TEST_F(BuildTest, SwallowFailuresLimit) {
   ASSERT_EQ("cannot make progress due to previous errors", err);
 }
 
+TEST_F(BuildTest, SwallowFailuresPool) {
+  ASSERT_NO_FATAL_FAILURE(AssertParse(&state_,
+"pool failpool\n"
+"  depth = 1\n"
+"rule fail\n"
+"  command = fail\n"
+"  pool = failpool\n"
+"build out1: fail\n"
+"build out2: fail\n"
+"build out3: fail\n"
+"build final: cat out1 out2 out3\n"));
+
+  // Swallow ten failures; we should stop before building final.
+  config_.failures_allowed = 11;
+
+  string err;
+  EXPECT_TRUE(builder_.AddTarget("final", &err));
+  ASSERT_EQ("", err);
+
+  EXPECT_FALSE(builder_.Build(&err));
+  ASSERT_EQ(3u, command_runner_.commands_ran_.size());
+  ASSERT_EQ("cannot make progress due to previous errors", err);
+}
+
 TEST_F(BuildTest, PoolEdgesReadyButNotWanted) {
   fs_.Create("x", "");