Use logger in scripted instead of println

This commit is contained in:
Ethan Atkins 2019-11-17 12:34:19 -08:00
parent 0d1d8a790c
commit ee56140f5c
3 changed files with 11 additions and 5 deletions

View File

@ -1115,7 +1115,8 @@ def scriptedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
scriptedBufferLog.value, scriptedBufferLog.value,
Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed, Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed,
scriptedPrescripted.value, scriptedPrescripted.value,
scriptedLaunchOpts.value scriptedLaunchOpts.value,
streams.value.log
) )
} }
@ -1128,7 +1129,8 @@ def scriptedUnpublishedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
scriptedBufferLog.value, scriptedBufferLog.value,
Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed, Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed,
scriptedPrescripted.value, scriptedPrescripted.value,
scriptedLaunchOpts.value scriptedLaunchOpts.value,
streams.value.log
) )
} }

View File

@ -5,6 +5,8 @@ import java.lang.reflect.InvocationTargetException
import sbt._ import sbt._
import sbt.internal.inc.ScalaInstance import sbt.internal.inc.ScalaInstance
import sbt.internal.inc.classpath.{ ClasspathUtilities, FilteredLoader } import sbt.internal.inc.classpath.{ ClasspathUtilities, FilteredLoader }
import sbt.ScriptedPlugin.autoImport._
import sbt.util.Level
object LocalScriptedPlugin extends AutoPlugin { object LocalScriptedPlugin extends AutoPlugin {
override def requires = plugins.JvmPlugin override def requires = plugins.JvmPlugin
@ -99,8 +101,10 @@ object Scripted {
args: Seq[String], args: Seq[String],
prescripted: File => Unit, prescripted: File => Unit,
launchOpts: Seq[String], launchOpts: Seq[String],
logger: Logger
): Unit = { ): Unit = {
System.err.println(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}") logger.info(s"About to run tests: ${args.mkString("\n * ", "\n * ", "\n")}")
logger.info("")
// Force Log4J to not use a thread context classloader otherwise it throws a CCE // Force Log4J to not use a thread context classloader otherwise it throws a CCE
sys.props(org.apache.logging.log4j.util.LoaderUtil.IGNORE_TCCL_PROPERTY) = "true" sys.props(org.apache.logging.log4j.util.LoaderUtil.IGNORE_TCCL_PROPERTY) = "true"

View File

@ -64,7 +64,7 @@ final class ScriptedTests(
val n = nme.getName val n = nme.getName
val label = s"$g / $n" val label = s"$g / $n"
() => { () => {
println(s"Running $label") log.info(s"Running $label")
val result = testResources.readWriteResourceDirectory(g, n) { testDirectory => val result = testResources.readWriteResourceDirectory(g, n) { testDirectory =>
val buffer = new BufferedLogger(new FullLogger(log)) val buffer = new BufferedLogger(new FullLogger(log))
val singleTestRunner = () => { val singleTestRunner = () => {
@ -326,7 +326,7 @@ final class ScriptedTests(
groupedTests.map { groupedTests.map {
case ((group, name), originalDir) => case ((group, name), originalDir) =>
val label = s"$group/$name" val label = s"$group/$name"
println(s"Running $label") log.info(s"Running $label")
// Copy test's contents and reload the sbt instance to pick them up // Copy test's contents and reload the sbt instance to pick them up
IO.copyDirectory(originalDir, tempTestDir) IO.copyDirectory(originalDir, tempTestDir)