summaryrefslogtreecommitdiff
path: root/test/disabled/run/t6987.scala
blob: 37e91d61ae228b106aa289e678b210b3f88b68c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.io._
import tools.nsc.{CompileClient, CompileServer}
import java.util.concurrent.{CountDownLatch, TimeUnit}

object Test extends App {
  val startupLatch = new CountDownLatch(1)
  // we have to explicitly launch our server because when the client launches a server it uses 
  // the "scala" shell command meaning whatever version of scala (and whatever version of libraries)
  // happens to be in the path gets used
  val t = new Thread(new Runnable {
    def run() = {
      CompileServer.execute(() => startupLatch.countDown(), Array[String]())
    }
  })
  t setDaemon true
  t.start()
  if (!startupLatch.await(2, TimeUnit.MINUTES))
    sys error "Timeout waiting for server to start"

  val baos = new ByteArrayOutputStream()
  val ps = new PrintStream(baos) 

  val success = (scala.Console withOut ps) {
    // shut down the server via the client using the verbose flag
    CompileClient.process(Array("-shutdown", "-verbose"))
  }

  // now make sure we got success and a verbose result
  val msg = baos.toString()

  if (success) {
    if (msg contains "Settings after normalizing paths") {
     println("got successful verbose results!")
    } else {
     println("did not get the string expected, full results were:")
     println(msg)
    }
  } else {
    println("got a failure. Full results were:")
    println(msg)
  }
  scala.Console.flush
}