mirror of https://github.com/sbt/sbt.git
implement server handshake test
This commit is contained in:
parent
2e4873c7fb
commit
6b8e716428
|
|
@ -26,7 +26,7 @@ env:
|
|||
- SBT_CMD="scripted dependency-management/*4of4"
|
||||
- SBT_CMD="scripted java/* package/* reporter/* run/* project-load/*"
|
||||
- SBT_CMD="scripted project/*1of2"
|
||||
- SBT_CMD="scripted project/*2of2"
|
||||
- SBT_CMD="scripted project/*2of2 server/*"
|
||||
- SBT_CMD="scripted source-dependencies/*1of3"
|
||||
- SBT_CMD="scripted source-dependencies/*2of3"
|
||||
- SBT_CMD="scripted source-dependencies/*3of3"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package example
|
||||
|
||||
import java.net.{ URI, Socket, InetAddress, SocketException }
|
||||
import sbt.io._
|
||||
import sbt.io.syntax._
|
||||
import java.io.File
|
||||
|
||||
object Client extends App {
|
||||
val host = "127.0.0.1"
|
||||
val port = 5123
|
||||
val delimiter: Byte = '\n'.toByte
|
||||
|
||||
println("hello")
|
||||
Thread.sleep(1000)
|
||||
|
||||
val connection = getConnection
|
||||
val out = connection.getOutputStream
|
||||
val in = connection.getInputStream
|
||||
|
||||
out.write("""{ "type": "ExecCommand", "commandLine": "exit" }""".getBytes("utf-8"))
|
||||
out.write(delimiter.toInt)
|
||||
out.flush
|
||||
|
||||
val baseDirectory = new File(args(0))
|
||||
IO.write(baseDirectory / "ok.txt", "ok")
|
||||
|
||||
def getConnection: Socket =
|
||||
try {
|
||||
new Socket(InetAddress.getByName(host), port)
|
||||
} catch {
|
||||
case _ =>
|
||||
Thread.sleep(1000)
|
||||
getConnection
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
lazy val runClient = taskKey[Unit]("")
|
||||
|
||||
lazy val root = (project in file("."))
|
||||
.settings(
|
||||
scalaVersion := "2.12.3",
|
||||
serverPort in Global := 5123,
|
||||
libraryDependencies += "org.scala-sbt" %% "io" % "1.0.1",
|
||||
runClient := (Def.taskDyn {
|
||||
val b = baseDirectory.value
|
||||
(bgRun in Compile).toTask(s""" $b""")
|
||||
}).value
|
||||
)
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
> show serverPort
|
||||
> runClient
|
||||
-> shell
|
||||
|
||||
$ sleep 1000
|
||||
$ exists ok.txt
|
||||
Loading…
Reference in New Issue