Skip to content

Commit

Permalink
Add support for OCaml 5.00
Browse files Browse the repository at this point in the history
  • Loading branch information
kit-ty-kate authored and gildor478 committed Feb 8, 2022
1 parent 4169ea0 commit 9345a47
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 11 deletions.
1 change: 1 addition & 0 deletions ounit2-lwt.opam
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ depends: [
"ocaml" {>= "4.04.0"}
"dune" {>= "1.11.0"}
"lwt"
"seq"
"ounit2" {= version}
]
build: [
Expand Down
1 change: 1 addition & 0 deletions ounit2.opam
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ depends: [
"dune" {>= "1.11.0"}
"base-bytes"
"base-unix"
"seq"
"stdlib-shims"
]
build: [
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ounit2/advanced/dune
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
(name oUnitAdvanced)
(public_name ounit2.advanced)
(wrapped false)
(libraries unix bytes stdlib-shims))
(libraries unix bytes seq stdlib-shims))
10 changes: 7 additions & 3 deletions src/lib/ounit2/advanced/oUnitAssert.ml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ let assert_bool msg b =
let assert_string str =
if not (str = "") then assert_failure str

(* TODO: Use Seq.forever from OCaml >= 4.14 *)
let rec seq_forever f () =
Seq.Cons (f(), seq_forever f)

let assert_equal ?ctxt ?(cmp = ( = )) ?printer ?pp_diff ?msg expected actual =
let get_error_string () =
let res =
Expand Down Expand Up @@ -127,7 +131,7 @@ let assert_equal ?ctxt ?(cmp = ( = )) ?printer ?pp_diff ?msg expected actual =

let assert_command
?(exit_code=Unix.WEXITED 0)
?(sinput=Stream.of_list [])
?(sinput=Seq.empty)
?(foutput=ignore)
?(use_stderr=true)
?(backtrace=true)
Expand Down Expand Up @@ -267,7 +271,7 @@ let assert_command
let () =
(* Dump sinput into the process stdin *)
let buff = Bytes.make 1 ' ' in
Stream.iter
Seq.iter
(fun c ->
let _i : int =
Bytes.set buff 0 c;
Expand Down Expand Up @@ -312,7 +316,7 @@ let assert_command
begin
let chn = open_in fn_out in
try
foutput (Stream.of_channel chn)
foutput (seq_forever (fun () -> input_char chn))
with e ->
close_in chn;
raise e
Expand Down
2 changes: 1 addition & 1 deletion src/lib/ounit2/dune
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
(name oUnit)
(public_name ounit2)
(wrapped false)
(libraries unix ounit2.advanced))
(libraries unix seq ounit2.advanced))

(documentation
(package ounit2)
Expand Down
6 changes: 3 additions & 3 deletions src/lib/ounit2/oUnit.mli
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ val assert_string : string -> unit
(** [assert_command prg args] Run the command provided.
@param exit_code expected exit code
@param sinput provide this [char Stream.t] as input of the process
@param sinput provide this [char Seq.t] as input of the process
@param foutput run this function on output, it can contains an
[assert_equal] to check it
@param use_stderr redirect [stderr] to [stdout]
Expand All @@ -77,8 +77,8 @@ val assert_string : string -> unit
*)
val assert_command :
?exit_code:Unix.process_status ->
?sinput:char Stream.t ->
?foutput:(char Stream.t -> unit) ->
?sinput:char Seq.t ->
?foutput:(char Seq.t -> unit) ->
?use_stderr:bool ->
?env:string array ->
?verbose:bool ->
Expand Down
6 changes: 3 additions & 3 deletions src/lib/ounit2/oUnit2.mli
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ val assert_string : string -> unit
(** [assert_command prg args] Run the command provided.
@param exit_code expected exit code
@param sinput provide this [char Stream.t] as input of the process
@param sinput provide this [char Seq.t] as input of the process
@param foutput run this function on output, it can contains an
[assert_equal] to check it
@param use_stderr redirect [stderr] to [stdout]
Expand All @@ -85,8 +85,8 @@ val assert_string : string -> unit
*)
val assert_command :
?exit_code:Unix.process_status ->
?sinput:char Stream.t ->
?foutput:(char Stream.t -> unit) ->
?sinput:char Seq.t ->
?foutput:(char Seq.t -> unit) ->
?use_stderr:bool ->
?backtrace:bool ->
?chdir:string ->
Expand Down

0 comments on commit 9345a47

Please sign in to comment.