Skip to content
New issue

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

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

Already on GitHub? # to your account

Add ability to watch T.inputs and interp.watchValues #2489

Merged
merged 29 commits into from
May 4, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 3 additions & 3 deletions example/tasks/2-primary-tasks/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ def lineCount: T[Int] = T {

> ./mill show lineCount
Computing line count
18
16

> ./mill show lineCount # line count already cached, doesn't need to be computed
18
16

*/

Expand Down Expand Up @@ -111,7 +111,7 @@ def hugeFileName = T{
/** Usage

> ./mill show lineCount
18
16

> ./mill show hugeFileName # This still runs `largestFile` even though `lineCount() < 999`
Finding Largest File
Expand Down
30 changes: 15 additions & 15 deletions main/eval/src/mill/eval/Evaluator.scala
Original file line number Diff line number Diff line change
Expand Up @@ -179,15 +179,15 @@ class Evaluator private (
def getFailing(
sortedGroups: MultiBiMap[Either[Task[_], Labelled[Any]], Task[_]],
results: collection.Map[Task[_], TaskResult[(Val, Int)]]
): MultiBiMap.Mutable[Either[Task[_], Labelled[_]], Failing[_]] = {
val failing = new MultiBiMap.Mutable[Either[Task[_], Labelled[_]], mill.api.Result.Failing[_]]
): MultiBiMap.Mutable[Either[Task[_], Labelled[_]], Failing[Val]] = {
val failing = new MultiBiMap.Mutable[Either[Task[_], Labelled[_]], Result.Failing[Val]]
for ((k, vs) <- sortedGroups.items()) {
failing.addAll(
k,
Loose.Agg.from(
vs.items.flatMap(results.get).collect {
case er @ TaskResult(f: mill.api.Result.Failing[_], _) =>
f
case er @ TaskResult(f: Result.Failing[(Val, Int)], _) =>
f.map(_._1)
}
)
)
Expand Down Expand Up @@ -455,10 +455,10 @@ class Evaluator private (
}

newResults(labelledNamedTask.task) match {
case TaskResult(mill.api.Result.Failure(_, Some((v, _))), _) =>
case TaskResult(Result.Failure(_, Some((v, _))), _) =>
handleTaskResult(v, v.##, paths.meta, inputsHash, labelledNamedTask)

case TaskResult(mill.api.Result.Success((v, _)), _) =>
case TaskResult(Result.Success((v, _)), _) =>
handleTaskResult(v, v.##, paths.meta, inputsHash, labelledNamedTask)

case _ =>
Expand Down Expand Up @@ -540,7 +540,7 @@ class Evaluator private (
target <- nonEvaluatedTargets
item <- target.inputs.filterNot(group.contains)
} yield results(item).map(_._1)
inputResults.forall(_.result.isInstanceOf[mill.api.Result.Success[_]])
inputResults.forall(_.result.isInstanceOf[Result.Success[_]])
}

val tickerPrefix = maybeTargetLabel.map { targetLabel =>
Expand Down Expand Up @@ -568,7 +568,7 @@ class Evaluator private (
.collect { case Result.Success((v, _)) => v }

val res = {
if (targetInputValues.length != task.inputs.length) mill.api.Result.Skipped
if (targetInputValues.length != task.inputs.length) Result.Skipped
else {
val args = new Ctx(
args = targetInputValues.map(_.value).toIndexedSeq,
Expand Down Expand Up @@ -596,7 +596,7 @@ class Evaluator private (
try task.evaluate(args).map(Val(_))
catch {
case NonFatal(e) =>
mill.api.Result.Exception(
Result.Exception(
e,
new OuterStack(new Exception().getStackTrace.toIndexedSeq)
)
Expand Down Expand Up @@ -786,26 +786,26 @@ object Evaluator {
)
}

case class TaskResult[T](result: Result[T], recalcOpt: Option[() => mill.api.Result[T]]) {
case class TaskResult[T](result: Result[T], recalcOpt: Option[() => Result[T]]) {
def map[V](f: T => V) = TaskResult[V](
result.map(f),
recalcOpt.map(r => () => r().map(f))
)
}

case class Results(
rawValues: Seq[mill.api.Result[Val]],
rawValues: Seq[Result[Val]],
evaluated: Agg[Task[_]],
transitive: Agg[Task[_]],
failing: MultiBiMap[Either[Task[_], Labelled[_]], mill.api.Result.Failing[_]],
failing: MultiBiMap[Either[Task[_], Labelled[_]], Result.Failing[Val]],
results: collection.Map[Task[_], TaskResult[Val]]
) {
def values: Seq[Any] = rawValues.collect { case mill.api.Result.Success(v) => v }
def values: Seq[Any] = rawValues.collect { case Result.Success(v) => v }
private def copy(
rawValues: Seq[Result[Val]] = rawValues,
evaluated: Agg[Task[_]] = evaluated,
transitive: Agg[Task[_]] = transitive,
failing: MultiBiMap[Either[Task[_], Labelled[_]], Result.Failing[_]] = failing,
failing: MultiBiMap[Either[Task[_], Labelled[_]], Result.Failing[Val]] = failing,
results: collection.Map[Task[_], TaskResult[Val]]
): Results = new Results(
rawValues,
Expand All @@ -821,7 +821,7 @@ object Evaluator {
Seq[Result[Any]],
Agg[Task[_]],
Agg[Task[_]],
MultiBiMap[Either[Task[_], Labelled[_]], Failing[_]],
MultiBiMap[Either[Task[_], Labelled[_]], Failing[Val]],
collection.Map[Task[_], TaskResult[_]]
)] = Some((
results.rawValues,
Expand Down
12 changes: 10 additions & 2 deletions main/testkit/src/mill/testkit/MillTestkit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,16 @@ trait MillTestKit {
)
} else {
Left(
evaluated.failing.lookupKey(evaluated.failing.keys().next).items.next()
.asInstanceOf[Result.Failing[T]]
evaluated
.failing
.lookupKey(evaluated.failing.keys().next)
.items
.next()
.asInstanceOf[Result.Failing[Val]]
.map{(x: Val) =>
x.value.asInstanceOf[T]
}

)
}
}
Expand Down
4 changes: 2 additions & 2 deletions scalajslib/test/src/mill/scalajslib/HelloJSWorldTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ object HelloJSWorldTests extends TestSuite {
}

object HelloJSWorld extends TestUtil.BaseModule {
val scalaVersions = Seq("2.13.3", "3.0.0-RC1", "2.12.12", "2.11.12")
val scalaJSVersions = Seq("1.8.0", "1.3.1", "1.0.1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these versions no longer supported? AFAIK, those partly changed/extended their API, and those tests make sure we can still build against them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we could kill them, but I'll revert this and leave it for another PR

val scalaVersions = Seq("2.13.3", "2.12.12", "2.11.12")
val scalaJSVersions = Seq("1.8.0")
val matrix = for {
scala <- scalaVersions
scalaJS <- scalaJSVersions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ object HelloNativeWorldTests extends TestSuite {
extends Cross.ToSegments[ReleaseMode](v => List(v.toString))

val matrix = for {
scala <- Seq("3.2.1", "3.1.3", scala213, "2.12.13", "2.11.12")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this version no longer supported?

scalaNative <- Seq(scalaNative04, "0.4.9")
scala <- Seq("3.2.1", scala213, "2.12.13", "2.11.12")
scalaNative <- Seq(scalaNative04)
mode <- List(ReleaseMode.Debug, ReleaseMode.ReleaseFast)
if !(ZincWorkerUtil.isScala3(scala) && scalaNative == scalaNative04)
} yield (scala, scalaNative, mode)
Expand Down