Merge pull request #5290 from eatkins/scripted-log

Use logger in scripted instead of println
This commit is contained in:
eugene yokota 2019-12-10 18:59:29 -05:00 committed by GitHub
commit c933a1923d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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,
Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed,
scriptedPrescripted.value,
scriptedLaunchOpts.value
scriptedLaunchOpts.value,
streams.value.log
)
}
@ -1128,7 +1129,8 @@ def scriptedUnpublishedTask: Def.Initialize[InputTask[Unit]] = Def.inputTask {
scriptedBufferLog.value,
Def.setting(Scripted.scriptedParser(scriptedSource.value)).parsed,
scriptedPrescripted.value,
scriptedLaunchOpts.value
scriptedLaunchOpts.value,
streams.value.log
)
}

View File

@ -5,6 +5,8 @@ import java.lang.reflect.InvocationTargetException
import sbt._
import sbt.internal.inc.ScalaInstance
import sbt.internal.inc.classpath.{ ClasspathUtilities, FilteredLoader }
import sbt.ScriptedPlugin.autoImport._
import sbt.util.Level
object LocalScriptedPlugin extends AutoPlugin {
override def requires = plugins.JvmPlugin
@ -99,8 +101,10 @@ object Scripted {
args: Seq[String],
prescripted: File => Unit,
launchOpts: Seq[String],
logger: Logger
): 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
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 label = s"$g / $n"
() => {
println(s"Running $label")
log.info(s"Running $label")
val result = testResources.readWriteResourceDirectory(g, n) { testDirectory =>
val buffer = new BufferedLogger(new FullLogger(log))
val singleTestRunner = () => {
@ -326,7 +326,7 @@ final class ScriptedTests(
groupedTests.map {
case ((group, name), originalDir) =>
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
IO.copyDirectory(originalDir, tempTestDir)