Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gares committed Dec 18, 2024
1 parent 77f8cf7 commit 3e5ba47
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
12 changes: 10 additions & 2 deletions language-server/tests/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@
(* *)
(**************************************************************************)

[%%import "vscoq_config.mlh"]

open Dm
open Base
open Types
open Protocol.LspWrapper

[%%if lsp < (1,19,0) ]
let string_of_message x = x
[%%else]
let string_of_message = function `String x -> x | _ -> assert false
[%%endif]

[%%if coq = "8.18" || coq = "8.19" || coq = "8.20"]
let injections =
Coqinit.init_ocaml ();
Expand Down Expand Up @@ -180,7 +188,7 @@ type diag_spec =

let check_no_diag st =
let diagnostics = DocumentManager.all_diagnostics st in
let diagnostics = List.map ~f:Lsp.Types.Diagnostic.(fun d -> d.range, d.message, d.severity) diagnostics in
let diagnostics = List.map ~f:Lsp.Types.Diagnostic.(fun d -> d.range, string_of_message d.message, d.severity) diagnostics in
[%test_pred: (Range.t * string * DiagnosticSeverity.t option) list] List.is_empty diagnostics

type diagnostic_summary = Range.t * string * DiagnosticSeverity.t option [@@deriving sexp]
Expand All @@ -189,7 +197,7 @@ let check_diag st specl =
let open Result in
let open Lsp.Types.Diagnostic in
let diagnostic_summary { range; message; severity } =
let message = Str.global_replace (Str.regexp_string "\n") " " message in
let message = Str.global_replace (Str.regexp_string "\n") " " (string_of_message message) in
let message = Str.global_replace (Str.regexp " Raised at .*$") "" message in
(range, message, severity) in
let match_diagnostic r s rex (range, message, severity) =
Expand Down
11 changes: 11 additions & 0 deletions language-server/tests/dune
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,15 @@
(libraries base dm protocol)
(preprocess
(pps ppx_sexp_conv ppx_inline_test ppx_assert ppx_optcomp -- -cookie "ppx_optcomp.env=env ~coq:(Defined \"%{coq:version.major}.%{coq:version.minor}\")"))
(preprocessor_deps vscoq_config.mlh)
(inline_tests))


(rule
(target vscoq_config.mlh)
(action (with-stdout-to %{target}
(progn
(echo "(* Automatically generated, don't edit *)\n")
(echo "[%%define lsp ")
(run vscoq_version_parser %{version:lsp})
(echo "]\n")))))

0 comments on commit 3e5ba47

Please sign in to comment.