Created
May 3, 2024 01:03
-
-
Save xuwei-k/3dc36ee2719a3a2e5c455937a0eafa8f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-Test / javaOptions += "-Dtest-database-name=sample" | |
+concurrentRestrictions := { | |
+ val par = parallelExecution.value | |
+ val max = EvaluateTask.SystemProcessors | |
+ List( | |
+ Tags.limitAll(if (par) max else 1), | |
+ Tags.limit(Tags.ForkedTestGroup, 4), // ここ増やした | |
+ Tags.exclusiveGroup(Tags.Clean) | |
+ ) | |
+} | |
+ | |
+Test / testGrouping := { | |
+ val groupCount = 4 | |
+ def groupByHash(tests: Seq[TestDefinition]): Seq[Tests.Group] = | |
+ tests | |
+ .groupBy(x => | |
+ // overflow避けるために一度Longにしている | |
+ scala.util.hashing.MurmurHash3 | |
+ .stringHash(x.name) | |
+ .toLong | |
+ .abs | |
+ .toInt % groupCount | |
+ ) | |
+ .map { case (hash, tests) => | |
+ println((hash, tests.size)) | |
+ val options = ForkOptions().withRunJVMOptions( | |
+ (Test / javaOptions).value.toVector ++ Vector( | |
+ s"-Dtest-database-name=${hash}" | |
+ ) | |
+ ) | |
+ new Tests.Group(hash.toString, tests, Tests.SubProcess(options)) | |
+ } | |
+ .toSeq | |
+ groupByHash((Test / definedTests).value) | |
+} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment