From 2049ce3632bed3c308230b00fa928643d484705e Mon Sep 17 00:00:00 2001 From: Ethan Atkins Date: Sat, 23 Nov 2019 16:37:46 -0800 Subject: [PATCH] Improve ServerSpec feedback In some cases if sbt is broken in the right way (for example if the process dies), the ServerSpec will spam the console by printing empty lines. This commit prevents it from printing empty lines and also stops waiting for a server response if the process has died. --- sbt/src/test/scala/testpkg/ServerSpec.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sbt/src/test/scala/testpkg/ServerSpec.scala b/sbt/src/test/scala/testpkg/ServerSpec.scala index 7b5abacbe..c937cb552 100644 --- a/sbt/src/test/scala/testpkg/ServerSpec.scala +++ b/sbt/src/test/scala/testpkg/ServerSpec.scala @@ -166,7 +166,7 @@ object TestServer { val init = Try { testServer.waitForString(30.seconds) { s => - println(s) + if (s.nonEmpty) println(s) s contains """"message":"Done"""" } } @@ -292,7 +292,7 @@ case class TestServer(baseDirectory: File) { val deadline = duration.fromNow @tailrec def impl(): Boolean = { - if (deadline.isOverdue) false + if (deadline.isOverdue || !process.isAlive) false else readFrame.fold(false)(f) || impl } impl()