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

Draft: add an order to apply on sequential #2220

Draft
wants to merge 1 commit into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,5 @@ object PlannerInput {
def apply(bindings: ModuleBase, activation: Activation, root: DIKey, roots: DIKey*): PlannerInput =
PlannerInput(bindings, Roots(root, roots*), activation, DefaultPrivacy)

implicit def plannerInputOrdering: Ordering[PlannerInput] = Ordering.by(_.hashCode())
}
Original file line number Diff line number Diff line change
Expand Up @@ -226,4 +226,6 @@ object Plan {
}
}

implicit def planOrdering: Ordering[Plan] = Ordering.by(_.input)

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@ import izumi.distage.model.plan.Plan
import izumi.distage.model.reflection.DIKey
import izumi.distage.testkit.runner.impl.services.Timed
import izumi.fundamentals.collections.nonempty.NEList
import scala.math.Ordering

final case class PreparedTest[F[_]](
test: DistageTest[F],
timedPlan: Timed[Plan],
roots: Set[DIKey],
)

object PreparedTest {
implicit def orderedPreparedTest[F[_]]: Ordering[PreparedTest[F[_]]] =
Ordering.by { case PreparedTest(test, _, _) =>
(test.testMeta.pos.file, test.testMeta.pos.line)
}
}

final case class FailedTest[F[_]](
test: DistageTest[F],
timedPlan: Timed[NEList[DIError]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,8 @@ final case class TestTree[F[_]](
}
}
}

object TestTree {
implicit def testTreeOrdering[F[_]]: Ordering[TestTree[F[_]]] = Ordering.by(_.levelPlan)
}

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ import scala.concurrent.duration.FiniteDuration

object DistageTestRunner {
case class SuiteData(id: SuiteId, meta: SuiteMeta, suiteParallelism: Parallelism)

object SuiteData {
implicit def suiteDataOrdering: Ordering[SuiteData] = Ordering.by {
case SuiteData(id, meta, suiteParallelism) =>
(id.suiteId, meta.suiteName, meta.suiteClassName, suiteParallelism.toString())
}
}
}

class DistageTestRunner[F[_]: TagK, G[_]](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ object TestPlanner {
highestDebugOutputInTests: Boolean,
)

object PreparedTestEnv {
implicit def preparedTestEnvOrdering: Ordering[PreparedTestEnv] =
Ordering.by(_.runtimePlan)
}

sealed trait PlanningFailure
object PlanningFailure {
final case class Exception(throwable: Throwable) extends PlanningFailure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ object TestTreeRunner {
// note: scheduling here is custom also and tests may automatically run in parallel for any non-trivial monad
// we assume that individual tests within a suite can't have different values of `parallelSuites`
// (because of structure & that difference even if happens wouldn't be actionable at the level of suites anyway)
implicit def testsBySuiteOrdering[A]: Ordering[(DistageTestRunner.SuiteData, A)] = Ordering.by(_._1)

parTraverse(testsBySuite)(_._1.suiteParallelism) {
case (suiteData, preparedTests) =>
F.bracket(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import izumi.functional.quasi.{QuasiAsync, QuasiIO}
import izumi.functional.quasi.QuasiIO.syntax.*

trait ExtParTraverse[F[_]] {
def apply[A, B](
def apply[A: Ordering, B](
l: Iterable[A]
)(getParallelismGroup: A => Parallelism
)(f: A => F[B]
Expand All @@ -18,7 +18,7 @@ object ExtParTraverse {
F: QuasiIO[F],
P: QuasiAsync[F],
) extends ExtParTraverse[F] {
def apply[A, B](
def apply[A: Ordering, B](
l: Iterable[A]
)(getParallelismGroup: A => Parallelism
)(f: A => F[B]
Expand All @@ -31,7 +31,7 @@ object ExtParTraverse {
F.traverse(sorted) {
case (Parallelism.Fixed(n), l) if l.size > 1 => P.parTraverseN(n)(l)(f)
case (Parallelism.Unlimited, l) if l.size > 1 => P.parTraverse(l)(f)
case (_, l) => F.traverse(l)(f)
case (_, l) => F.traverse(l.toSeq.sorted)(f)
}.map(_.flatten)
}
}
Expand Down
Loading