Merge pull request #5777 from eatkins/ci-virtual-io

Don't use virtual io by default in CI
This commit is contained in:
eugene yokota 2020-08-19 22:57:07 -04:00 committed by GitHub
commit f7dad80258
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -171,6 +171,8 @@ object Terminal {
// Disable noisy jline log spam // Disable noisy jline log spam
if (System.getProperty("sbt.jline.verbose", "false") != "true") if (System.getProperty("sbt.jline.verbose", "false") != "true")
jline.internal.Log.setOutput(new PrintStream(_ => {}, false)) jline.internal.Log.setOutput(new PrintStream(_ => {}, false))
private[this] val isCI = System.getProperty("sbt.ci", "") == "true" ||
sys.env.contains("BUILD_NUMBER") || sys.env.contains("CI")
def consoleLog(string: String): Unit = { def consoleLog(string: String): Unit = {
try Terminal.console.printStream.println(s"[info] $string") try Terminal.console.printStream.println(s"[info] $string")
catch { case _: IOException => } catch { case _: IOException => }
@ -281,7 +283,9 @@ object Terminal {
* @return the result of the thunk * @return the result of the thunk
*/ */
private[sbt] def withStreams[T](isServer: Boolean)(f: => T): T = private[sbt] def withStreams[T](isServer: Boolean)(f: => T): T =
if (System.getProperty("sbt.io.virtual", "true") == "true") { // In ci environments, don't touch the io streams unless run with -Dsbt.io.virtual=true
if (isCI && System.getProperty("sbt.io.virtual", "") != "true") f
else {
hasProgress.set(isServer) hasProgress.set(isServer)
consoleTerminalHolder.set(wrap(jline.TerminalFactory.get)) consoleTerminalHolder.set(wrap(jline.TerminalFactory.get))
activeTerminal.set(consoleTerminalHolder.get) activeTerminal.set(consoleTerminalHolder.get)
@ -313,7 +317,7 @@ object Terminal {
console.close() console.close()
} }
} }
} else f }
private[this] object ProxyTerminal extends Terminal { private[this] object ProxyTerminal extends Terminal {
private def t: Terminal = activeTerminal.get private def t: Terminal = activeTerminal.get
@ -775,7 +779,6 @@ object Terminal {
val size = system.getSize val size = system.getSize
(size.getColumns, size.getRows) (size.getColumns, size.getRows)
} }
private[this] val isCI = sys.env.contains("BUILD_NUMBER") || sys.env.contains("CI")
override lazy val isAnsiSupported: Boolean = term.isAnsiSupported && !isCI override lazy val isAnsiSupported: Boolean = term.isAnsiSupported && !isCI
override private[sbt] def progressState: ProgressState = consoleProgressState.get override private[sbt] def progressState: ProgressState = consoleProgressState.get
override def isEchoEnabled: Boolean = system.echo() override def isEchoEnabled: Boolean = system.echo()