Skip to content

Commit

Permalink
Fix PlanCheck only printing a subset of the bindings without DefaultM…
Browse files Browse the repository at this point in the history
…odule etc when printBindings=true
  • Loading branch information
neko-kai committed Feb 25, 2023
1 parent 8d19f0a commit 7a5f749
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package izumi.distage.framework

import izumi.distage.config.model.ConfTag
import izumi.distage.framework.model.{PlanCheckInput, PlanCheckResult}
import izumi.distage.model.definition.ModuleBase
import izumi.distage.model.plan.Roots
import izumi.distage.model.plan.operations.OperationOrigin
import izumi.distage.model.planning.AxisPoint
Expand Down Expand Up @@ -124,6 +125,7 @@ object PlanCheck {
var effectiveConfig = "unknown, failed too early"
var effectiveBsPlugins = LoadedPlugins.empty
var effectiveAppPlugins = LoadedPlugins.empty
var effectiveModule = ModuleBase.empty
var effectivePlugins = LoadedPlugins.empty

def renderPlugins(plugins: Seq[PluginBase]): String = {
Expand All @@ -148,25 +150,27 @@ object PlanCheck {
} else {
""
}
val bindings = effectiveModule
val bsPlugins = effectiveBsPlugins.result
val appPlugins = effectiveAppPlugins.result
// fixme missing DefaultModule bindings !!!
val bsPluginsStr = renderPlugins(bsPlugins)
val appPluginsStr = renderPlugins(appPlugins)
val printedBindings = if (printBindings) {
(if (bsPlugins.nonEmpty)
s"""
|Bootstrap bindings were:
|
|${bsPlugins.flatMap(_.iterator.map(_.toString)).niceList()}
|""".stripMargin
else "") ++
s"""Bindings were:
|
|${appPlugins.flatMap(_.iterator.map(_.toString)).niceList()}
|${bindings.iterator.map(_.toString).niceList()}
|
|Keys visited:
|${visitedKeys.niceList()}
|
|App plugin bindings were:
|${appPlugins.flatMap(_.iterator.map(_.toString)).niceList()}
|""".stripMargin
} else ""

Expand All @@ -188,7 +192,8 @@ object PlanCheck {
| printBindings = $printBindings${if (!printBindings) ", set to `true` for full bindings printout" else ""}
| onlyWarn = $onlyWarn${if (!onlyWarn) ", set to `true` to ignore compilation error" else ""}
|$onlyWarnAdvice
|${printedBindings}Error was:
|$printedBindings
|Error was:
|$errorMsg
|""".stripMargin
}
Expand All @@ -206,6 +211,7 @@ object PlanCheck {
case Roots.Of(roots) => roots.mkString(", ")
case Roots.Everything => "<Roots.Everything>"
}
effectiveModule = input.module
effectiveAppPlugins = input.appPlugins
effectiveBsPlugins = input.bsPlugins
val loadedPlugins = input.appPlugins ++ input.bsPlugins
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ final class CompileTimePlanCheckerTest extends AnyWordSpec with GivenWhenThen {
)
).getMessage contains "cannot parse configuration"
)
// FIXME this causes error output during build, would be great to find a way to silence this
assertCompiles(
"""
PlanCheck.assertAppCompileTime(StaticTestMain, PlanCheckConfig("statictestrole", config = "check-test-bad.conf", onlyWarn = true))
Expand Down

0 comments on commit 7a5f749

Please sign in to comment.