Changed ForkTests to call acceptorThread.join(), to make sure that acceptorThread is finished before Acceptor.result is called.

This commit is contained in:
cheeseng 2013-04-05 15:05:28 +08:00
parent 18bc8423b5
commit b83d378cd0
1 changed files with 6 additions and 2 deletions

View File

@ -72,7 +72,8 @@ private[sbt] object ForkTests {
try {
testListeners.foreach(_.doInit())
new Thread(Acceptor).start()
val acceptorThread = new Thread(Acceptor)
acceptorThread.start()
val fullCp = classpath ++: Seq(IO.classLocationFile[ForkMain], IO.classLocationFile[Framework])
val options = Seq("-classpath", fullCp mkString File.pathSeparator, classOf[ForkMain].getCanonicalName, server.getLocalPort.toString)
@ -80,8 +81,11 @@ private[sbt] object ForkTests {
val result =
if (ec != 0)
(TestResult.Error, Map("Running java with options " + options.mkString(" ") + " failed with exit code " + ec -> TestResult.Error))
else
else {
// Need to wait acceptor thread to finish its business
acceptorThread.join()
Acceptor.result
}
testListeners.foreach(_.doComplete(result._1))
result
} finally {