Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ jobs:

- uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
cache: 'sbt'
distribution: "temurin"
java-version: "17"
cache: "sbt"

- name: Setup sbt
uses: sbt/setup-sbt@v1

- name: Test
run: sbt ci buildWebsite
Expand Down
13 changes: 11 additions & 2 deletions modules/e2e-tests/src/test/scala/EndToEndTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import cats.effect.kernel.Resource
import java.lang.management.ManagementFactory

import langoustine.example.{MyCustomRequest, MyCustomNotification}
import fs2.io.process.Processes

case class Result(code: Int, stdout: List[String], stderr: List[String])

Expand Down Expand Up @@ -91,7 +92,11 @@ object EndToEndTests extends SimpleIOSuite:
.compile
.toVector

langoustine.ChildProcess.resource[IO](process*).use { prc =>
val procR = Processes[IO].spawn(
fs2.io.process.ProcessBuilder(process.head, process.tail*)
)

procR.use { prc =>
IO.ref("")
.flatMap { fromStdout =>
prc.stdout
Expand All @@ -100,7 +105,11 @@ object EndToEndTests extends SimpleIOSuite:
.compile
.drain
.start *>
fs2.Stream.emits(send.getBytes).through(prc.stdin).compile.drain *>
fs2.Stream
.emits(send.getBytes)
.through(prc.stdin)
.compile
.drain *>
IO.sleep(timeout) *>
fromStdout.get
}
Expand Down
101 changes: 0 additions & 101 deletions modules/tracer/backend/src/main/scala/ChildProcess.scala

This file was deleted.

9 changes: 6 additions & 3 deletions modules/tracer/backend/src/main/scala/browser.open.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ import com.indoorvivants.detective.Platform.OS.MacOS
import com.indoorvivants.detective.Platform.OS.Linux
import com.indoorvivants.detective.Platform.OS.Unknown
import scala.util.Failure
import fs2.io.process.Processes

def openBrowser(url: Uri): IO[Unit] =
val stringUri = url.renderString

def cmd(args: String*) =
Try(sys.process.Process.apply(args).!!)
Processes[IO]
.spawn(fs2.io.process.ProcessBuilder(args.head, args.tail*))
.use(_.stdout.compile.drain)

val mac = cmd("open", stringUri)
val linux =
Expand All @@ -24,8 +27,8 @@ def openBrowser(url: Uri): IO[Unit] =

Platform.os match
case Windows => Logging.error("Cannot open the browser on windows")
case MacOS => IO.fromTry(mac).void
case Linux => IO.fromTry(linux).void
case MacOS => mac.void
case Linux => linux.void
case Unknown =>
Logging.error("Cannot open the browser on unknown platform")
end openBrowser
Expand Down
12 changes: 9 additions & 3 deletions modules/tracer/backend/src/main/scala/command.trace.scala
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.http4s.server.Server
import jsonrpclib.fs2.lsp
import scala.util.NotGiven
import jsonrpclib.Message
import fs2.io.process.Processes

extension (s: fs2.Stream[IO, Payload])
def debugAs(name: String) =
Expand Down Expand Up @@ -50,8 +51,14 @@ def Trace(
summary: Summary
) =
fs2.Stream.eval(IO.deferred[Communicate[IO]]).flatMap { comms =>
langoustine.ChildProcess
.spawn[IO](traceConfig.cmd.toList*)
fs2.Stream
.resource {
Processes[IO]
.spawn(
fs2.io.process
.ProcessBuilder(traceConfig.cmd.head, traceConfig.cmd.tail)
)
}
.flatMap { child =>

import langoustine.lsp.jsonrpcIntegration.given
Expand Down Expand Up @@ -107,7 +114,6 @@ def Trace(
.through(inBytes.publish)
.onFinalize(
Logging.info("process stdin finished, shutting down tracer") *>
child.terminate *>

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests pass, but I feel like we may be missing something if this isn't called. The fs2 process API doesn't actually have a method for killing the process, guess you have to somehow provoke the resource to exit early instead.

How would I confirm whether this is fine as-is?

exits.complete(true).void
)

Expand Down

This file was deleted.