[gradle][plugin] Fix tests (#7384)

Tests running under Gradle 5.6.4 were breaking due to a change in
informational output. It's not clear when this was introduced, but it
looks like the upgrade to Gradle 5.6.4 may have stopped running tests
during builds.
This commit is contained in:
Jim Schubert 2020-09-09 23:42:33 -04:00 committed by GitHub
parent 4d8ac0e055
commit 1eb8c2991d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 140 additions and 98 deletions

View File

@ -1,6 +1,5 @@
#Thu Jan 30 22:14:34 EST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStorePath=wrapper/dists distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@ -1,5 +1,21 @@
#!/usr/bin/env sh #!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
############################################################################## ##############################################################################
## ##
## Gradle start up script for UN*X ## Gradle start up script for UN*X
@ -28,7 +44,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"` APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS="" DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum" MAX_FD="maximum"
@ -109,8 +125,8 @@ if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi fi
# For Cygwin, switch paths to Windows format before running java # For Cygwin or MSYS, switch paths to Windows format before running java
if $cygwin ; then if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"` APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"` JAVACMD=`cygpath --unix "$JAVACMD"`

View File

@ -1,3 +1,19 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS= set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe @rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome if defined JAVA_HOME goto findJavaFromJavaHome

View File

@ -94,6 +94,7 @@
<tasks> <tasks>
<!-- calls "clean assemble install" --> <!-- calls "clean assemble install" -->
<task>clean</task> <task>clean</task>
<task>check</task>
<task>assemble</task> <task>assemble</task>
<task>publishToMavenLocal</task> <task>publishToMavenLocal</task>
<task>publishPluginMavenPublicationToMavenLocal</task> <task>publishPluginMavenPublicationToMavenLocal</task>

View File

@ -5,6 +5,7 @@ import org.gradle.testkit.runner.TaskOutcome
import org.testng.annotations.Test import org.testng.annotations.Test
import java.io.File import java.io.File
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFalse
import kotlin.test.assertTrue import kotlin.test.assertTrue
class GenerateTaskDslTest : TestBase() { class GenerateTaskDslTest : TestBase() {
@ -78,17 +79,17 @@ class GenerateTaskDslTest : TestBase() {
// Act // Act
val resultFirstRun = GradleRunner.create() val resultFirstRun = GradleRunner.create()
.withProjectDir(temp) .withProjectDir(temp)
.withArguments("openApiGenerate") .withArguments("openApiGenerate", "--info")
.withPluginClasspath() .withPluginClasspath()
.build() .build()
val resultSecondRun = GradleRunner.create() val resultSecondRun = GradleRunner.create()
.withProjectDir(temp) .withProjectDir(temp)
.withArguments("openApiGenerate") .withArguments("openApiGenerate", "--info")
.withPluginClasspath() .withPluginClasspath()
.build() .build()
// Assert // Assert
assertTrue(resultFirstRun.output.contains("Task ':openApiGenerate' is not up-to-date"), "First run should not be up-to-date") assertFalse(resultFirstRun.output.contains("Task :openApiGenerate UP-TO-DATE"), "First run should not be up-to-date")
assertTrue(resultSecondRun.output.contains("Task :openApiGenerate UP-TO-DATE"), "Task of second run should be up-to-date") assertTrue(resultSecondRun.output.contains("Task :openApiGenerate UP-TO-DATE"), "Task of second run should be up-to-date")
} }
@ -103,7 +104,7 @@ class GenerateTaskDslTest : TestBase() {
// Act // Act
val resultFirstRun = GradleRunner.create() val resultFirstRun = GradleRunner.create()
.withProjectDir(temp) .withProjectDir(temp)
.withArguments("openApiGenerate", "--build-cache") .withArguments("openApiGenerate", "--build-cache", "--info")
.withPluginClasspath() .withPluginClasspath()
.build() .build()
@ -113,13 +114,22 @@ class GenerateTaskDslTest : TestBase() {
// re-run // re-run
val resultSecondRun = GradleRunner.create() val resultSecondRun = GradleRunner.create()
.withProjectDir(temp) .withProjectDir(temp)
.withArguments("openApiGenerate", "--build-cache") .withArguments("openApiGenerate", "--build-cache", "--info")
.withPluginClasspath()
.build()
// re-run without deletes
val resultThirdRun = GradleRunner.create()
.withProjectDir(temp)
.withArguments("openApiGenerate", "--build-cache", "--info")
.withPluginClasspath() .withPluginClasspath()
.build() .build()
// Assert // Assert
assertTrue(resultFirstRun.output.contains("Task ':openApiGenerate' is not up-to-date"), "First run should not be up-to-date") assertTrue(resultFirstRun.output.contains("No history is available."), "First run should not be up-to-date")
assertTrue(resultSecondRun.output.contains("Task :openApiGenerate FROM-CACHE"), "Task of second run should be from cache") assertFalse(resultSecondRun.output.contains("No history is available."), "Task of second run should be from cache")
assertTrue(resultSecondRun.output.contains("has been removed."), "Task of second run should detect cache changes for untracked files")
assertTrue(resultThirdRun.output.contains("Skipping task ':openApiGenerate' as it is up-to-date."), "Task of third run should not require rebuild")
} }
@Test @Test

View File

@ -32,7 +32,7 @@ class ValidateTaskDslTest : TestBase() {
.buildAndFail() .buildAndFail()
// Assert // Assert
assertTrue(result.output.contains("unable to read location `some_location`"), "Unexpected/no message presented to the user for a spec pointing to an invalid URI.") assertTrue(result.output.contains("some_location' specified for property 'inputSpec' does not exist"), "Unexpected/no message presented to the user for a spec pointing to an invalid URI.")
assertEquals(FAILED, result.task(":openApiValidate")?.outcome, assertEquals(FAILED, result.task(":openApiValidate")?.outcome,
"Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}") "Expected a failed run, but found ${result.task(":openApiValidate")?.outcome}")
} }