How to verify test.maxParallelForks value?


(Noel Yap) #1

In a multi-project build, I would like to define for each subproject ‘test.maxParallelForks’ as ‘Runtime.getRuntime().availableProcessors() * (1 + ratioOfWaitTimeToComputeTime)’ where each subproject can define ‘ratioOfWaitTimeToComputeTime’.

I’ve created the following function:

int numberOfForks(int ratioOfWaitTimeToComputeTime) {

Runtime.getRuntime().availableProcessors() * (1 + ratioOfWaitTimeToComputeTime)

}

and did:

subprojects {

test {

// TODO: allow different settings per subproject

int ratioOfWaitTimeToComputeTime = 2

maxParallelForks numberOfForks(ratioOfWaitTimeToComputeTime)

}

}

How do I verify that the setting is actually taking place?


(René Groeschke) #2

Hello noel, well one very simple way to verify your settings is to print out the value of Test#maxparallelforks in a doFirst block:

tasks.withType(Test){
    doFirst{
        println "configured maxparallelforks: ${maxParallelForks}"
     }
}

cheers, René