build: isolate test working/tmp/home directories
Project: http://git-wip-us.apache.org/repos/asf/zest-java/repo Commit: http://git-wip-us.apache.org/repos/asf/zest-java/commit/7524f12d Tree: http://git-wip-us.apache.org/repos/asf/zest-java/tree/7524f12d Diff: http://git-wip-us.apache.org/repos/asf/zest-java/diff/7524f12d Branch: refs/heads/develop Commit: 7524f12d41e945a406dad98aa309d899bf2cc977 Parents: e485f59 Author: Paul Merlin <[email protected]> Authored: Sat Nov 19 15:44:25 2016 +0100 Committer: Paul Merlin <[email protected]> Committed: Sat Nov 19 16:12:19 2016 +0100 ---------------------------------------------------------------------- .../apache/zest/gradle/AllProjectsPlugin.groovy | 38 +++++++++++++++----- 1 file changed, 29 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zest-java/blob/7524f12d/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy ---------------------------------------------------------------------- diff --git a/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy b/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy index 42a6bb1..abd4b4f 100644 --- a/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy +++ b/buildSrc/src/main/groovy/org/apache/zest/gradle/AllProjectsPlugin.groovy @@ -18,6 +18,7 @@ package org.apache.zest.gradle import groovy.transform.CompileStatic +import java.nio.file.Files import org.apache.zest.gradle.dependencies.DependenciesPlugin import org.apache.zest.gradle.publish.PublishingPlugin import org.gradle.api.JavaVersion @@ -112,15 +113,34 @@ class AllProjectsPlugin implements Plugin<Project> private static void configureTest( Project project ) { - def test = project.tasks.getByName( 'test' ) as Test - test.onlyIf { !project.hasProperty( 'skipTests' ) } - test.testLogging.info.exceptionFormat = TestExceptionFormat.FULL - test.maxHeapSize = '1g' - test.systemProperties = [ 'proxySet' : System.properties[ 'proxySet' ], - 'proxyHost': System.properties[ 'proxyHost' ], - 'proxyPort': System.properties[ 'proxyPort' ] ] - test.systemProperties[ 'user.dir' ] = test.workingDir - test.reports.html.enabled = true + // The space in the directory name is intentional + def allTestsDir = project.file( "$project.buildDir/tmp/test files" ) + project.tasks.withType( Test ) { Test testTask -> + testTask.onlyIf { !project.hasProperty( 'skipTests' ) } + testTask.testLogging.info.exceptionFormat = TestExceptionFormat.FULL + testTask.maxHeapSize = '1g' + testTask.systemProperties = [ 'proxySet' : System.properties[ 'proxySet' ], + 'proxyHost': System.properties[ 'proxyHost' ], + 'proxyPort': System.properties[ 'proxyPort' ] ] + testTask.reports.html.enabled = true + def testDir = new File( allTestsDir, testTask.name ) + def workDir = new File( testDir, 'work' ) + def tmpDir = new File( testDir, 'tmp' ) + def homeDir = new File( testDir, 'home' ) + testTask.workingDir = workDir + testTask.systemProperties[ 'user.dir' ] = workDir + testTask.systemProperties[ 'java.io.tmpdir' ] = tmpDir + testTask.systemProperties[ 'home.dir' ] = homeDir + testTask.doFirst { Test task -> + [ workDir, tmpDir, homeDir ]*.mkdirs() + } + testTask.doLast { Test task -> + if( !task.state.failure ) + { + project.delete testDir + } + } + } } // Dependency Report generate only the runtime configuration
