Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add test grouping for the Native build #4650

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import sbt.Tests.{Group, SubProcess}

ThisBuild / tlBaseVersion := "2.12"

val scalaCheckVersion = "1.18.0"
Expand Down Expand Up @@ -70,10 +72,38 @@ Global / concurrentRestrictions += Tags.limit(NativeTags.Link, 1)
// Therefore `tlVersionIntroduced` should be reset to 2.12.0 for all scala versions in all native cross-projects.
val commonNativeTlVersionIntroduced = List("2.12", "2.13", "3").map(_ -> "2.12.0").toMap

lazy val commonNativeSettings = Seq[Setting[?]](
doctestGenTests := Seq.empty,
tlVersionIntroduced := commonNativeTlVersionIntroduced
)
lazy val commonNativeSettings = {
def divideOnTwoGroups(tests: Seq[TestDefinition]) = {
val options = ForkOptions().withRunJVMOptions(
Vector(
"-Xmx6G",
"-Xss8m",
"-XX:+UseG1GC",
"-XX:ReservedCodeCacheSize=256m",
"-XX:MaxMetaspaceSize=512M"
)
)

val (tests1, tests2) = tests.splitAt(tests.length / 2 + 1)
Seq(
new Group("Global-Native-1", tests1, SubProcess(options)),
new Group("Global-Native-2", tests2, SubProcess(options))
)
}

// We want to divide all tests into two groups, per unit time,
// a single-forked JVM will run tests in parallel within the group.
Seq[Setting[?]](
doctestGenTests := Seq.empty,
tlVersionIntroduced := commonNativeTlVersionIntroduced,
Test / fork := true,
Test / testForkedParallel := true,
Test / testGrouping :=
divideOnTwoGroups((Test / definedTests).value),
Global / concurrentRestrictions :=
Tags.limit(Tags.ForkedTestGroup, 1) :: Nil
)
}

lazy val disciplineDependencies = Seq(
libraryDependencies ++= Seq(
Expand Down
Loading