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

Move task override tracking from planning time to instantiation time #4181

Merged
merged 26 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
mill.eval.EvaluationTestsThreads1.evaluateMixed.overrideSuperTask passes
  • Loading branch information
lihaoyi committed Dec 26, 2024
commit b78b3f94480fd7f185f30c3f1782b7f54abe4da8
4 changes: 0 additions & 4 deletions main/define/src/mill/define/Ctx.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ object Ctx extends LowPriCtx {
override val enclosingModule: Any,
crossValues: Seq[Any]
) extends Ctx {
pprint.log(segments)
def enclosingCls = enclosingModule.getClass
def withCrossValues(crossValues: Seq[Any]): Ctx = copy(crossValues = crossValues)
def withMillSourcePath(millSourcePath: os.Path): Ctx = copy(millSourcePath = millSourcePath)
Expand Down Expand Up @@ -93,7 +92,6 @@ object Ctx extends LowPriCtx {
// `sourcecode.Name` to work around bug with anonymous classes
// returning `$anon` names
val lastSegmentStr = millModuleEnclosing0.value.split("\\.|#| ").filter(!_.startsWith("$anon")).last
pprint.log(segments0)
Impl(
millModuleEnclosing0.value,
millModuleLine0.value,
Expand All @@ -104,8 +102,6 @@ object Ctx extends LowPriCtx {
case Some(value) =>
val mapping = value.asInstanceOf[mill.define.OverrideMapping.Wrapper].overrideMapping
val key = (enclosingClass.value, lastSegmentStr)

pprint.log(mapping.value(key))
mapping.value(key)
case None => Segments()
}
Expand Down
6 changes: 1 addition & 5 deletions main/define/src/mill/define/Module.scala
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@ trait Module extends Module.BaseClass with OverrideMapping.Wrapper {
val enclosings = groupRest.map(_.getDeclaringClass.getName)
Seq((groupHead.getDeclaringClass, names) -> Segments()) ++
groupRest.map{ taskMethod =>
pprint.log(taskMethod.getDeclaringClass.getName)
pprint.log(taskMethod.getName)
(taskMethod.getDeclaringClass, names) ->
Module.assignOverridenTaskSegments(
enclosings,
Expand All @@ -80,7 +78,6 @@ trait Module extends Module.BaseClass with OverrideMapping.Wrapper {
)
}
}
pprint.log(result)

OverrideMapping(result)
}
Expand Down Expand Up @@ -141,7 +138,7 @@ object Module {
taskMethodName: String,
taskClassName: String) = {
// StringTokenizer is faster than String#split due to not using regexes
def splitEnclosing(s: String) = new StringTokenizer(s, ".# ")
def splitEnclosing(s: String) = new StringTokenizer(s, ".# $")
.asIterator()
.asScala.map(_.asInstanceOf[String])
.filter(_ != "<empty>")
Expand All @@ -160,7 +157,6 @@ object Module {
// `dropRight(1)` to always drop the task name, which has to be
// the same for all overriden tasks with the same segments
val superSuffix0 = splitted.drop(dropLeft)
pprint.log(dropLeft)

// If there are no different segments between the enclosing strings,
// preserve at least one path segment which is the class name
Expand Down
4 changes: 3 additions & 1 deletion main/define/src/mill/define/Task.scala
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,9 @@ trait NamedTask[+T] extends Task[T] {

def evaluate(ctx: mill.api.Ctx): Result[T] = ctx.arg[T](0)

val ctx: Ctx = ctx0.withSegments(segments = ctx0.segments ++ Seq(ctx0.segment))
val ctx: Ctx =
if (ctx0.segments.value.exists(_.pathSegments.exists(_.endsWith(".super")))) ctx0
else ctx0.withSegments(segments = ctx0.segments ++ Seq(ctx0.segment))
val inputs: Seq[Task[_]] = Seq(t)

def readWriterOpt: Option[upickle.default.ReadWriter[_]] = None
Expand Down
3 changes: 1 addition & 2 deletions main/eval/test/src/mill/eval/EvaluationTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class EvaluationTests(threadCount: Option[Int]) extends TestSuite {
// Make sure data is persisted even if we re-create the evaluator each time
val evaluator = UnitTester(module, null, threads = threadCount).evaluator

pprint.log(evaluator.outPath)
def apply(
target: Task[_],
expValue: Any,
Expand Down Expand Up @@ -226,7 +225,7 @@ class EvaluationTests(threadCount: Option[Int]) extends TestSuite {

val public = os.read(checker.evaluator.outPath / "foo.json")
val overridden = os.read(
checker.evaluator.outPath / "foo.super/TestGraphs$BaseModule.json"
checker.evaluator.outPath / "foo.super/BaseModule.json"
)

assert(
Expand Down