Skip to content

Commit

Permalink
Adjust test assertions to fix flakiness (gradle#8979)
Browse files Browse the repository at this point in the history
This fixes gradle/gradle-private#1760

The changes we made to TAPI in gradle#7654 caused some flakiness.
This PR fixes these flakiness by adjusting test assertions.
  • Loading branch information
blindpirate authored Apr 10, 2019
1 parent 248ea36 commit c787638
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.gradle.integtests.tooling.fixture.TestResultHandler
import org.gradle.integtests.tooling.fixture.ToolingApiSpecification
import org.gradle.test.fixtures.server.http.BlockingHttpServer
import org.gradle.tooling.BuildCancelledException
import org.gradle.util.GradleVersion
import org.junit.Rule

import java.util.concurrent.CountDownLatch
Expand Down Expand Up @@ -72,12 +73,20 @@ latch.await()
void buildWasCancelled(TestResultHandler resultHandler, String failureMessage = 'Could not execute build using Gradle') {
resultHandler.assertFailedWith(BuildCancelledException)
assert resultHandler.failure.message.startsWith(failureMessage)
assert resultHandler.failure.cause.message == "Build cancelled."

if (targetIsGradle51OrLater()) {
// https://github.com/gradle/gradle-private/issues/1760
assert resultHandler.failure.cause.message in ["Build cancelled.", "Daemon was stopped to handle build cancel request."]
}
def failure = OutputScrapingExecutionFailure.from(stdout.toString(), stderr.toString())
failure.assertHasDescription('Build cancelled.')
assertHasBuildFailedLogging()
}

private static void targetIsGradle51OrLater() {
targetVersion >= GradleVersion.version('5.1')
}

void configureWasCancelled(TestResultHandler resultHandler, String failureMessage) {
resultHandler.assertFailedWith(BuildCancelledException)
assert resultHandler.failure.message.startsWith(failureMessage)
Expand Down

0 comments on commit c787638

Please sign in to comment.