From 1ec07c1867d2b7eb01503f68e0fc43d84f445911 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Mon, 26 Mar 2018 10:37:25 -0400 Subject: [PATCH] Recover sbtOn --- build.sbt | 4 ++++ sbt/src/test/scala/sbt/RunFromSourceMain.scala | 17 +++++++++-------- sbt/src/test/scala/testpkg/ServerSpec.scala | 6 +++++- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/build.sbt b/build.sbt index 41723a157..01f18a2a8 100644 --- a/build.sbt +++ b/build.sbt @@ -497,6 +497,7 @@ lazy val sbtProj = (project in file("sbt")) normalizedName := "sbt", crossScalaVersions := Seq(baseScalaVersion), crossPaths := false, + javaOptions ++= Seq("-Xdebug", "-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"), mimaSettings, mimaBinaryIssueFilters ++= sbtIgnoredProblems, BuildInfoPlugin.buildInfoDefaultSettings, @@ -508,6 +509,9 @@ lazy val sbtProj = (project in file("sbt")) classDirectory in Compile, classDirectory in Test, ), + Test / run / connectInput := true, + Test / run / outputStrategy := Some(StdoutOutput), + Test / run / fork := true, ) .configure(addSbtCompilerBridge) diff --git a/sbt/src/test/scala/sbt/RunFromSourceMain.scala b/sbt/src/test/scala/sbt/RunFromSourceMain.scala index 2f4e81a51..c0bd9cfc1 100644 --- a/sbt/src/test/scala/sbt/RunFromSourceMain.scala +++ b/sbt/src/test/scala/sbt/RunFromSourceMain.scala @@ -7,7 +7,7 @@ package sbt -import scala.concurrent.Future +import scala.util.Try import sbt.util.LogExchange import scala.annotation.tailrec import buildinfo.TestBuildInfo @@ -17,21 +17,22 @@ object RunFromSourceMain { private val sbtVersion = "1.0.3" // "dev" private val scalaVersion = "2.12.4" - def fork(workingDirectory: File): Future[Unit] = { + def fork(workingDirectory: File): Try[Unit] = { val fo = ForkOptions() - .withWorkingDirectory(workingDirectory) .withOutputStrategy(OutputStrategy.StdoutOutput) + fork(fo, workingDirectory) + } + + def fork(fo0: ForkOptions, workingDirectory: File): Try[Unit] = { + val fo = fo0 + .withWorkingDirectory(workingDirectory) implicit val runner = new ForkRun(fo) val cp = { TestBuildInfo.test_classDirectory +: TestBuildInfo.fullClasspath } val options = Vector(workingDirectory.toString) val log = LogExchange.logger("RunFromSourceMain.fork", None, None) - import scala.concurrent.ExecutionContext.Implicits.global - Future { - Run.run("sbt.RunFromSourceMain", cp, options, log) - () - } + Run.run("sbt.RunFromSourceMain", cp, options, log) } def main(args: Array[String]): Unit = args match { diff --git a/sbt/src/test/scala/testpkg/ServerSpec.scala b/sbt/src/test/scala/testpkg/ServerSpec.scala index f34eee6b1..259e5c248 100644 --- a/sbt/src/test/scala/testpkg/ServerSpec.scala +++ b/sbt/src/test/scala/testpkg/ServerSpec.scala @@ -71,7 +71,11 @@ case class TestServer(baseDirectory: File) { private val RetByte = '\r'.toByte hostLog("fork to a new sbt instance") - RunFromSourceMain.fork(baseDirectory) + import scala.concurrent.ExecutionContext.Implicits.global + Future { + RunFromSourceMain.fork(baseDirectory) + () + } lazy val portfile = baseDirectory / "project" / "target" / "active.json" hostLog("wait 30s until the server is ready to respond")