Skip to content

Commit 9576302

Browse files
authored
Merge pull request #333 from psafont/private/paus/yang-ppx
CP-38064: compatibility with rpclib 7
2 parents a849c4b + a7d07ab commit 9576302

File tree

1 file changed

+26
-10
lines changed

1 file changed

+26
-10
lines changed

lib_test/idl_test_common.ml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ module type CONFIG = sig
3333
end
3434

3535
module type MARSHALLER = sig
36-
val string_of_call : Rpc.call -> string
36+
val string_of_call : ?strict:bool -> Rpc.call -> string
3737

3838
val call_of_string : string -> Rpc.call
3939

40-
val string_of_response : Rpc.response -> string
40+
val string_of_response : ?strict:bool -> Rpc.response -> string
4141

4242
val response_of_string : string -> Rpc.response
4343

44-
val to_string : Rpc.t -> string
44+
val to_string : ?strict:bool -> Rpc.t -> string
4545

4646
val of_string : string -> Rpc.t
4747
end
@@ -54,11 +54,13 @@ module TJsonrpc : MARSHALLER = struct
5454
(* there is a ?strict parameter, and the signature would not match *)
5555
let of_string s = of_string s
5656

57+
let to_string ?(strict : _) t = to_string t
58+
5759
let response_of_string r = response_of_string r
5860

59-
let string_of_call call = string_of_call call
61+
let string_of_call ?(strict : _) call = string_of_call call
6062

61-
let string_of_response response = string_of_response response
63+
let string_of_response ?(strict : _) response = string_of_response response
6264
end
6365

6466
module TXmlrpc : MARSHALLER = struct
@@ -69,6 +71,12 @@ module TXmlrpc : MARSHALLER = struct
6971
let response_of_string s = response_of_string s
7072

7173
let of_string s = of_string s
74+
75+
let to_string ?(strict : _) t = to_string t
76+
77+
let string_of_call ?(strict : _) call = string_of_call call
78+
79+
let string_of_response ?(strict : _) response = string_of_response response
7280
end
7381

7482
(** The following module implements test cases that write test RPC requests and
@@ -105,7 +113,7 @@ module GenTestData (C : CONFIG) (M : MARSHALLER) = struct
105113

106114
open M
107115

108-
let declare name _ ty =
116+
let declare_ response_needed name _ ty =
109117
let rec inner :
110118
type b. ((string * Rpc.t) list * Rpc.t list) list -> b fn -> unit =
111119
fun params -> function
@@ -170,8 +178,8 @@ module GenTestData (C : CONFIG) (M : MARSHALLER) = struct
170178
| _ ->
171179
Rpc.Dict named :: List.rev unnamed
172180
in
173-
let call = Rpc.call wire_name args in
174-
call)
181+
let rpccall = if response_needed then Rpc.notif else Rpc.call in
182+
rpccall wire_name args)
175183
params
176184
in
177185
List.iteri
@@ -229,6 +237,10 @@ module GenTestData (C : CONFIG) (M : MARSHALLER) = struct
229237
, `Quick
230238
, test_fn )
231239
:: !tests
240+
241+
let declare name desc_list ty = declare_ false name desc_list ty
242+
243+
let declare_notification name desc_list ty = declare_ true name desc_list ty
232244
end
233245

234246
let get_arg call has_named name is_opt =
@@ -315,8 +327,8 @@ module TestOldRpcs (C : CONFIG) (M : MARSHALLER) = struct
315327
| Returning (_, _) ->
316328
false
317329

318-
let declare : string -> string list -> 'a fn -> _ res =
319-
fun name _ ty ->
330+
let declare_ : bool -> string -> string list -> 'a fn -> _ res =
331+
fun _notification name _ ty ->
320332
( (* Sanity check: ensure the description has been set before we declare any
321333
RPCs *)
322334
match !description with
@@ -430,4 +442,8 @@ module TestOldRpcs (C : CONFIG) (M : MARSHALLER) = struct
430442
responses
431443
in
432444
tests := !tests @ request_tests @ response_tests
445+
446+
let declare name desc_list ty = declare_ false name desc_list ty
447+
448+
let declare_notification name desc_list ty = declare_ true name desc_list ty
433449
end

0 commit comments

Comments
 (0)