diff --git a/console/src/main/scala/io/shiftleft/console/embammonite/EmbeddedAmmonite.scala b/console/src/main/scala/io/shiftleft/console/embammonite/EmbeddedAmmonite.scala index 825c89416..4cef52f61 100644 --- a/console/src/main/scala/io/shiftleft/console/embammonite/EmbeddedAmmonite.scala +++ b/console/src/main/scala/io/shiftleft/console/embammonite/EmbeddedAmmonite.scala @@ -67,7 +67,6 @@ class EmbeddedAmmonite(predef: String = "") { * */ def queryAsync(q: String)(observer: QueryResult => Unit): UUID = { val uuid = UUID.randomUUID() -// println(s"adding job to queue: ${q}") jobQueue.add(Job(uuid, q, observer)) uuid } @@ -80,10 +79,8 @@ class EmbeddedAmmonite(predef: String = "") { var result: QueryResult = null queryAsync(q) { r => result = r -// println("EmbeddedAmmonite.query: mutex.release") mutex.release() } -// println("EmbeddedAmmonite.query: mutex.acquire") mutex.acquire() result } diff --git a/console/src/main/scala/io/shiftleft/console/embammonite/UserRunnable.scala b/console/src/main/scala/io/shiftleft/console/embammonite/UserRunnable.scala index 5d1704962..fbaaaa361 100644 --- a/console/src/main/scala/io/shiftleft/console/embammonite/UserRunnable.scala +++ b/console/src/main/scala/io/shiftleft/console/embammonite/UserRunnable.scala @@ -43,7 +43,6 @@ class UserRunnable(queue: BlockingQueue[Job], writer: PrintWriter, reader: Buffe } private def sendQueryToAmmonite(job: Job): Unit = { - println(s"sendQueryToAmmonite: ${job.query.trim} =========") writer.println(job.query.trim) writer.println(s""""END: ${job.uuid}"""") writer.println(s"""throw new RuntimeException("END: ${job.uuid}")""") @@ -52,12 +51,7 @@ class UserRunnable(queue: BlockingQueue[Job], writer: PrintWriter, reader: Buffe private def stdOutUpToMarker(): Option[String] = { var currentOutput: String = "" - println("UserRunnable: reader.readLine()") var line = reader.readLine() - println(s"line=${line.toCharArray.toSeq.map(_.toInt)}") // magic echo seq... -// val substr = line.substring(magicEchoSeq.size) -// println(substr.toCharArray.toSeq.map(_.toInt)) -// println(substr.map(_.toChar)) while (line != null) { if (!line.startsWith(magicEchoSeq) && !line.isEmpty) { val uuid = uuidFromLine(line) @@ -73,7 +67,6 @@ class UserRunnable(queue: BlockingQueue[Job], writer: PrintWriter, reader: Buffe } private def uuidFromLine(line: String): Iterator[UUID] = { -// println(s"uuidFromLine: ${line.toCharArray.toSeq.map(_.toInt)}") endMarker.findAllIn(line).matchData.flatMap { m => Try { UUID.fromString(m.group(1)) }.toOption } diff --git a/console/src/test/scala/io/shiftleft/console/cpgqlserver/CPGQLServerTests.scala b/console/src/test/scala/io/shiftleft/console/cpgqlserver/CPGQLServerTests.scala index a87f906ec..da1914551 100644 --- a/console/src/test/scala/io/shiftleft/console/cpgqlserver/CPGQLServerTests.scala +++ b/console/src/test/scala/io/shiftleft/console/cpgqlserver/CPGQLServerTests.scala @@ -36,25 +36,6 @@ class CPGQLServerTests extends AnyWordSpec with Matchers { ujson.read(getResponse.bytes) } - "foo1" in Fixture() { host => - val webSocketTextMsg = scala.concurrent.Promise[String]() - cask.util.WsClient.connect(s"$host/connect") { - case cask.Ws.Text(msg) => webSocketTextMsg.success(msg) - } - val wsMsg = Await.result(webSocketTextMsg.future, DefaultPromiseAwaitTimeout) - wsMsg shouldBe "connected" - } - - // copy of "allow posting a simple query without any websocket connections established" in Fixture() { host => - "foo2" in Fixture() { host => - val postQueryResponse = postQuery(host, "1") - postQueryResponse.obj.keySet should contain("success") - val UUIDResponse = postQueryResponse("uuid").str - UUIDResponse should not be empty - postQueryResponse("success").bool shouldBe true - } - - "CPGQLServer" should { "allow websocket connections to the `/connect` endpoint" in Fixture() { host => @@ -228,23 +209,11 @@ object Fixture { .setHandler(ammServer.defaultHandler) .build server.start() - // val res = - // try { - // f(httpEndpoint) - // } finally { - // server.stop() - // println("XXXX0") - // val res0 = ammonite.shutdown() - // println("XXXX1") - // res0 - // } - // println("XXXX2") - // res - val res = f(httpEndpoint) - Thread.sleep(1000) - server.stop() - Thread.sleep(1000) - ammonite.shutdown() + val res = + try { f(httpEndpoint) } finally { + server.stop() + ammonite.shutdown() + } res } } diff --git a/console/src/test/scala/io/shiftleft/console/embammonite/EmbeddedAmmoniteTests.scala b/console/src/test/scala/io/shiftleft/console/embammonite/EmbeddedAmmoniteTests.scala index 07f5f2eb3..334e05a9c 100644 --- a/console/src/test/scala/io/shiftleft/console/embammonite/EmbeddedAmmoniteTests.scala +++ b/console/src/test/scala/io/shiftleft/console/embammonite/EmbeddedAmmoniteTests.scala @@ -17,7 +17,7 @@ class EmbeddedAmmoniteTests extends AnyWordSpec with Matchers { "execute a command synchronously" in { val shell = new EmbeddedAmmonite() shell.start() - val result = shell.query("def foo() = {1} \n foo()") + val result = shell.query("def foo() = {\n1\n}\n foo()") result.out shouldBe """defined function foo |res1: Int = 1