Skip to content

Commit f42d3ac

Browse files
fix(unix-sockets): use temp file for socket path instead of fixed path (#1958)
Fixes relative `base-dir` configurations, as well as issues where the socket path was too long to handle (when the project is located in a deeply nested directory).
1 parent 4e79915 commit f42d3ac

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

modules/sbt/src/main/scala/stryker4s/sbt/runner/ProcessTestRunner.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,9 +217,12 @@ object ProcessTestRunner extends TestInterfaceMapper {
217217
testProcess.sendMessage(testContext).void
218218
}
219219

220-
def getSocketAddress(id: TestRunnerId)(implicit config: Config): IO[GenSocketAddress] =
220+
def getSocketAddress(id: TestRunnerId): IO[GenSocketAddress] =
221221
unixSocketSupported.ifM(
222-
IO.pure(UnixSocketAddress((config.baseDir / "target" / s"stryker4s-$id.sock").toString)),
222+
// Creates a temp file and then deletes it. But this ensures there is a known unique path for the socket
223+
Files[IO]
224+
.tempFile(None, "s4s-", ".sock", None)
225+
.use(path => IO.pure(UnixSocketAddress(path.toString))),
223226
IO.pure {
224227
val portStart = 13336
225228
SocketAddress(ipv4"127.0.0.1", Port.fromInt(portStart + id.value).get)

0 commit comments

Comments
 (0)