summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJames Iry <jamesiry@gmail.com>2013-01-17 11:46:10 -0800
committerJames Iry <jamesiry@gmail.com>2013-01-22 12:27:12 -0800
commit1dab5bf91361b8d6073db05ba1dff1bc01a83220 (patch)
treeea048566662a8a572cad5f49da171dc902a2913e /test
parente12a5b88acd80a41574d51c88a7776f99c3d2580 (diff)
downloadscala-1dab5bf91361b8d6073db05ba1dff1bc01a83220.tar.gz
scala-1dab5bf91361b8d6073db05ba1dff1bc01a83220.tar.bz2
scala-1dab5bf91361b8d6073db05ba1dff1bc01a83220.zip
SI-6987 Tests fsc verbose output
This commit includes a test of fsc's verbose output. In order for it to work, CompileServer's main method had to be modified to remove a sys exit 0 at the end. It was redundant and made testing a bit harder. In order to prevent a race condition between server and client start up, this commit also adds a server callback that decrements a CountDownLatch that the main testing thread waits for. Finally, the server had to be modified to use Console.withErr and Console.withOut instead of mutating the global System.err and System.out variables. Otherwise the test would be unreliable.
Diffstat (limited to 'test')
-rw-r--r--test/files/run/t6987.check1
-rw-r--r--test/files/run/t6987.scala43
2 files changed, 44 insertions, 0 deletions
diff --git a/test/files/run/t6987.check b/test/files/run/t6987.check
new file mode 100644
index 0000000000..86fc96c679
--- /dev/null
+++ b/test/files/run/t6987.check
@@ -0,0 +1 @@
+got successful verbose results!
diff --git a/test/files/run/t6987.scala b/test/files/run/t6987.scala
new file mode 100644
index 0000000000..37e91d61ae
--- /dev/null
+++ b/test/files/run/t6987.scala
@@ -0,0 +1,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
+}