mirror of https://github.com/sbt/sbt.git
Restore old scripted behavior with batch tests disabled
When 1 is passed in as the sbtInstances argument to runInParallel, all of the tests get batched together in a single sbt session. The run methods in ScriptedRunner were delegating to runInParallel and as a result were causing all of the tests to be batched, which was not how it used to work in sbt 1.3.x. To fix this we can instead pass in Int.MaxValue for the number of sbt instances. The Int.MaxValue parameter causes the batch size to be set to 1 in the batchScriptedRunner method which causes the scriptedRunners variable to have the same size as the number of tests. We then can prevent a parallel array from being used if the sbtInstances is deteced to be the Int.MaxValue sentinel.
This commit is contained in:
parent
4983fbd536
commit
3b9b20051f
|
|
@ -376,7 +376,7 @@ class ScriptedRunner {
|
|||
launchOpts: Array[String],
|
||||
): Unit = {
|
||||
val logger = TestConsoleLogger()
|
||||
runInParallel(
|
||||
run(
|
||||
resourceBaseDirectory,
|
||||
bufferLog,
|
||||
tests,
|
||||
|
|
@ -384,7 +384,8 @@ class ScriptedRunner {
|
|||
launchOpts,
|
||||
prescripted = new java.util.ArrayList[File],
|
||||
LauncherBased(launcherJar),
|
||||
1
|
||||
1,
|
||||
parallelExecution = false,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -403,7 +404,7 @@ class ScriptedRunner {
|
|||
prescripted: java.util.List[File],
|
||||
): Unit = {
|
||||
val logger = TestConsoleLogger()
|
||||
runInParallel(
|
||||
run(
|
||||
resourceBaseDirectory,
|
||||
bufferLog,
|
||||
tests,
|
||||
|
|
@ -411,7 +412,8 @@ class ScriptedRunner {
|
|||
launchOpts,
|
||||
prescripted,
|
||||
LauncherBased(launcherJar),
|
||||
1
|
||||
Int.MaxValue,
|
||||
parallelExecution = false,
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -477,6 +479,18 @@ class ScriptedRunner {
|
|||
prescripted: java.util.List[File],
|
||||
prop: RemoteSbtCreatorProp,
|
||||
instances: Int
|
||||
) = run(baseDir, bufferLog, tests, logger, launchOpts, prescripted, prop, instances, true)
|
||||
|
||||
private[this] def run(
|
||||
baseDir: File,
|
||||
bufferLog: Boolean,
|
||||
tests: Array[String],
|
||||
logger: Logger,
|
||||
launchOpts: Array[String],
|
||||
prescripted: java.util.List[File],
|
||||
prop: RemoteSbtCreatorProp,
|
||||
instances: Int,
|
||||
parallelExecution: Boolean,
|
||||
): Unit = {
|
||||
val addTestFile = (f: File) => { prescripted.add(f); () }
|
||||
val runner = new ScriptedTests(baseDir, bufferLog, launchOpts)
|
||||
|
|
@ -490,11 +504,17 @@ class ScriptedRunner {
|
|||
// The scripted tests mapped to the inputs that the user wrote after `scripted`.
|
||||
val scriptedTests =
|
||||
get(tests, baseDir, accept, logger).map(st => (st.group, st.name))
|
||||
// Choosing Int.MaxValue will make the groupSize 1 in batchScriptedRunner
|
||||
val groupCount = if (parallelExecution) instances else Int.MaxValue
|
||||
val scriptedRunners =
|
||||
runner.batchScriptedRunner(scriptedTests, addTestFile, instances, prop, logger)
|
||||
val parallelRunners = scriptedRunners.toParArray
|
||||
parallelRunners.tasksupport = new ForkJoinTaskSupport(new ForkJoinPool(instances))
|
||||
runAll(parallelRunners)
|
||||
runner.batchScriptedRunner(scriptedTests, addTestFile, groupCount, prop, logger)
|
||||
if (parallelExecution && instances > 1) {
|
||||
val parallelRunners = scriptedRunners.toParArray
|
||||
parallelRunners.tasksupport = new ForkJoinTaskSupport(new ForkJoinPool(instances))
|
||||
runAll(parallelRunners)
|
||||
} else {
|
||||
runAll(scriptedRunners)
|
||||
}
|
||||
}
|
||||
def runInParallel(
|
||||
baseDir: File,
|
||||
|
|
|
|||
Loading…
Reference in New Issue