diff --git a/Makefile b/Makefile index 04690e74d..8afdbd1b7 100644 --- a/Makefile +++ b/Makefile @@ -42,8 +42,7 @@ bench: ## .PHONY: test-ocaml test-ocaml: ## Run the unit tests - # FIXME: Find another approach to prevent competing test runs from causing errors - dune build -j 1 @lsp/test/runtest @lsp-fiber/runtest @jsonrpc-fiber/runtest @ocaml-lsp-server/runtest + dune build @lsp/test/runtest @lsp-fiber/runtest @jsonrpc-fiber/runtest @ocaml-lsp-server/runtest .PHONY: promote promote: @@ -106,6 +105,5 @@ coverage-deps: .PHONY: test-coverage test-coverage: - # FIXME: Find another approach to prevent competing test runs from causing errors - dune build -j 1 --instrument-with bisect_ppx --force @lsp/test/runtest @lsp-fiber/runtest @jsonrpc-fiber/runtest @ocaml-lsp-server/runtest + dune build --instrument-with bisect_ppx --force @lsp/test/runtest @lsp-fiber/runtest @jsonrpc-fiber/runtest @ocaml-lsp-server/runtest bisect-ppx-report send-to Coveralls diff --git a/ocaml-lsp-server/test/e2e-new/helpers.ml b/ocaml-lsp-server/test/e2e-new/helpers.ml index 9e856e6a7..5039f1bb2 100644 --- a/ocaml-lsp-server/test/e2e-new/helpers.ml +++ b/ocaml-lsp-server/test/e2e-new/helpers.ml @@ -5,13 +5,8 @@ let client_capabilities = ClientCapabilities.create () let uri = DocumentUri.of_path "test.ml" let test ?extra_env text req = - let handler = - Client.Handler.make - ~on_notification:(fun client _notification -> - Client.state client; - Fiber.return ()) - () - in + let on_notification, diagnostics = Test.drain_diagnostics () in + let handler = Client.Handler.make ~on_notification () in Test.run ~handler ?extra_env (fun client -> let run_client () = Client.start @@ -31,6 +26,7 @@ let test ?extra_env text req = in let* () = req client in let* () = Client.request client Shutdown in + let* () = Fiber.Ivar.read diagnostics in Client.stop client in Fiber.fork_and_join_unit run_client run) diff --git a/ocaml-lsp-server/test/e2e-new/test.ml b/ocaml-lsp-server/test/e2e-new/test.ml index de646efc4..5a4f71b4b 100644 --- a/ocaml-lsp-server/test/e2e-new/test.ml +++ b/ocaml-lsp-server/test/e2e-new/test.ml @@ -168,19 +168,21 @@ end include T -let run_request ?(prep = fun _ -> Fiber.return ()) ?settings request = +let drain_diagnostics () = let diagnostics = Fiber.Ivar.create () in - let handler = - Client.Handler.make - ~on_notification:(fun _ -> function - | PublishDiagnostics _ -> ( - let* diag = Fiber.Ivar.peek diagnostics in - match diag with - | Some _ -> Fiber.return () - | None -> Fiber.Ivar.fill diagnostics ()) - | _ -> Fiber.return ()) - () + let on_notification _ = function + | Lsp.Server_notification.PublishDiagnostics _ -> ( + let* diag = Fiber.Ivar.peek diagnostics in + match diag with + | Some _ -> Fiber.return () + | None -> Fiber.Ivar.fill diagnostics ()) + | _ -> Fiber.return () in + (on_notification, diagnostics) + +let run_request ?(prep = fun _ -> Fiber.return ()) ?settings request = + let on_notification, diagnostics = drain_diagnostics () in + let handler = Client.Handler.make ~on_notification () in run ~handler @@ fun client -> let run_client () = let capabilities =