Skip to content

Commit

Permalink
Run tests with 'Configuration Cache' and 'Project Isolation'
Browse files Browse the repository at this point in the history
  • Loading branch information
jjohannes committed Jun 4, 2024
1 parent 671307b commit 52b2b5f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class CustomizationTest extends Specification {
appBuildFile << '''
javaModuleDependencies {
modulesProperties.set(rootProject.layout.projectDirectory.file(".hidden/modules.properties"))
modulesProperties.set(File(rootDir,".hidden/modules.properties"))
}
'''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class GroupMappingTest extends Specification {
'''

when:
def result = runner('assemble').build()
def result = runner(false, 'assemble').build()

then:
result.task(":app:compileJava").outcome == TaskOutcome.SUCCESS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,6 @@ class LocalModuleMappingsTest extends Specification {
'''

then:
build()
runner(false, 'build').build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,13 @@ class RequiresRuntimeTest extends Specification {
tasks.compileTestJava {
classpath += sourceSets.main.get().output
val srcDir = sourceSets.test.get().java.sourceDirectories.first()
options.compilerArgumentProviders.add {
listOf(
"--module-path",
classpath.files.joinToString(":"),
"--patch-module",
"org.gradlex.test.app=" + sourceSets.test.get().java.sourceDirectories.first()
"org.gradlex.test.app=" + srcDir
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ class GradleBuild {
mainClass.set("org.gradlex.test.app.Main")
}
tasks.register("printRuntimeJars") {
doLast { println(configurations.runtimeClasspath.get().files.map { it.name }) }
inputs.files(configurations.runtimeClasspath)
doLast { println(inputs.files.map { it.name }) }
}
tasks.register("printCompileJars") {
doLast { println(configurations.compileClasspath.get().files.map { it.name }) }
inputs.files(configurations.compileClasspath)
doLast { println(inputs.files.map { it.name }) }
}
'''
libBuildFile << '''
Expand Down Expand Up @@ -85,12 +87,18 @@ class GradleBuild {
runner('build').buildAndFail()
}

GradleRunner runner(String... args) {
GradleRunner runner(boolean projectIsolation = true, String... args) {
List<String> latestFeaturesArgs = gradleVersionUnderTest || !projectIsolation? [] : [
'--configuration-cache',
'-Dorg.gradle.unsafe.isolated-projects=true',
// 'getGroup' in 'JavaModuleDependenciesExtension.create'
'--configuration-cache-problems=warn', '-Dorg.gradle.configuration-cache.max-problems=3'
]
GradleRunner.create()
.forwardOutput()
.withPluginClasspath()
.withProjectDir(projectDir)
.withArguments(Arrays.asList(args) + '-s' + '--warning-mode' + 'all')
.withArguments(Arrays.asList(args) + latestFeaturesArgs + '-s' + '--warning-mode=all')
.withDebug(ManagementFactory.getRuntimeMXBean().getInputArguments().toString().contains("-agentlib:jdwp")).with {
gradleVersionUnderTest ? it.withGradleVersion(gradleVersionUnderTest) : it
}
Expand Down

0 comments on commit 52b2b5f

Please sign in to comment.