From 4f51bd1ccc7cb68822a59ec07946242c1394e8c4 Mon Sep 17 00:00:00 2001 From: Li Haoyi Date: Sun, 8 Apr 2018 07:39:32 -0700 Subject: explicitly disable clientserver tests on windows --- main/test/src/mill/main/ClientServerTests.scala | 152 ++++++++++++------------ 1 file changed, 77 insertions(+), 75 deletions(-) (limited to 'main/test') diff --git a/main/test/src/mill/main/ClientServerTests.scala b/main/test/src/mill/main/ClientServerTests.scala index d18c01b2..e0e74fc7 100644 --- a/main/test/src/mill/main/ClientServerTests.scala +++ b/main/test/src/mill/main/ClientServerTests.scala @@ -3,7 +3,7 @@ package mill.main import java.io._ import java.nio.file.Path -import mill.client.Locks +import mill.client.{ClientServer, Locks} import utest._ class EchoServer extends ServerMain[Int]{ def main0(args: Array[String], @@ -39,84 +39,86 @@ object ClientServerTests extends TestSuite{ def tests = Tests{ 'hello - { - val (tmpDir, locks) = init() - - def spawnEchoServer(): Unit = { - new Thread(() => new Server( - tmpDir.toString, - new EchoServer(), - () => (), - 1000, - locks - ).run()).start() - } - + if (!ClientServer.isWindows){ + val (tmpDir, locks) = init() - def runClient(arg: String) = { - val (in, out, err) = initStreams() - Server.lockBlock(locks.clientLock){ - mill.client.Main.run( + def spawnEchoServer(): Unit = { + new Thread(() => new Server( tmpDir.toString, - () => spawnEchoServer(), - locks, - in, - out, - err, - Array(arg) - ) - Thread.sleep(100) - (new String(out.toByteArray), new String(err.toByteArray)) + new EchoServer(), + () => (), + 1000, + locks + ).run()).start() } - } - // Make sure the simple "have the client start a server and - // exchange one message" workflow works from end to end. - - assert( - locks.clientLock.probe(), - locks.serverLock.probe(), - locks.processLock.probe() - ) - - val (out1, err1) = runClient("world") - - assert( - out1 == "helloworld\n", - err1 == "HELLOworld\n" - ) - - // Give a bit of time for the server to release the lock and - // re-acquire it to signal to the client that it's done - Thread.sleep(100) - - assert( - locks.clientLock.probe(), - !locks.serverLock.probe(), - !locks.processLock.probe() - ) - - // A seecond client in sequence connect to the same server - val (out2, err2) = runClient(" WORLD") - - assert( - out2 == "hello WORLD\n", - err2 == "HELLO WORLD\n" - ) - - // Make sure the server times out of not used for a while - Thread.sleep(2000) - assert( - locks.clientLock.probe(), - locks.serverLock.probe(), - locks.processLock.probe() - ) - - // Have a third client spawn/connect-to a new server at the same path - val (out3, err3) = runClient(" World") - assert( - out3 == "hello World\n", - err3 == "HELLO World\n" - ) + + def runClient(arg: String) = { + val (in, out, err) = initStreams() + Server.lockBlock(locks.clientLock){ + mill.client.Main.run( + tmpDir.toString, + () => spawnEchoServer(), + locks, + in, + out, + err, + Array(arg) + ) + Thread.sleep(100) + (new String(out.toByteArray), new String(err.toByteArray)) + } + } + + // Make sure the simple "have the client start a server and + // exchange one message" workflow works from end to end. + + assert( + locks.clientLock.probe(), + locks.serverLock.probe(), + locks.processLock.probe() + ) + + val (out1, err1) = runClient("world") + + assert( + out1 == "helloworld\n", + err1 == "HELLOworld\n" + ) + + // Give a bit of time for the server to release the lock and + // re-acquire it to signal to the client that it's done + Thread.sleep(100) + + assert( + locks.clientLock.probe(), + !locks.serverLock.probe(), + !locks.processLock.probe() + ) + + // A seecond client in sequence connect to the same server + val (out2, err2) = runClient(" WORLD") + + assert( + out2 == "hello WORLD\n", + err2 == "HELLO WORLD\n" + ) + + // Make sure the server times out of not used for a while + Thread.sleep(2000) + assert( + locks.clientLock.probe(), + locks.serverLock.probe(), + locks.processLock.probe() + ) + + // Have a third client spawn/connect-to a new server at the same path + val (out3, err3) = runClient(" World") + assert( + out3 == "hello World\n", + err3 == "HELLO World\n" + ) + } } } } -- cgit v1.2.3