From c2279c66c7fe08fcc2cee72d68dd4c08fe2742d4 Mon Sep 17 00:00:00 2001 From: danicheg Date: Thu, 5 Sep 2024 09:31:43 +0300 Subject: [PATCH 1/2] Add test grouping for the Native build --- build.sbt | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/build.sbt b/build.sbt index e0fe710ca2..db5c907f0b 100644 --- a/build.sbt +++ b/build.sbt @@ -1,3 +1,5 @@ +import sbt.Tests.{Group, SubProcess} + ThisBuild / tlBaseVersion := "2.12" val scalaCheckVersion = "1.18.0" @@ -70,10 +72,37 @@ 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 / testGrouping := + divideOnTwoGroups((Test / definedTests).value), + Global / concurrentRestrictions := + Tags.limit(Tags.ForkedTestGroup, 1) :: Nil + ) +} lazy val disciplineDependencies = Seq( libraryDependencies ++= Seq( From 950295214840f865bfb7f36cc044055cb51d0f48 Mon Sep 17 00:00:00 2001 From: danicheg Date: Thu, 5 Sep 2024 09:31:57 +0300 Subject: [PATCH 2/2] Add testForkedParallel := true --- build.sbt | 1 + 1 file changed, 1 insertion(+) diff --git a/build.sbt b/build.sbt index db5c907f0b..0c0b62e62f 100644 --- a/build.sbt +++ b/build.sbt @@ -97,6 +97,7 @@ lazy val commonNativeSettings = { doctestGenTests := Seq.empty, tlVersionIntroduced := commonNativeTlVersionIntroduced, Test / fork := true, + Test / testForkedParallel := true, Test / testGrouping := divideOnTwoGroups((Test / definedTests).value), Global / concurrentRestrictions :=