From a625dd1f4de7501c58304ec01c39a2bbb0e9fbd8 Mon Sep 17 00:00:00 2001 From: Goooler Date: Wed, 13 Dec 2023 07:41:57 +0800 Subject: [PATCH] test: tweak common test flags (#1066) * Use `--info` flag by default `--debug` is a little annoying. * Add --warning-mode=fail flag * Bump GE plugin in tests Gradle Enterprise plugin 3.6.4 has been deprecated. Starting with Gradle 9.0, only Gradle Enterprise plugin 3.13.1 or newer is supported. * Rearrange * Reuse testKitDir Use this to share test dependencies cache for speeding up clean build. https://docs.gradle.org/8.5/javadoc/org/gradle/testkit/runner/GradleRunner.html#withTestKitDir-java.io.File- --- .../github/spotbugs/snom/BaseFunctionalTest.groovy | 11 ++++++++++- .../spotbugs/snom/CacheabilityFunctionalTest.groovy | 2 +- .../spotbugs/snom/ExtensionFunctionalTest.groovy | 8 ++++---- .../snom/KotlinBuildScriptFunctionalTest.groovy | 2 +- .../spotbugs/snom/MultiProjectFunctionalTest.groovy | 4 ++-- .../spotbugs/snom/StandardFunctionalTest.groovy | 4 ++-- 6 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/BaseFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/BaseFunctionalTest.groovy index cb63c73b..0a46cab2 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/BaseFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/BaseFunctionalTest.groovy @@ -29,7 +29,8 @@ abstract class BaseFunctionalTest extends Specification { return new TestGradleRunner() .withGradleVersion(gradleVersion) .withProjectDir(rootDir) - .withArguments('--debug', '--stacktrace') + .withArguments('--info', '--stacktrace', '--warning-mode=fail') + .withTestKitDir(testKitDir) .forwardOutput() .withPluginClasspath() } @@ -45,4 +46,12 @@ abstract class BaseFunctionalTest extends Specification { return withArguments(Arrays.asList(arguments)) } } + + private static File getTestKitDir() { + def gradleUserHome = System.getenv("GRADLE_USER_HOME") + if (!gradleUserHome) { + gradleUserHome = new File(System.getProperty("user.home"), ".gradle").absolutePath + } + return new File(gradleUserHome, "testkit") + } } diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy index 5fbcbb92..91b2a64b 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/CacheabilityFunctionalTest.groovy @@ -189,7 +189,7 @@ class CacheabilityFunctionalTest extends BaseFunctionalTest { settingsFile << ''' |plugins { - | id "com.gradle.enterprise" version "3.6.4" + | id "com.gradle.enterprise" version "3.16" |} |gradleEnterprise { | buildScan { diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/ExtensionFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/ExtensionFunctionalTest.groovy index 1476ded7..64313877 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/ExtensionFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/ExtensionFunctionalTest.groovy @@ -118,7 +118,7 @@ spotbugs { }""" when: def result = gradleRunner - .withArguments('spotbugsMain') + .withArguments('--debug', 'spotbugsMain') .build() then: @@ -133,7 +133,7 @@ spotbugs { }""" when: def result = gradleRunner - .withArguments('spotbugsMain') + .withArguments('--debug', 'spotbugsMain') .build() then: @@ -148,7 +148,7 @@ spotbugs { }""" when: def result = gradleRunner - .withArguments('spotbugsMain') + .withArguments('--debug', 'spotbugsMain') .build() then: @@ -238,7 +238,7 @@ dependencies { }""" when: BuildResult result = gradleRunner - .withArguments(":spotbugsMain") + .withArguments('--debug', ":spotbugsMain") .build() then: diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/KotlinBuildScriptFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/KotlinBuildScriptFunctionalTest.groovy index 753726eb..ca46cf20 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/KotlinBuildScriptFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/KotlinBuildScriptFunctionalTest.groovy @@ -161,7 +161,7 @@ dependencies { """ when: BuildResult result = gradleRunner - .withArguments(":spotbugsMain") + .withArguments('--debug', ":spotbugsMain") .build() then: diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/MultiProjectFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/MultiProjectFunctionalTest.groovy index 51d39703..462c0064 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/MultiProjectFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/MultiProjectFunctionalTest.groovy @@ -77,7 +77,7 @@ repositories { def "can use project name of sub project"() { when: def result = gradleRunner - .withArguments(':sub:spotbugsMain') + .withArguments('--debug', ':sub:spotbugsMain') .build() then: @@ -98,7 +98,7 @@ subprojects { when: def result = gradleRunner - .withArguments(':sub:spotbugsMain') + .withArguments('--debug', ':sub:spotbugsMain') .build() then: diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy index 71384b86..96c38f15 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/StandardFunctionalTest.groovy @@ -486,7 +486,7 @@ public class MyFoo { when: BuildResult result = gradleRunner - .withArguments("spotbugsMain") + .withArguments('--debug', "spotbugsMain") .build() then: @@ -550,7 +550,7 @@ public class SimpleTest { when: BuildResult result = gradleRunner - .withArguments("spotbugsMain", "spotbugsTest", '--parallel') + .withArguments('--debug', '--parallel', "spotbugsMain", "spotbugsTest") .build() then: