Use absolute path for temporary directory in tests (#52228)

We explicitly set the path for the temporary directory to use in test
tasks, but today this path is a relative path, relative to the current
working directory of the test task. The fact that we are using a
relative path here appears to be legacy, simply leftover from the days
of the Maven build. An absolute path is preferred here, since it's
explicit and we do not have to rely on everyone resolving the path
properly relative to the working directory.
This commit is contained in:
Jason Tedor 2020-02-11 15:07:59 -05:00
parent 6ed3311443
commit bb2e04bc16
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
1 changed files with 2 additions and 3 deletions

View File

@ -732,9 +732,7 @@ class BuildPlugin implements Plugin<Project> {
test.jvmArgs '-ea', '-esa'
}
// we use './temp' since this is per JVM and tests are forbidden from writing to CWD
test.systemProperties 'gradle.dist.lib': new File(project.class.location.toURI()).parent,
'java.io.tmpdir': './temp',
'java.awt.headless': 'true',
'tests.gradle': 'true',
'tests.artifact': project.name,
@ -742,7 +740,6 @@ class BuildPlugin implements Plugin<Project> {
'tests.security.manager': 'true',
'jna.nosys': 'true'
// ignore changing test seed when build is passed -Dignore.tests.seed for cacheability experimentation
if (System.getProperty('ignore.tests.seed') != null) {
nonInputProperties.systemProperty('tests.seed', BuildParams.testSeed)
@ -753,6 +750,8 @@ class BuildPlugin implements Plugin<Project> {
// don't track these as inputs since they contain absolute paths and break cache relocatability
nonInputProperties.systemProperty('gradle.worker.jar', "${project.gradle.getGradleUserHomeDir()}/caches/${project.gradle.gradleVersion}/workerMain/gradle-worker.jar")
nonInputProperties.systemProperty('gradle.user.home', project.gradle.getGradleUserHomeDir())
// we use 'temp' relative to CWD since this is per JVM and tests are forbidden from writing to CWD
nonInputProperties.systemProperty('java.io.tmpdir', test.workingDir.toPath().resolve('temp'))
nonInputProperties.systemProperty('compiler.java', "${-> BuildParams.compilerJavaVersion.majorVersion}")