This is an automated email from the ASF dual-hosted git repository.
sergeykamov pushed a commit to branch NLPCRAFT-381
in repository https://gitbox.apache.org/repos/asf/incubator-nlpcraft.git
The following commit(s) were added to refs/heads/NLPCRAFT-381 by this push:
new eddf3e2 WIP.
eddf3e2 is described below
commit eddf3e2e478013acc2f6244226b5ade373c00c37
Author: Sergey Kamov <[email protected]>
AuthorDate: Wed Aug 11 16:19:44 2021 +0300
WIP.
---
.../nlpcraft/model/tools/cmdline/NCCliSpec.scala | 23 ++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git
a/nlpcraft-tests/cli/src/test/java/org/apache/nlpcraft/model/tools/cmdline/NCCliSpec.scala
b/nlpcraft-tests/cli/src/test/java/org/apache/nlpcraft/model/tools/cmdline/NCCliSpec.scala
index 19ea8b3..481aa6c 100644
---
a/nlpcraft-tests/cli/src/test/java/org/apache/nlpcraft/model/tools/cmdline/NCCliSpec.scala
+++
b/nlpcraft-tests/cli/src/test/java/org/apache/nlpcraft/model/tools/cmdline/NCCliSpec.scala
@@ -36,6 +36,13 @@ class NCCliSpec {
private var script: File = _
private var allDepsJar: File = _
+ case class ProcessWrapper(process: Process, listener: Thread) {
+ def destroy(): Unit = {
+ process.destroy()
+ U.stopThread(listener)
+ }
+ }
+
@BeforeEach
def before(): Unit = {
val dirUsr = new File(SystemUtils.USER_DIR).getParentFile.getParentFile
@@ -58,7 +65,7 @@ class NCCliSpec {
}
}
- private def start(arg: String, timeoutSecs: Int, expectedLines: String*):
Process = {
+ private def start(arg: String, timeoutSecs: Int, expectedLines: String*):
ProcessWrapper = {
val scriptArgs =
if (SystemUtils.IS_OS_UNIX)
Seq("bash", "-f", script.getAbsolutePath, arg)
@@ -86,7 +93,7 @@ class NCCliSpec {
if (expectedLines.exists(line.contains)) {
isStarted = true
- println(s"$arg finished fine by expected line:
'$line'")
+ println(s"$arg started fine. Expected line found:
'$line'")
println()
cdl.countDown()
@@ -103,22 +110,22 @@ class NCCliSpec {
thread.start()
- cdl.await(timeoutSecs, TimeUnit.SECONDS)
+ val w = ProcessWrapper(proc, thread)
- U.stopThread(thread)
+ cdl.await(timeoutSecs, TimeUnit.SECONDS)
if (!isStarted) {
- proc.destroy()
+ w.destroy()
- require(requirement = false, s"Command cannot be started: $arg")
+ throw new RuntimeException(s"Command cannot be started: $arg")
}
- proc
+ w
}
@Test
def test(): Unit = {
- val procs = mutable.Buffer.empty[Process]
+ val procs = mutable.Buffer.empty[ProcessWrapper]
def stopInstances(): Unit = {
// Both variant (stopped or already stopped) are fine.