From 2e56c29d62cb6ecbef26b4a3cd616163dce58d49 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Fri, 23 Aug 2024 22:01:17 +0200 Subject: [PATCH 1/3] Upgrade commandlang & use Expect_test_helpers_base --- bin/dune | 2 +- bin/main.ml | 5 +---- dune-project | 22 +++++++++++++--------- example/dune | 6 +++--- lib/vcs/test/dune | 6 +++--- lib/vcs_arg/test/dune | 13 ++++++++++--- lib/vcs_command/test/dune | 7 +++++-- lib/vcs_git/test/dune | 6 +++--- lib/vcs_git_blocking/test/dune | 12 +++++++++--- lib/vcs_git_cli/test/dune | 9 +++++++-- lib/vcs_test_helpers/test/dune | 6 +++--- test/expect/dune | 6 +++--- vcs-arg.opam | 2 +- vcs-command.opam | 6 +++--- vcs-tests.opam | 7 ++++--- 15 files changed, 69 insertions(+), 46 deletions(-) diff --git a/bin/dune b/bin/dune index dcf88c5..5de501e 100644 --- a/bin/dune +++ b/bin/dune @@ -3,6 +3,6 @@ (public_name ocaml-vcs) (package vcs-command) (flags :standard -w +a-4-40-41-42-44-45-48-66 -warn-error +a) - (libraries commandlang-err commandlang-to-cmdliner vcs-command) + (libraries commandlang-to-cmdliner err0 vcs-command) (instrumentation (backend bisect_ppx))) diff --git a/bin/main.ml b/bin/main.ml index 28a6797..6db82df 100644 --- a/bin/main.ml +++ b/bin/main.ml @@ -25,9 +25,6 @@ let () = ~name:"ocaml-vcs" ~version:"%%VERSION%%" ~exn_handler:(function - | Vcs.E e -> - Some - (Commandlang_err.Err.make - [ Commandlang_err.Err.pp_of_sexp (Vcs.Err.sexp_of_t e) ]) + | Vcs.E e -> Some (Err0.Err.make [ Err0.Err.pp_of_sexp (Vcs.Err.sexp_of_t e) ]) | _ -> None [@coverage off]) ;; diff --git a/dune-project b/dune-project index 7480273..02aa683 100644 --- a/dune-project +++ b/dune-project @@ -90,7 +90,7 @@ :dev (>= 2.8.3))) (commandlang - (>= 0.0.1)) + (>= 0.0.2)) (eio (>= 1.0)) (fpath @@ -154,15 +154,15 @@ (cmdliner (= 1.3.0)) (commandlang - (>= 0.0.1)) - (commandlang-err - (>= 0.0.1)) + (>= 0.0.2)) (commandlang-to-cmdliner - (>= 0.0.1)) + (>= 0.0.2)) (eio (>= 1.0)) (eio_main (>= 1.0)) + (err0 + (>= 0.0.2)) (fpath (>= 0.7.3)) (fpath-base @@ -413,11 +413,9 @@ (cmdliner (= 1.3.0)) (commandlang - (>= 0.0.1)) - (commandlang-err - (>= 0.0.1)) + (>= 0.0.2)) (commandlang-to-cmdliner - (>= 0.0.1)) + (>= 0.0.2)) (core (and (>= v0.17) @@ -426,6 +424,12 @@ (>= 1.0)) (eio_main (>= 1.0)) + (err0 + (>= 0.0.2)) + (expect_test_helpers_core + (and + (>= v0.17) + (< v0.18))) (fpath (>= 0.7.3)) (fpath-base diff --git a/example/dune b/example/dune index 3f6ac30..a85c988 100644 --- a/example/dune +++ b/example/dune @@ -11,16 +11,16 @@ -open Base -open - Expect_test_helpers - -open Fpath_base -open + Expect_test_helpers_base + -open Or_error.Let_syntax) (libraries base eio eio_main - expect_test_helpers + expect_test_helpers_core.expect_test_helpers_base fpath fpath-base vcs diff --git a/lib/vcs/test/dune b/lib/vcs/test/dune index 77e12d0..a0e3854 100644 --- a/lib/vcs/test/dune +++ b/lib/vcs/test/dune @@ -16,16 +16,16 @@ -open Base -open - Expect_test_helpers - -open Fpath_base -open + Expect_test_helpers_base + -open Or_error.Let_syntax) (libraries base eio eio_main - expect_test_helpers + expect_test_helpers_core.expect_test_helpers_base fpath fpath-base vcs diff --git a/lib/vcs_arg/test/dune b/lib/vcs_arg/test/dune index 6874751..3510e0d 100644 --- a/lib/vcs_arg/test/dune +++ b/lib/vcs_arg/test/dune @@ -11,10 +11,17 @@ -open Base -open - Expect_test_helpers + Fpath_base -open - Fpath_base) - (libraries base eio eio_main expect_test_helpers fpath fpath-base vcs_arg) + Expect_test_helpers_base) + (libraries + base + eio + eio_main + expect_test_helpers_core.expect_test_helpers_base + fpath + fpath-base + vcs_arg) (instrumentation (backend bisect_ppx)) (lint diff --git a/lib/vcs_command/test/dune b/lib/vcs_command/test/dune index 5fae6a2..08c3076 100644 --- a/lib/vcs_command/test/dune +++ b/lib/vcs_command/test/dune @@ -11,8 +11,11 @@ -open Base -open - Expect_test_helpers) - (libraries base expect_test_helpers vcs_command) + Expect_test_helpers_base) + (libraries + base + expect_test_helpers_core.expect_test_helpers_base + vcs_command) (instrumentation (backend bisect_ppx)) (lint diff --git a/lib/vcs_git/test/dune b/lib/vcs_git/test/dune index d61a494..d6ce3e7 100644 --- a/lib/vcs_git/test/dune +++ b/lib/vcs_git/test/dune @@ -11,16 +11,16 @@ -open Base -open - Expect_test_helpers - -open Fpath_base -open + Expect_test_helpers_base + -open Or_error.Let_syntax) (libraries base eio eio_main - expect_test_helpers + expect_test_helpers_core.expect_test_helpers_base fpath fpath-base vcs diff --git a/lib/vcs_git_blocking/test/dune b/lib/vcs_git_blocking/test/dune index fe6a76a..ceafafb 100644 --- a/lib/vcs_git_blocking/test/dune +++ b/lib/vcs_git_blocking/test/dune @@ -11,10 +11,16 @@ -open Base -open - Expect_test_helpers + Fpath_base -open - Fpath_base) - (libraries base expect_test_helpers fpath fpath-base vcs vcs_git_blocking) + Expect_test_helpers_base) + (libraries + base + expect_test_helpers_core.expect_test_helpers_base + fpath + fpath-base + vcs + vcs_git_blocking) (instrumentation (backend bisect_ppx)) (lint diff --git a/lib/vcs_git_cli/test/dune b/lib/vcs_git_cli/test/dune index 3c6bb99..a7b80fd 100644 --- a/lib/vcs_git_cli/test/dune +++ b/lib/vcs_git_cli/test/dune @@ -16,8 +16,13 @@ -open Base -open - Expect_test_helpers) - (libraries base eio eio_main expect_test_helpers vcs_git_cli) + Expect_test_helpers_base) + (libraries + base + eio + eio_main + expect_test_helpers_core.expect_test_helpers_base + vcs_git_cli) (instrumentation (backend bisect_ppx)) (lint diff --git a/lib/vcs_test_helpers/test/dune b/lib/vcs_test_helpers/test/dune index 1144863..744d636 100644 --- a/lib/vcs_test_helpers/test/dune +++ b/lib/vcs_test_helpers/test/dune @@ -11,16 +11,16 @@ -open Base -open - Expect_test_helpers - -open Fpath_base -open + Expect_test_helpers_base + -open Or_error.Let_syntax) (libraries base eio eio_main - expect_test_helpers + expect_test_helpers_core.expect_test_helpers_base fpath fpath-base vcs diff --git a/test/expect/dune b/test/expect/dune index da60341..f1e4bf3 100644 --- a/test/expect/dune +++ b/test/expect/dune @@ -11,16 +11,16 @@ -open Base -open - Expect_test_helpers - -open Fpath_base -open + Expect_test_helpers_base + -open Or_error.Let_syntax) (libraries base eio eio_main - expect_test_helpers + expect_test_helpers_core.expect_test_helpers_base fpath fpath-base vcs diff --git a/vcs-arg.opam b/vcs-arg.opam index cd6b57c..247c933 100644 --- a/vcs-arg.opam +++ b/vcs-arg.opam @@ -12,7 +12,7 @@ depends: [ "ocaml" {>= "5.2"} "base" {>= "v0.17" & < "v0.18"} "bisect_ppx" {dev & >= "2.8.3"} - "commandlang" {>= "0.0.1"} + "commandlang" {>= "0.0.2"} "eio" {>= "1.0"} "fpath" {>= "0.7.3"} "fpath-base" {>= "0.0.9"} diff --git a/vcs-command.opam b/vcs-command.opam index 158684d..5911453 100644 --- a/vcs-command.opam +++ b/vcs-command.opam @@ -13,11 +13,11 @@ depends: [ "base" {>= "v0.17" & < "v0.18"} "bisect_ppx" {dev & >= "2.8.3"} "cmdliner" {= "1.3.0"} - "commandlang" {>= "0.0.1"} - "commandlang-err" {>= "0.0.1"} - "commandlang-to-cmdliner" {>= "0.0.1"} + "commandlang" {>= "0.0.2"} + "commandlang-to-cmdliner" {>= "0.0.2"} "eio" {>= "1.0"} "eio_main" {>= "1.0"} + "err0" {>= "0.0.2"} "fpath" {>= "0.7.3"} "fpath-base" {>= "0.0.9"} "ppx_compare" {>= "v0.17" & < "v0.18"} diff --git a/vcs-tests.opam b/vcs-tests.opam index 780243c..f82152a 100644 --- a/vcs-tests.opam +++ b/vcs-tests.opam @@ -14,12 +14,13 @@ depends: [ "base_quickcheck" {>= "v0.17" & < "v0.18"} "bisect_ppx" {dev & >= "2.8.3"} "cmdliner" {= "1.3.0"} - "commandlang" {>= "0.0.1"} - "commandlang-err" {>= "0.0.1"} - "commandlang-to-cmdliner" {>= "0.0.1"} + "commandlang" {>= "0.0.2"} + "commandlang-to-cmdliner" {>= "0.0.2"} "core" {>= "v0.17" & < "v0.18"} "eio" {>= "1.0"} "eio_main" {>= "1.0"} + "err0" {>= "0.0.2"} + "expect_test_helpers_core" {>= "v0.17" & < "v0.18"} "fpath" {>= "0.7.3"} "fpath-base" {>= "0.0.9"} "mdx" {with-doc & >= "2.4"} From 5ec019a91629b6353f1ad40ecf1c8c8530446cce Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Fri, 23 Aug 2024 22:01:38 +0200 Subject: [PATCH 2/3] Remove now unused vendor dir --- vendor/expect-test-helpers/LICENSE | 21 - vendor/expect-test-helpers/LICENSE.janestreet | 25 - vendor/expect-test-helpers/src/dune | 25 - .../src/expect_test_helpers.ml | 1 - .../src/expect_test_helpers_base.ml | 811 ------------------ .../src/expect_test_helpers_base.mli | 1 - .../src/expect_test_helpers_base_intf.ml | 492 ----------- vendor/update-expect-test-helpers.sh | 26 - 8 files changed, 1402 deletions(-) delete mode 100644 vendor/expect-test-helpers/LICENSE delete mode 100644 vendor/expect-test-helpers/LICENSE.janestreet delete mode 100644 vendor/expect-test-helpers/src/dune delete mode 100644 vendor/expect-test-helpers/src/expect_test_helpers.ml delete mode 100644 vendor/expect-test-helpers/src/expect_test_helpers_base.ml delete mode 100644 vendor/expect-test-helpers/src/expect_test_helpers_base.mli delete mode 100644 vendor/expect-test-helpers/src/expect_test_helpers_base_intf.ml delete mode 100755 vendor/update-expect-test-helpers.sh diff --git a/vendor/expect-test-helpers/LICENSE b/vendor/expect-test-helpers/LICENSE deleted file mode 100644 index 4c9862b..0000000 --- a/vendor/expect-test-helpers/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2024 Mathieu Barbin - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/vendor/expect-test-helpers/LICENSE.janestreet b/vendor/expect-test-helpers/LICENSE.janestreet deleted file mode 100644 index 6fe16ff..0000000 --- a/vendor/expect-test-helpers/LICENSE.janestreet +++ /dev/null @@ -1,25 +0,0 @@ -This library re-publishes the original `expect_test_helpers_base` library in order -to make it a standalone opam package. The original code can be found -[here](https://github.com/janestreet/core/tree/master/expect_test_helpers_core) -and has the following license: - -The MIT License - -Copyright (c) 2008--2023 Jane Street Group, LLC opensource-contacts@janestreet.com - -Permission is hereby granted, free of charge, to any person obtaining a copy of -this software and associated documentation files (the "Software"), to deal in -the Software without restriction, including without limitation the rights to -use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of -the Software, and to permit persons to whom the Software is furnished to do so, -subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS -FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR -COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/vendor/expect-test-helpers/src/dune b/vendor/expect-test-helpers/src/dune deleted file mode 100644 index 1a7b0a4..0000000 --- a/vendor/expect-test-helpers/src/dune +++ /dev/null @@ -1,25 +0,0 @@ -(library - (name expect_test_helpers) - (public_name vcs-tests.expect_test_helpers) - (flags - :standard - -w - +a-4-40-41-42-44-45-48-66 - -warn-error - +a - -open - Base - -open - Stdio - -w - -70) - (libraries base base_quickcheck re sexp_pretty stdio) - (inline_tests) - (preprocess - (pps - ppx_compare - ppx_expect - base_quickcheck.ppx_quickcheck - ppx_sexp_conv - ppx_sexp_message - ppx_sexp_value))) diff --git a/vendor/expect-test-helpers/src/expect_test_helpers.ml b/vendor/expect-test-helpers/src/expect_test_helpers.ml deleted file mode 100644 index cf81136..0000000 --- a/vendor/expect-test-helpers/src/expect_test_helpers.ml +++ /dev/null @@ -1 +0,0 @@ -include Expect_test_helpers_base diff --git a/vendor/expect-test-helpers/src/expect_test_helpers_base.ml b/vendor/expect-test-helpers/src/expect_test_helpers_base.ml deleted file mode 100644 index 5c160da..0000000 --- a/vendor/expect-test-helpers/src/expect_test_helpers_base.ml +++ /dev/null @@ -1,811 +0,0 @@ -include Expect_test_helpers_base_intf - -let print_string string = - print_string string; - Out_channel.(flush stdout) -;; - -module CR = struct - include CR - - let message t here = - let cr cr = - String.concat - [ "(* " - ; cr - ; " require-failed: " - ; here |> Source_code_position.to_string - ; ".\n" - ; " Do not 'X' this CR; instead make the required property true,\n" - ; " which will make the CR disappear. For more information, see\n" - ; " [Expect_test_helpers_base.require]. *)" - ] - in - match t with - | CR -> cr "CR" - | CR_soon -> cr "CR-soon" - | CR_someday -> cr "CR-someday" - | Comment -> - String.concat - [ "(* require-failed: "; here |> Source_code_position.to_string; ". *)" ] - | Suppress -> "" - ;; - - let hide_unstable_output = function - | CR -> false - | CR_soon | CR_someday | Comment | Suppress -> true - ;; -end - -module Sexp_style = struct - include Sexp_style - - let default_pretty = Pretty (Sexp_pretty.Config.create ~color:false ()) - - let simple_pretty = - Pretty - { indent = 1 - ; data_alignment = Data_not_aligned - ; color_scheme = [||] - ; atom_coloring = Color_none - ; atom_printing = Escaped - ; paren_coloring = false - ; opening_parens = Same_line - ; closing_parens = Same_line - ; comments = Drop - ; singleton_limit = Singleton_limit (Atom_threshold 0, Character_threshold 0) - ; leading_threshold = Atom_threshold 0, Character_threshold 0 - ; separator = No_separator - ; sticky_comments = After - } - ;; -end - -module Phys_equal (M : sig - type t [@@deriving sexp_of] - end) = -struct - type t = M.t [@@deriving sexp_of] - - let equal = phys_equal -end - -let hide_temp_files_in_string = - let re = lazy (Re.compile (Re.seq [ Re.str ".tmp."; Re.repn Re.alnum 6 (Some 6) ])) in - fun string -> Re.replace_string (force re) ~by:".tmp.RANDOM" string -;; - -let hide_positions_in_string = - let module Re = Re.Pcre in - let expanders = - lazy - ([ (* This first pattern has an alphabetic prefix because we want to match exceptions - and their file positions without also matching timestamps. However, [Re.Pcre] - doesn't implement back-references, precluding a simple substitution. Instead, - we provide a length of matched data to copy into the output, effectively acting - like a back-reference in this special case. *) - "[a-zA-z]:[0-9]+:[0-9]+", 1, ":LINE:COL" - ; "line [0-9]+:", 0, "line LINE:" - ; "line [0-9]+, characters [0-9]+-[0-9]+", 0, "line LINE, characters C1-C2" - ] - |> List.map ~f:(fun (pattern, prefix_len, expansion) -> - let rex = Re.regexp pattern in - fun string -> - Re.substitute ~rex string ~subst:(fun orig -> - String.concat [ String.prefix orig prefix_len; expansion ]))) - in - fun string -> - List.fold (force expanders) ~init:string ~f:(fun ac expander -> expander ac) -;; - -let maybe_hide_positions_in_string ?(hide_positions = false) string = - if hide_positions then hide_positions_in_string string else string -;; - -let sexp_style = ref Sexp_style.default_pretty - -let sexp_to_string ?hide_positions sexp = - let string = - match !sexp_style with - | To_string_mach -> Sexp.to_string_mach sexp ^ "\n" - | To_string_hum -> Sexp.to_string_hum sexp ^ "\n" - | Pretty config -> Sexp_pretty.pretty_string config sexp - in - maybe_hide_positions_in_string ?hide_positions string -;; - -let replace = String.substr_replace_all - -let rec replace_s (sexp : Sexp.t) ~pattern ~with_ : Sexp.t = - match sexp with - | Atom atom -> Atom (replace atom ~pattern ~with_) - | List list -> List (List.map list ~f:(replace_s ~pattern ~with_)) -;; - -let expect_test_output (here : Lexing.position) = - Ppx_expect_runtime.For_external.read_current_test_output_exn ~here -;; - -let am_running_expect_test = Ppx_expect_runtime.For_external.am_running_expect_test - -let assert_am_running_expect_test here = - if am_running_expect_test () - then () - else - raise_s - [%message - "This code should be run inside an expect test; currently, it is running outside \ - an expect test." - ~_:(here : Source_code_position.t)] -;; - -let wrap f = - Staged.stage (fun ?hide_positions string -> - f (maybe_hide_positions_in_string ?hide_positions string)) -;; - -let rec smash_sexp sexp ~f = - match f sexp with - | Sexp.List list -> Sexp.List (List.map list ~f:(smash_sexp ~f)) - | Sexp.Atom _ as atom -> atom -;; - -let remove_backtraces = - let prefixes = - List.concat - [ (* taken from [printexc.ml] in ocaml runtime *) - [ "Raised at " - ; "Re-raised at " - ; "Raised by primitive operation at " - ; "Called from " - ] - (* based on [monitor.ml] in async_kernel *) - ; [ "Caught by monitor " ] - ] - in - smash_sexp ~f:(function - | Sexp.(List (Atom hd :: _)) - when List.exists prefixes ~f:(fun prefix -> String.is_prefix ~prefix hd) -> - Sexp.(List [ Atom "ELIDED BACKTRACE" ]) - | s -> s) -;; - -let print_endline = Staged.unstage (wrap print_endline) -let print_string = Staged.unstage (wrap print_string) -let print_s ?hide_positions sexp = print_string (sexp_to_string ?hide_positions sexp) -let on_print_cr = ref (fun string -> print_endline string) - -let print_cr_with_optional_message - ?(cr = CR.CR) - ?(hide_positions = CR.hide_unstable_output cr) - here - optional_message - = - assert_am_running_expect_test here; - match cr with - | Suppress -> () - | _ -> - let cr = CR.message cr here |> maybe_hide_positions_in_string ~hide_positions in - !on_print_cr - (match optional_message with - | None -> cr - | Some sexp -> - String.concat [ cr; "\n"; String.rstrip (sexp_to_string ~hide_positions sexp) ]) -;; - -let print_cr ?cr ?hide_positions here message = - print_cr_with_optional_message ?cr ?hide_positions here (Some message) -;; - -let require ?cr ?hide_positions ?if_false_then_print_s here bool = - match bool with - | true -> () - | false -> - print_cr_with_optional_message - ?cr - ?hide_positions - here - (Option.map if_false_then_print_s ~f:force) -;; - -let require_equal - (type a) - ?cr - ?hide_positions - ?if_false_then_print_s - ?(message = "values are not equal") - here - (module M : With_equal with type t = a) - x - y - = - require - ?cr - ?hide_positions - here - (M.equal x y) - ~if_false_then_print_s: - (lazy - [%message - message - ~_:(x : M.t) - ~_:(y : M.t) - ~_:(if_false_then_print_s : (Sexp.t Lazy.t option[@sexp.option]))]) -;; - -let require_not_equal - (type a) - ?cr - ?hide_positions - ?if_false_then_print_s - ?(message = "values are equal") - here - (module M : With_equal with type t = a) - x - y - = - require - ?cr - ?hide_positions - here - (not (M.equal x y)) - ~if_false_then_print_s: - (lazy - [%message - message - ~_:(x : M.t) - ~_:(y : M.t) - ~_:(if_false_then_print_s : (Sexp.t Lazy.t option[@sexp.option]))]) -;; - -let require_compare_equal - (type a) - ?cr - ?hide_positions - ?message - here - (module M : With_compare with type t = a) - x - y - = - require_equal - ?cr - ?hide_positions - ?message - here - (module struct - include M - - let equal = [%compare.equal: t] - end) - x - y -;; - -let require_compare_not_equal - (type a) - ?cr - ?hide_positions - ?message - here - (module M : With_compare with type t = a) - x - y - = - require_not_equal - ?cr - ?hide_positions - ?message - here - (module struct - include M - - let equal = [%compare.equal: t] - end) - x - y -;; - -let require_sets_are_equal - (type elt) - ?cr - ?hide_positions - ?(names = "first", "second") - here - first - second - = - let module Elt = struct - type t = elt - - let sexp_of_t = (Set.comparator first).sexp_of_t - end - in - require - ?cr - ?hide_positions - here - (Set.equal first second) - ~if_false_then_print_s: - (lazy - (let show_diff (name1, set1) (name2, set2) = - let diff = Set.diff set1 set2 in - if Set.is_empty diff - then [%message] - else - [%message - (Printf.sprintf "in %s but not in %s" name1 name2) ~_:(diff : Set.M(Elt).t)] - in - let first = fst names, first in - let second = snd names, second in - [%message.omit_nil - "sets are not equal" - ~_:(show_diff first second : Sexp.t) - ~_:(show_diff second first : Sexp.t)])) -;; - -type try_with_result = - | Did_not_raise - | Raised of Sexp.t - -let try_with ?raise_message ?(show_backtrace = false) (type a) (f : unit -> a) = - (Backtrace.Exn.with_recording show_backtrace ~f:(fun () -> - match ignore (f () : a) with - | () -> Did_not_raise - | exception exn -> - let backtrace = - if not show_backtrace then None else Some (Backtrace.Exn.most_recent ()) - in - Ref.set_temporarily Backtrace.elide (not show_backtrace) ~f:(fun () -> - Raised - [%message - "" - ~_:(raise_message : (string option[@sexp.option])) - ~_:(exn : exn) - (backtrace : (Backtrace.t option[@sexp.option]))])) [@nontail]) -;; - -let require_does_not_raise ?cr ?hide_positions ?show_backtrace here f = - match try_with f ?show_backtrace ~raise_message:"unexpectedly raised" with - | Did_not_raise -> () - | Raised message -> print_cr ?cr ?hide_positions here message -;; - -let require_does_raise ?cr ?(hide_positions = false) ?show_backtrace here f = - match try_with f ?show_backtrace with - | Raised message -> print_s ~hide_positions message - | Did_not_raise -> print_cr ?cr ~hide_positions here [%message "did not raise"] -;; - -let require_first_gen - (type first second) - ?cr - ?hide_positions - ?(print_first : (first -> Sexp.t) option) - ~message - here - (sexp_of_second : second -> Sexp.t) - (either : (first, second) Either.t) - = - match either with - | First first -> - (match print_first with - | None -> () - | Some sexp_of_first -> print_s [%sexp (first : first)]) - | Second second -> - print_cr ?cr ?hide_positions here [%message message ~_:(second : second)] -;; - -let require_first = require_first_gen ~message:"unexpected [Second]" - -let require_second ?cr ?hide_positions ?print_second here print_first either = - require_first_gen - ?cr - ?hide_positions - ?print_first:print_second - ~message:"unexpected [First]" - here - print_first - (Either.swap either) -;; - -let require_some ?cr ?hide_positions ?print_some here option = - require_first_gen - ?cr - ~message:"unexpected [None]" - ?hide_positions - ?print_first:print_some - here - [%sexp_of: unit] - (match option with - | Some some -> First some - | None -> Second ()) -;; - -let require_none ?cr ?hide_positions here sexp_of_some option = - require_first_gen - ?cr - ~message:"unexpected [Some]" - ?hide_positions - here - sexp_of_some - (match option with - | None -> First () - | Some some -> Second some) -;; - -let require_ok_result ?cr ?hide_positions ?print_ok here sexp_of_error result = - require_first_gen - ?cr - ~message:"unexpected [Error]" - ?hide_positions - ?print_first:print_ok - here - sexp_of_error - (match result with - | Ok ok -> First ok - | Error error -> Second error) -;; - -let require_error_result ?cr ?hide_positions ?print_error here sexp_of_ok result = - require_first_gen - ?cr - ~message:"unexpected [Ok]" - ?hide_positions - ?print_first:print_error - here - sexp_of_ok - (match result with - | Error error -> First error - | Ok ok -> Second ok) -;; - -let require_ok ?cr ?hide_positions ?print_ok here res = - require_ok_result ?cr ?hide_positions ?print_ok here [%sexp_of: Error.t] res -;; - -let require_error ?cr ?hide_positions ?(print_error = false) here sexp_of_ok res = - let print_error = Option.some_if print_error [%sexp_of: Error.t] in - require_error_result ?cr ?hide_positions ?print_error here sexp_of_ok res -;; - -let print_and_check_round_trip - (type a) - ?cr - ?hide_positions - here - (module T : With_equal with type t = a) - reprs - examples - = - require_does_not_raise ?cr ?hide_positions here (fun () -> - let tag_of name = - String.map name ~f:(fun char -> if Char.is_alphanum char then char else '_') - in - List.iter examples ~f:(fun t -> - (* compute conversions for each value *) - let conversions = - List.map reprs ~f:(fun (module M : With_round_trip with type t = a) -> - let repr = M.to_repr t in - let sexp = M.sexp_of_repr repr in - let round_trip_result = M.of_repr repr in - let name = M.repr_name in - name, sexp, round_trip_result) - in - (* print one-way conversions *) - (match conversions with - | [] -> (* a useless case anyway *) () - | [ (_, sexp, _) ] -> - (* only one repr, print unlabeled *) - print_s sexp - | _ :: _ :: _ -> - (* multiple reprs, print with labels *) - print_s - (List - (List.map conversions ~f:(fun (name, sexp, _) -> - [%sexp (tag_of name : string), (sexp : Sexp.t)])))); - (* check two-way round-trip *) - List.iter conversions ~f:(fun (name, sexp, round_trip) -> - require - ?cr - ?hide_positions - here - (T.equal t round_trip) - ~if_false_then_print_s: - (lazy - (Sexp.message - (name ^ " serialization failed to round-trip") - [ "original", T.sexp_of_t t - ; tag_of name, sexp - ; tag_of name ^ "_roundtrip", T.sexp_of_t round_trip - ]))))) -;; - -let print_and_check_stringable - (type a) - ?cr - ?hide_positions - here - (module T : With_stringable with type t = a) - list - = - let module T = struct - include T - - let sexp_of_t t = Sexp.Atom (to_string t) - end - in - let module Conv = struct - type t = T.t - type repr = string [@@deriving sexp_of] - - let to_repr = T.to_string - let of_repr = T.of_string - let repr_name = "string" - end - in - print_and_check_round_trip ?cr ?hide_positions here (module T) [ (module Conv) ] list -;; - -let print_and_check_sexpable - (type a) - ?cr - ?hide_positions - here - (module T : With_sexpable with type t = a) - list - = - let module Conv = struct - type t = T.t - type repr = Sexp.t [@@deriving sexp_of] - - let to_repr = T.sexp_of_t - let of_repr = T.t_of_sexp - let repr_name = "sexp" - end - in - print_and_check_round_trip ?cr ?hide_positions here (module T) [ (module Conv) ] list -;; - -let show_raise (type a) ?hide_positions ?show_backtrace (f : unit -> a) = - print_s - ?hide_positions - (match try_with f ?show_backtrace ~raise_message:"raised" with - | Did_not_raise -> [%message "did not raise"] - | Raised message -> message) -;; - -let quickcheck_m - (type a) - here - ?config - ?cr - ?examples - ?hide_positions - (module M : Base_quickcheck.Test.S with type t = a) - ~f - = - Base_quickcheck.Test.result - ?config - ?examples - (module M) - ~f:(fun elt -> - let crs = Queue.create () in - (* We set [on_print_cr] to accumulate CRs in [crs]; it affects both [f elt] as - well as our call to [require_does_not_raise]. *) - Ref.set_temporarily on_print_cr (Queue.enqueue crs) ~f:(fun () -> - require_does_not_raise here ?cr ?hide_positions (fun () -> f elt)); - if Queue.is_empty crs then Ok () else Error (Queue.to_list crs)) - |> Result.iter_error ~f:(fun (input, output) -> - print_s [%message "quickcheck: test failed" (input : M.t)]; - List.iter output ~f:print_endline) -;; - -let quickcheck - (type a) - here - ?cr - ?hide_positions - ?(seed = Base_quickcheck.Test.default_config.seed) - ?(sizes = Base_quickcheck.Test.default_config.sizes) - ?(trials = Base_quickcheck.Test.default_config.test_count) - ?(shrinker = Base_quickcheck.Shrinker.atomic) - ?(shrink_attempts = Base_quickcheck.Test.default_config.shrink_count) - ?examples - ~sexp_of - ~f - quickcheck_generator - = - quickcheck_m - here - ~config:{ seed; test_count = trials; shrink_count = shrink_attempts; sizes } - ?cr - ?examples - ?hide_positions - (module struct - type t = a - - let sexp_of_t = sexp_of - let quickcheck_generator = quickcheck_generator - let quickcheck_shrinker = shrinker - end) - ~f -;; - -module Tuple2 (M : Quickcheck.Test.S) : Quickcheck.Test.S with type t = M.t * M.t = struct - type t = M.t * M.t [@@deriving sexp_of] - - let quickcheck_generator = [%quickcheck.generator: M.t * M.t] - let quickcheck_shrinker = [%quickcheck.shrinker: M.t * M.t] -end - -module Tuple3 (M : Quickcheck.Test.S) : Quickcheck.Test.S with type t = M.t * M.t * M.t = -struct - type t = M.t * M.t * M.t [@@deriving sexp_of] - - let quickcheck_generator = [%quickcheck.generator: M.t * M.t * M.t] - let quickcheck_shrinker = [%quickcheck.shrinker: M.t * M.t * M.t] -end - -let test_compare here ?config ?cr ?hide_positions (module M : With_quickcheck_and_compare) - = - let check bool msg = require here ?cr ?hide_positions bool ~if_false_then_print_s:msg in - let check_reflexive x = - let compare_x_x = M.compare x x in - check - (compare_x_x = 0) - [%lazy_message "[compare] is not reflexive" (x : M.t) (compare_x_x : int)] - in - let check_asymmetric x y = - let compare_x_y = M.compare x y in - let compare_y_x = M.compare y x in - check - (Sign.equal (Sign.of_int compare_x_y) (Sign.flip (Sign.of_int compare_y_x))) - [%lazy_message - "[compare] is not asymmetric" - (x : M.t) - (y : M.t) - (compare_x_y : int) - (compare_y_x : int)] - in - let check_transitive x y z = - let compare_x_y = M.compare x y in - let compare_y_z = M.compare y z in - let compare_x_z = M.compare x z in - let expected : Ordering.t option = - match Ordering.of_int compare_x_y, Ordering.of_int compare_y_z with - | Equal, Equal -> Some Equal - | Less, Less | Less, Equal | Equal, Less -> Some Less - | Greater, Greater | Greater, Equal | Equal, Greater -> Some Greater - | Less, Greater | Greater, Less -> None - in - Option.iter expected ~f:(fun expected -> - check - (Ordering.equal expected (Ordering.of_int compare_x_z)) - [%lazy_message - "[compare] is not transitive" - (x : M.t) - (y : M.t) - (z : M.t) - (compare_x_y : int) - (compare_y_z : int) - (compare_x_z : int)]) - in - let test m ~f = quickcheck_m here ?config ?cr ?hide_positions m ~f in - test - (module M) - ~f:(fun x -> - check_reflexive x; - check_asymmetric x x; - check_transitive x x x); - test - (module Tuple2 (M)) - ~f:(fun (x, y) -> - check_asymmetric x y; - check_transitive x x y; - check_transitive x y x; - check_transitive y x x); - test - (module Tuple3 (M)) - ~f:(fun (x, y, z) -> - check_transitive x y z; - check_transitive x z y; - check_transitive y x z) -;; - -let test_equal here ?config ?cr ?hide_positions (module M : With_quickcheck_and_equal) = - let check bool msg = require here ?cr ?hide_positions bool ~if_false_then_print_s:msg in - let check_reflexive x = - let equal_x_x = M.equal x x in - check - equal_x_x - [%lazy_message "[equal] is not reflexive" (x : M.t) (equal_x_x : bool)] - in - let check_symmetric x y = - let equal_x_y = M.equal x y in - let equal_y_x = M.equal y x in - check - (Bool.equal equal_x_y equal_y_x) - [%lazy_message - "[equal] is not symmetric" - (x : M.t) - (y : M.t) - (equal_x_y : bool) - (equal_y_x : bool)] - in - let check_transitive x y z = - let equal_x_y = M.equal x y in - let equal_y_z = M.equal y z in - let equal_x_z = M.equal x z in - let msg = - [%lazy_message - "[equal] is not transitive" - (x : M.t) - (y : M.t) - (z : M.t) - (equal_x_y : bool) - (equal_y_z : bool) - (equal_x_z : bool)] - in - match equal_x_y, equal_y_z with - | true, true -> check equal_x_z msg - | true, false | false, true -> check (not equal_x_z) msg - | false, false -> () - in - let test m ~f = quickcheck_m here ?config ?cr ?hide_positions m ~f in - test - (module M) - ~f:(fun x -> - check_reflexive x; - check_symmetric x x; - check_transitive x x x); - test - (module Tuple2 (M)) - ~f:(fun (x, y) -> - check_symmetric x y; - check_transitive x x y; - check_transitive x y x; - check_transitive y x x); - test - (module Tuple3 (M)) - ~f:(fun (x, y, z) -> - check_transitive x y z; - check_transitive x z y; - check_transitive y x z) -;; - -let test_compare_and_equal - here - ?config - ?cr - ?hide_positions - (module M : With_quickcheck_and_compare_and_equal) - = - test_compare here ?config ?cr ?hide_positions (module M); - test_equal here ?config ?cr ?hide_positions (module M); - let check_agreement x y = - let compare_x_y = M.compare x y in - let equal_x_y = M.equal x y in - require - here - ?cr - ?hide_positions - (Bool.equal equal_x_y (compare_x_y = 0)) - ~if_false_then_print_s: - [%lazy_message - "[compare] and [equal] do not agree" - (x : M.t) - (y : M.t) - (compare_x_y : int) - (equal_x_y : bool)] - in - quickcheck_m - here - ?config - ?cr - ?hide_positions - (module Tuple2 (M)) - ~f:(fun (x, y) -> - check_agreement x y; - check_agreement y x) -;; diff --git a/vendor/expect-test-helpers/src/expect_test_helpers_base.mli b/vendor/expect-test-helpers/src/expect_test_helpers_base.mli deleted file mode 100644 index 133816c..0000000 --- a/vendor/expect-test-helpers/src/expect_test_helpers_base.mli +++ /dev/null @@ -1 +0,0 @@ -include Expect_test_helpers_base_intf.Expect_test_helpers_base (** @inline *) diff --git a/vendor/expect-test-helpers/src/expect_test_helpers_base_intf.ml b/vendor/expect-test-helpers/src/expect_test_helpers_base_intf.ml deleted file mode 100644 index ca015db..0000000 --- a/vendor/expect-test-helpers/src/expect_test_helpers_base_intf.ml +++ /dev/null @@ -1,492 +0,0 @@ -module CR = struct - type t = - | CR - | CR_soon - | CR_someday - | Comment - | Suppress - [@@deriving sexp_of] -end - -module Sexp_style = struct - type t = - | To_string_mach - | To_string_hum - | Pretty of Sexp_pretty.Config.t - [@@deriving sexp_of] -end - -module type With_compare = sig - type t [@@deriving compare, sexp_of] -end - -module type With_equal = sig - type t [@@deriving equal, sexp_of] -end - -module type With_round_trip = sig - type t - type repr [@@deriving sexp_of] - - val to_repr : t -> repr - val of_repr : repr -> t - val repr_name : string -end - -module type With_sexpable = sig - type t [@@deriving equal, sexp] -end - -module type With_stringable = sig - type t [@@deriving equal] - - include Stringable.S with type t := t -end - -module type With_quickcheck_and_compare = sig - type t [@@deriving compare] - - include Base_quickcheck.Test.S with type t := t -end - -module type With_quickcheck_and_equal = sig - type t [@@deriving equal] - - include Base_quickcheck.Test.S with type t := t -end - -module type With_quickcheck_and_compare_and_equal = sig - type t [@@deriving compare, equal] - - include Base_quickcheck.Test.S with type t := t -end - -module Quickcheck = Base_quickcheck - -module type Expect_test_helpers_base = sig - (** Helpers for producing output inside [let%expect_test]. Designed for code using - [Base]. See also [Expect_test_helpers_core] and [Expect_test_helpers_async]. *) - - module type With_compare = With_compare - module type With_equal = With_equal - module type With_round_trip = With_round_trip - module type With_sexpable = With_sexpable - module type With_stringable = With_stringable - module type With_quickcheck_and_compare = With_quickcheck_and_compare - module type With_quickcheck_and_equal = With_quickcheck_and_equal - - module type With_quickcheck_and_compare_and_equal = - With_quickcheck_and_compare_and_equal - - module CR : sig - include module type of struct - include CR - end - - (** [hide_unstable_output t] returns [false] if [t = CR] and [true] otherwise. Useful - to provide a default for arguments such as [?hide_positions] in functions that - also have a [?cr] argument. *) - val hide_unstable_output : t -> bool - end - - module Phys_equal (M : sig - type t [@@deriving sexp_of] - end) : With_equal with type t = M.t - - module Sexp_style : sig - include module type of struct - include Sexp_style - end - - (** Pretty-printing via [Sexp_pretty] with default config, except no colors. *) - val default_pretty : t - - (** Pretty-printing via [Sexp_pretty] with most heuristics disabled. *) - val simple_pretty : t - end - - (** [hide_positions_in_string] does line-based regexp matching to replace line numbers - and column numbers that appear in source-code positions with constant text [LINE] - and [COL]. This can be useful in making displayed test output less fragile. *) - val hide_positions_in_string : string -> string - - (** [hide_temp_files_in_string] replaces [.tmp.______], where each [_] represents some - alphanumeric character, with ".tmp.RANDOM". This can make output deterministic when - describing temporary files generated by, e.g., [Core_unix.mkstemp]. *) - val hide_temp_files_in_string : string -> string - - (** Renders an s-expression as a string. With [~hide_positions:true], patterns in the - string that match OCaml-style file positions are modified to hide the line number, - column number, and character positions, to make output less fragile. *) - val sexp_to_string : ?hide_positions:bool (** default is [false] *) -> Sexp.t -> string - - (** Substitutes [with_] for every occurrence of [pattern] in a string. *) - val replace : string -> pattern:string -> with_:string -> string - - (** Like [replace], for every atom in a sexp. *) - val replace_s : Sexp.t -> pattern:string -> with_:string -> Sexp.t - - (** Applies [f] at every node in the given sexp, top-down, recurring on the contents of - the output. The word "smash" is used as in the sexp command-line tool's query - language. See: https://github.com/janestreet/sexp *) - val smash_sexp : Sexp.t -> f:(Sexp.t -> Sexp.t) -> Sexp.t - - (** Removes OCaml backtraces from sexps. *) - val remove_backtraces : Sexp.t -> Sexp.t - - (** For printing an s-expression to stdout. [hide_positions] works as in - [sexp_to_string]. *) - val print_s : ?hide_positions:bool (** default is [false] *) -> Sexp.t -> unit - - val print_string : ?hide_positions:bool (** default is [false] *) -> string -> unit - val print_endline : ?hide_positions:bool (** default is [false] *) -> string -> unit - - (** Behaves like [[%expect.output]]. *) - val expect_test_output : Source_code_position.t -> string - - (** Returns [true] if running inside the body of [let%expect_test], or [false] - otherwise. Use to test whether [expect_test_output] will raise, for example. Unlike - [Core.am_running_test], this is not configured by an environment variable, and is - not inherited by child processes. *) - val am_running_expect_test : unit -> bool - - (** If [am_running_expect_test () = false], raises with an explanatory error message. Do - not use [require am_running_expect_test], as outside of an expect test that may not - accomplish anything. *) - val assert_am_running_expect_test : Source_code_position.t -> unit - - (** [print_cr here message] prints a [CR require-failed], which will appear in - expect-test output. The CR will appear in the feature owner's [fe todo], thus - preventing release of the feature. [print_cr] is an expect-test-friendly version of - [assert false]. It works with the normal expect-test workflow because it does not - raise, and it prevents mistakenly releasing features that violate a required - property. There is no need to 'X' a [CR require-failed]; simply fix the property - that triggered the [print_cr] and re-run the test to restore the empty output. *) - val print_cr - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> Source_code_position.t - -> Sexp.t - -> unit - - (** [require here bool] is a no-op if [bool = true], but if not, prints a [CR - require-failed] similarly to [print_cr], with a message determined by the - [if_false_then_print_s] argument, if any. - - [if_false_then_print_s] is useful for including information that may help debug the - problem, but that would otherwise be too voluminous. [if_false_then_print_s] is - lazy to avoid construction of the sexp except when needed. *) - val require - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?if_false_then_print_s:Sexp.t Lazy.t - -> Source_code_position.t - -> bool - -> unit - - (** [require_equal] compares its two arguments using the equality predicate of the - provided module. If the comparison fails, prints a message that renders the - arguments as sexps. *) - val require_equal - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?if_false_then_print_s:Sexp.t Lazy.t - -> ?message:string - -> Source_code_position.t - -> (module With_equal with type t = 'a) - -> 'a - -> 'a - -> unit - - (** Like [require_equal], but derives an equality predicate from a comparison - function. *) - val require_compare_equal - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?message:string - -> Source_code_position.t - -> (module With_compare with type t = 'a) - -> 'a - -> 'a - -> unit - - (** Like [require_equal] but instead requires that the arguments are *not* equal. *) - val require_not_equal - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?if_false_then_print_s:Sexp.t Lazy.t - -> ?message:string - -> Source_code_position.t - -> (module With_equal with type t = 'a) - -> 'a - -> 'a - -> unit - - (** Like [require_not_equal], but derives an equality predicate from a comparison - function. *) - val require_compare_not_equal - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?message:string - -> Source_code_position.t - -> (module With_compare with type t = 'a) - -> 'a - -> 'a - -> unit - - (** Like [require_equal], but when equality fails produces a message including sexps of - both [Set.diff first second] and [Set.diff second first] to aid in debugging. *) - val require_sets_are_equal - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?names:string * string (** default is ["first", "second"] *) - -> Source_code_position.t - -> ('elt, 'cmp) Set.t - -> ('elt, 'cmp) Set.t - -> unit - - (** [show_raise] calls [f ()] and prints the exception that it raises, or, if it doesn't - raise, prints [did not raise]. [show_raise] ignores the result of [f] so that one - doesn't have to put an [ignore] inside the body of an [f] that is expected to raise. - [~hide_positions:true] operates as in [print_s], to make output less fragile. Using - [~show_backtrace:true] will result in a CR in the expectation, but it's still - available here as it is still valuable when initially writing tests and - debugging. *) - val show_raise - : ?hide_positions:bool (** default is [false] *) - -> ?show_backtrace:bool (** default is [false] *) - -> (unit -> _) - -> unit - - (** [require_does_not_raise] is like [show_raise], but does not print anything if the - function does not raise, and prints a CR along with the exception if it does raise. - Unlike for [show_raise], the supplied function is required to return [unit] to avoid - mistakes like incomplete partial application that silently would not raise, but for - the wrong reason. *) - val require_does_not_raise - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?show_backtrace:bool (** default is [false] *) - -> Source_code_position.t - -> (unit -> unit) - -> unit - - (** [require_does_raise] is like [show_raise], but additionally prints a CR if the - function does not raise. *) - val require_does_raise - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] *) - -> ?show_backtrace:bool (** default is [false] *) - -> Source_code_position.t - -> (unit -> _) - -> unit - - (** [require_some here option] is like [require here (is_some option)], with improved - output. If [option = None], it prints a CR. If [option = Some some] and - [~print_some] is provided, it prints [print_some some]. *) - val require_some - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?print_some:('some -> Sexp.t) - -> Source_code_position.t - -> 'some option - -> unit - - (** [require_none here sexp_of_some option] is like [require here (is_none option)], - with improved output. If [option = Some some], it prints a CR including - [sexp_of_some some]. If [option = None], it does not print. *) - val require_none - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> Source_code_position.t - -> ('some -> Sexp.t) - -> 'some option - -> unit - - (** [require_ok here or_error] is like [require here (is_ok or_error)], with improved - output. If [or_error = Error error], it prints a CR including [error]. If - [or_error = Ok ok] and [~print_ok] is provided, it prints [print_ok ok]. *) - val require_ok - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?print_ok:('ok -> Sexp.t) - -> Source_code_position.t - -> 'ok Or_error.t - -> unit - - (** [require_error here sexp_of_ok or_error] is like [require here (is_error or_error)], - with improved output. If [or_error = Ok ok], it prints a CR including [sexp_of_ok - ok]. If [or_error = Error error] and [print_error = true], it prints [error]. *) - val require_error - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?print_error:bool (** default is [false] *) - -> Source_code_position.t - -> ('ok -> Sexp.t) - -> 'ok Or_error.t - -> unit - - (** [require_ok_result here sexp_of_error result] is like [require here (is_ok - or_error)], with improved output. If [result = Error error], it prints a CR - including [sexp_of_error error]. If [result = Ok ok] and [~print_ok] is provided, - it prints [print_ok ok]. *) - val require_ok_result - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?print_ok:('ok -> Sexp.t) - -> Source_code_position.t - -> ('error -> Sexp.t) - -> ('ok, 'error) Result.t - -> unit - - (** [require_error_result here sexp_of_ok result] is like [require here (is_error - result)], with improved output. If [result = Ok ok], it prints a CR including - [sexp_of_ok ok]. If [result = Error error] and [~print_error] is supplied, it - prints [print_error error]. *) - val require_error_result - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?print_error:('error -> Sexp.t) - -> Source_code_position.t - -> ('ok -> Sexp.t) - -> ('ok, 'error) Result.t - -> unit - - (** [require_first here print_second either] is like [require here (is_first either)], - with improved output. If [either = Second second], it prints a CR including - [sexp_of_second second]. If [either = First first] and [~print_first] is provided, - it prints [print_first first]. *) - val require_first - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true otherwise] *) - -> ?print_first:('first -> Sexp.t) - -> Source_code_position.t - -> ('second -> Sexp.t) - -> ('first, 'second) Either.t - -> unit - - (** [require_second here sexp_of_first either] is like [require here (is_second - either)], with improved output. If [either = First first], it prints a CR including - [sexp_of_first first]. If [either = Second second] and [~print_second] is provided, - it prints [print_second second]. *) - val require_second - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true otherwise] *) - -> ?print_second:('second -> Sexp.t) - -> Source_code_position.t - -> ('first -> Sexp.t) - -> ('first, 'second) Either.t - -> unit - - (** Print string representations of the given values, and test that [to_string] / - [of_string] round-trip. *) - val print_and_check_stringable - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true otherwise] *) - -> Source_code_position.t - -> (module With_stringable with type t = 'a) - -> 'a list - -> unit - - (** Print sexp representations of the given values, and test that [sexp_of_t] / - [t_of_sexp] round-trip. *) - val print_and_check_sexpable - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true otherwise] *) - -> Source_code_position.t - -> (module With_sexpable with type t = 'a) - -> 'a list - -> unit - - (** Print the [With_round_trip] representations of the given values. If there are - multiple representations, includes the [repr_name] of each in the output. Tests that - [to_repr] and [of_repr] round-trip for each representation. *) - val print_and_check_round_trip - : ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true otherwise] *) - -> Source_code_position.t - -> (module With_equal with type t = 'a) - -> (module With_round_trip with type t = 'a) list - -> 'a list - -> unit - - (** [quickcheck] is similar to [Base_quickcheck.Test.run], but - - 1. [quickcheck] takes separate arguments for the values which - [Base_quickcheck.Test.run] takes in a first-class module. - - 2. [quickcheck] stops after the first iteration that raises or prints a CR, as - detected by [on_print_cr]. *) - val quickcheck - : Source_code_position.t - -> ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> ?seed:Quickcheck.Test.Config.Seed.t - -> ?sizes:int Sequence.t - -> ?trials:int - -> ?shrinker:'a Quickcheck.Shrinker.t - -> ?shrink_attempts:int - -> ?examples:'a list - -> sexp_of:('a -> Sexp.t) - -> f:('a -> unit) - -> 'a Quickcheck.Generator.t - -> unit - - (** [quickcheck_m] is similar to [Base_quickcheck.Test.run]. It stops after the first - iteration that raises or prints a CR, as detected by [on_print_cr]. *) - val quickcheck_m - : Source_code_position.t - -> ?config:Base_quickcheck.Test.Config.t - (** default is [Base_quickcheck.Test.default_config] *) - -> ?cr:CR.t (** default is [CR] *) - -> ?examples:'a list - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> (module Base_quickcheck.Test.S with type t = 'a) - -> f:('a -> unit) - -> unit - - (** [test_compare] uses quickcheck to test that a compare function is reflexive, - asymmetric, and transitive. *) - val test_compare - : Source_code_position.t - -> ?config:Base_quickcheck.Test.Config.t - (** default is [Base_quickcheck.Test.default_config] *) - -> ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> (module With_quickcheck_and_compare) - -> unit - - (** [test_equal] uses quickcheck to test that an equal function is reflexive, symmetric, - and transitive. *) - val test_equal - : Source_code_position.t - -> ?config:Base_quickcheck.Test.Config.t - (** default is [Base_quickcheck.Test.default_config] *) - -> ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> (module With_quickcheck_and_equal) - -> unit - - (** [test_compare_and_equal] uses quickcheck to test that compare and equal functions - satisfy [test_compare] and [test_equal], and that their results are consistent with - each other. *) - val test_compare_and_equal - : Source_code_position.t - -> ?config:Base_quickcheck.Test.Config.t - (** default is [Base_quickcheck.Test.default_config] *) - -> ?cr:CR.t (** default is [CR] *) - -> ?hide_positions:bool (** default is [false] when [cr=CR], [true] otherwise *) - -> (module With_quickcheck_and_compare_and_equal) - -> unit - - (** [sexp_style] determines the sexp format used by [sexp_to_string], [print_s], and - other functions in this module. Defaults to [Sexp_style.default_pretty]. *) - val sexp_style : Sexp_style.t ref - - (** [on_print_cr] determines the behavior of all functions above that print CRs, such as - [print_cr] and [require]. The rendered string form of the CR is passed to - [!on_print_cr]. The default value is [print_endline]; this can be overridden to - replace or extend the default behavior. For example, some testing harnesses may - choose to abort a series of tests after the first CR is printed. *) - val on_print_cr : (string -> unit) ref -end diff --git a/vendor/update-expect-test-helpers.sh b/vendor/update-expect-test-helpers.sh deleted file mode 100755 index 697e315..0000000 --- a/vendor/update-expect-test-helpers.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash - -version=0ddba5a635b1b6589d41ae10bdf34159f88eae7d - -set -e -o pipefail - -TMP="$(mktemp -d)" -trap "rm -rf $TMP" EXIT - -rm -rf expect-test-helpers -mkdir -p expect-test-helpers/src - -( - cd $TMP - git clone https://github.com/mbarbin/expect-test-helpers.git - cd expect-test-helpers - git checkout $version -) - -SRC=$TMP/expect-test-helpers - -cp -v $SRC/LICENSE{,.janestreet} expect-test-helpers/ -cp -v -R $SRC/src expect-test-helpers/ - -git checkout expect-test-helpers/src/dune -git add -A . From a15cfd762db19c87e9d40d0065dbd74f01fe0194 Mon Sep 17 00:00:00 2001 From: Mathieu Barbin Date: Fri, 23 Aug 2024 22:01:48 +0200 Subject: [PATCH 3/3] Update changelog --- CHANGES.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 4709846..d921bdc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,20 @@ +## 0.0.6 (unreleased) + +### Added + +### Changed + +- Now using `expect_test_helpers_base`. +- Upgrade to `err0` and more recent `commandlang`. + +### Deprecated + +### Fixed + +### Removed + +- Removed vendored `expect-test-helpers`. + ## 0.0.5 (2024-08-19) ### Changed