From fa484fd91ed3421d9685bdfe2a9851681bbcaa4f Mon Sep 17 00:00:00 2001 From: janakr Date: Wed, 22 Nov 2017 12:13:20 -0800 Subject: Put more information in failure message of occasionally flaky test, and deduplicate code. PiperOrigin-RevId: 176686795 --- .../build/skyframe/MemoizingEvaluatorTest.java | 37 ++++++++++------------ 1 file changed, 16 insertions(+), 21 deletions(-) (limited to 'src/test') diff --git a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java index f82719dfaf..4e666dc256 100644 --- a/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java +++ b/src/test/java/com/google/devtools/build/skyframe/MemoizingEvaluatorTest.java @@ -1645,8 +1645,7 @@ public class MemoizingEvaluatorTest { /** * Regression test: tests that pass before other build actions fail yield crash in non -k builds. */ - @Test - public void passThenFailToBuild() throws Exception { + private void passThenFailToBuild(boolean successFirst) throws Exception { CountDownLatch blocker = new CountDownLatch(1); SkyKey successKey = GraphTester.toSkyKey("success"); tester.getOrCreate(successKey).setBuilder( @@ -1659,30 +1658,26 @@ public class MemoizingEvaluatorTest { /*notifyFinish=*/null, /*waitForException=*/false, /*value=*/null, /*deps=*/ImmutableList.of())); - EvaluationResult result = tester.eval( - /*keepGoing=*/false, successKey, slowFailKey); - assertThat(result.getError().getRootCauses()).containsExactly(slowFailKey); + EvaluationResult result; + if (successFirst) { + result = tester.eval(/*keepGoing=*/ false, successKey, slowFailKey); + } else { + result = tester.eval(/*keepGoing=*/ false, slowFailKey, successKey); + } + assertThatEvaluationResult(result) + .hasErrorEntryForKeyThat(slowFailKey) + .rootCauseOfExceptionIs(slowFailKey); assertThat(result.values()).containsExactly(new StringValue("yippee")); } @Test - public void passThenFailToBuildAlternateOrder() throws Exception { - CountDownLatch blocker = new CountDownLatch(1); - SkyKey successKey = GraphTester.toSkyKey("success"); - tester.getOrCreate(successKey).setBuilder( - new ChainedFunction(/*notifyStart=*/null, /*waitToFinish=*/null, - /*notifyFinish=*/blocker, /*waitForException=*/false, new StringValue("yippee"), - /*deps=*/ImmutableList.of())); - SkyKey slowFailKey = GraphTester.toSkyKey("slow_then_fail"); - tester.getOrCreate(slowFailKey).setBuilder( - new ChainedFunction(/*notifyStart=*/null, /*waitToFinish=*/blocker, - /*notifyFinish=*/null, /*waitForException=*/false, /*value=*/null, - /*deps=*/ImmutableList.of())); + public void passThenFailToBuild() throws Exception { + passThenFailToBuild(true); + } - EvaluationResult result = tester.eval( - /*keepGoing=*/false, slowFailKey, successKey); - assertThat(result.getError().getRootCauses()).containsExactly(slowFailKey); - assertThat(result.values()).containsExactly(new StringValue("yippee")); + @Test + public void passThenFailToBuildAlternateOrder() throws Exception { + passThenFailToBuild(false); } @Test -- cgit v1.2.3