Skip to content

Commit

Permalink
test: tweak common test flags (#1066)
Browse files Browse the repository at this point in the history
* 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-
  • Loading branch information
Goooler committed Dec 12, 2023
1 parent c448e16 commit a625dd1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ spotbugs {
}"""
when:
def result = gradleRunner
.withArguments('spotbugsMain')
.withArguments('--debug', 'spotbugsMain')
.build()

then:
Expand All @@ -133,7 +133,7 @@ spotbugs {
}"""
when:
def result = gradleRunner
.withArguments('spotbugsMain')
.withArguments('--debug', 'spotbugsMain')
.build()

then:
Expand All @@ -148,7 +148,7 @@ spotbugs {
}"""
when:
def result = gradleRunner
.withArguments('spotbugsMain')
.withArguments('--debug', 'spotbugsMain')
.build()

then:
Expand Down Expand Up @@ -238,7 +238,7 @@ dependencies {
}"""
when:
BuildResult result = gradleRunner
.withArguments(":spotbugsMain")
.withArguments('--debug', ":spotbugsMain")
.build()

then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ dependencies {
"""
when:
BuildResult result = gradleRunner
.withArguments(":spotbugsMain")
.withArguments('--debug', ":spotbugsMain")
.build()

then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -98,7 +98,7 @@ subprojects {

when:
def result = gradleRunner
.withArguments(':sub:spotbugsMain')
.withArguments('--debug', ':sub:spotbugsMain')
.build()

then:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ public class MyFoo {
when:
BuildResult result = gradleRunner
.withArguments("spotbugsMain")
.withArguments('--debug', "spotbugsMain")
.build()
then:
Expand Down Expand Up @@ -550,7 +550,7 @@ public class SimpleTest {
when:
BuildResult result = gradleRunner
.withArguments("spotbugsMain", "spotbugsTest", '--parallel')
.withArguments('--debug', '--parallel', "spotbugsMain", "spotbugsTest")
.build()
then:
Expand Down

0 comments on commit a625dd1

Please sign in to comment.