-
Notifications
You must be signed in to change notification settings - Fork 935
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replicate failing to open port on Windows
- Loading branch information
1 parent
09e06c4
commit fdcdd8b
Showing
3 changed files
with
40 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* | ||
* sbt | ||
* Copyright 2011 - 2018, Lightbend, Inc. | ||
* Copyright 2008 - 2010, Mark Harrah | ||
* Licensed under Apache License 2.0 (see LICENSE) | ||
*/ | ||
|
||
package xsbt | ||
|
||
import org.scalatest.flatspec.AnyFlatSpec | ||
import org.scalatest.matchers.should.Matchers._ | ||
import xsbt.IPC.Server | ||
|
||
import java.net.Socket | ||
|
||
class IPCSpec extends AnyFlatSpec { | ||
"server" should "find free open ports and close them" in { | ||
val openedServers = collection.mutable.Set.empty[(Server, Socket)] | ||
val portsToTest = 1000 | ||
|
||
noException should be thrownBy { | ||
(1 to portsToTest).foreach { _ => | ||
val server = IPC.unmanagedServer | ||
openedServers.add((server, new Socket(IPC.loopback, server.port))) | ||
} | ||
} | ||
|
||
openedServers.size shouldBe 1000 | ||
|
||
Thread.sleep(10000) | ||
|
||
openedServers.foreach { | ||
case (server, socket) => | ||
noException should be thrownBy socket.close() | ||
noException should be thrownBy server.close() | ||
} | ||
} | ||
} |