From 77b6a5c5ef75344479d9076553694a691c843e8d Mon Sep 17 00:00:00 2001 From: Jerry James Date: Sep 20 2022 17:33:29 +0000 Subject: Add patch to adapt tests to cmdliner 1.1.0. --- diff --git a/ocaml-mdx-cmdliner.patch b/ocaml-mdx-cmdliner.patch new file mode 100644 index 0000000..d40d4ae --- /dev/null +++ b/ocaml-mdx-cmdliner.patch @@ -0,0 +1,258 @@ +--- mdx-2.1.0/bin/cli.ml.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/cli.ml 2022-09-15 15:55:07.018063580 -0600 +@@ -5,7 +5,7 @@ let named wrapper = Term.(app (const wra + + let non_deterministic = + let doc = "Run non-deterministic tests." in +- let env = Arg.env_var ~doc "MDX_RUN_NON_DETERMINISTIC" in ++ let env = Cmd.Env.info ~doc "MDX_RUN_NON_DETERMINISTIC" in + named + (fun x -> `Non_deterministic x) + Arg.(value & flag & info [ "non-deterministic"; "n" ] ~env ~doc) +--- mdx-2.1.0/bin/deps.ml.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/deps.ml 2022-09-15 15:55:48.578172860 -0600 +@@ -33,10 +33,11 @@ let run (`Setup ()) (`Syntax syntax) (`F + Printf.printf "%s" (Mdx.Util.Csexp.to_string (List deps)); + 0 + +-let cmd = +- let open Cmdliner in +- let doc = +- "List the dependencies of the input file. This command is meant to be used \ +- by dune only. There are no stability guarantees." +- in +- (Term.(pure run $ Cli.setup $ Cli.syntax $ Cli.file), Term.info "deps" ~doc) ++let term = Cmdliner.Term.(const run $ Cli.setup $ Cli.syntax $ Cli.file) ++ ++let doc = ++ "List the dependencies of the input file. This command is meant to be used \ ++ by dune only. There are no stability guarantees." ++ ++let info = Cmdliner.Cmd.info "deps" ~doc ++let cmd = Cmdliner.Cmd.v info term +--- mdx-2.1.0/bin/deps.mli.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/deps.mli 2022-09-15 15:56:11.034231908 -0600 +@@ -14,6 +14,4 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +-open Cmdliner +- +-val cmd : int Term.t * Term.info ++val cmd : int Cmdliner.Cmd.t +--- mdx-2.1.0/bin/dune_gen.ml.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/dune_gen.ml 2022-09-15 15:56:39.290306213 -0600 +@@ -56,11 +56,11 @@ let run (`Setup ()) (`Prelude prelude) ( + Buffer.output_buffer stdout buffer; + 0 + +-let cmd = +- let open Cmdliner in +- let doc = +- "Generate the source for a specialized testing binary. This command is \ +- meant to be used by dune only. There are no stability guarantees." +- in +- ( Term.(pure run $ Cli.setup $ Cli.prelude $ Cli.directories), +- Term.info "dune-gen" ~doc ) ++let term = Cmdliner.Term.(const run $ Cli.setup $ Cli.prelude $ Cli.directories) ++ ++let doc = ++ "Generate the source for a specialized testing binary. This command is meant \ ++ to be used by dune only. There are no stability guarantees." ++ ++let info = Cmdliner.Cmd.info "dune-gen" ~doc ++let cmd = Cmdliner.Cmd.v info term +--- mdx-2.1.0/bin/dune_gen.mli.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/dune_gen.mli 2022-09-15 15:57:00.658362404 -0600 +@@ -14,6 +14,4 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +-open Cmdliner +- +-val cmd : int Term.t * Term.info ++val cmd : int Cmdliner.Cmd.t +--- mdx-2.1.0/bin/main.ml.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/main.ml 2022-09-15 16:05:36.283718254 -0600 +@@ -19,11 +19,11 @@ open Cmdliner + let cmds = [ Test.cmd; Pp.cmd; Deps.cmd; Dune_gen.cmd ] + let main (`Setup ()) = `Help (`Pager, None) + +-let main = ++let info = + let doc = "Execute markdown files." in +- let exits = Term.default_exits in + let man = [] in +- ( Term.(ret (const main $ Cli.setup)), +- Term.info "ocaml-mdx" ~version:"2.1.0" ~doc ~exits ~man ) ++ Cmd.info "ocaml-mdx" ~version:"%%VERSION%%" ~doc ~man + +-let () = Term.(exit_status @@ eval_choice main cmds) ++let default = Term.(ret (const main $ Cli.setup)) ++let group = Cmd.group ~default info cmds ++let () = Stdlib.exit @@ Cmd.eval' group +--- mdx-2.1.0/bin/pp.ml.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/pp.ml 2022-09-15 15:58:24.650583246 -0600 +@@ -62,8 +62,7 @@ let run (`Setup ()) (`File file) (`Secti + + open Cmdliner + +-let cmd = +- let doc = "Pre-process markdown files to produce OCaml code." in +- let exits = Term.default_exits in +- ( Term.(pure run $ Cli.setup $ Cli.file $ Cli.section), +- Term.info "pp" ~doc ~exits ) ++let term = Term.(const run $ Cli.setup $ Cli.file $ Cli.section) ++let doc = "Pre-process markdown files to produce OCaml code." ++let info = Cmd.info "pp" ~doc ++let cmd = Cmd.v info term +--- mdx-2.1.0/bin/pp.mli.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/pp.mli 2022-09-15 15:58:49.602648845 -0600 +@@ -14,6 +14,4 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +-open Cmdliner +- +-val cmd : int Term.t * Term.info ++val cmd : int Cmdliner.Cmd.t +--- mdx-2.1.0/bin/test/main.ml.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/test/main.ml 2022-09-15 16:01:07.227010752 -0600 +@@ -73,16 +73,18 @@ let run setup non_deterministic silent_e + + open Cmdliner + +-let cmd = +- let exits = Term.default_exits in ++let term = ++ Term.( ++ const run $ Cli.setup $ Cli.non_deterministic $ Cli.silent_eval ++ $ Cli.record_backtrace $ Cli.syntax $ Cli.silent $ Cli.verbose_findlib ++ $ Cli.prelude $ Cli.prelude_str $ Cli.file $ Cli.section $ Cli.root ++ $ Cli.force_output $ Cli.output) ++ ++let info = + let man = [] in + let doc = "Test markdown files." in +- ( Term.( +- pure run $ Cli.setup $ Cli.non_deterministic $ Cli.silent_eval +- $ Cli.record_backtrace $ Cli.syntax $ Cli.silent $ Cli.verbose_findlib +- $ Cli.prelude $ Cli.prelude_str $ Cli.file $ Cli.section $ Cli.root +- $ Cli.force_output $ Cli.output), +- Term.info "ocaml-mdx-test" ~version:"2.1.0" ~doc ~exits ~man ) ++ Cmd.info "ocaml-mdx-test" ~version:"%%VERSION%%" ~doc ~man + +-let main () = Term.(exit_status @@ eval cmd) ++let cmd = Cmd.v info term ++let main () = Stdlib.exit @@ Cmd.eval' cmd + let () = main () +--- mdx-2.1.0/bin/test.ml.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/test.ml 2022-09-15 15:59:33.185763445 -0600 +@@ -47,11 +47,12 @@ let run (`Setup ()) _ _ _ _ _ _ _ _ _ _ + + open Cmdliner + +-let cmd : int Term.t * Term.info = +- let doc = "Test markdown files." in +- ( Term.( +- pure run $ Cli.setup $ Cli.non_deterministic $ Cli.silent_eval +- $ Cli.syntax $ Cli.silent $ Cli.verbose_findlib $ Cli.prelude +- $ Cli.prelude_str $ Cli.file $ Cli.section $ Cli.root $ Cli.force_output +- $ Cli.output), +- Term.info "test" ~doc ) ++let term = ++ Term.( ++ const run $ Cli.setup $ Cli.non_deterministic $ Cli.silent_eval $ Cli.syntax ++ $ Cli.silent $ Cli.verbose_findlib $ Cli.prelude $ Cli.prelude_str ++ $ Cli.file $ Cli.section $ Cli.root $ Cli.force_output $ Cli.output) ++ ++let doc = "Test markdown files." ++let info = Cmd.info "test" ~doc ++let cmd = Cmd.v info term +--- mdx-2.1.0/bin/test.mli.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/bin/test.mli 2022-09-15 15:59:52.369813894 -0600 +@@ -14,6 +14,4 @@ + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + *) + +-open Cmdliner +- +-val cmd : int Term.t * Term.info ++val cmd : int Cmdliner.Cmd.t +--- mdx-2.1.0/dune-project.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/dune-project 2022-09-15 16:01:29.339068903 -0600 +@@ -30,7 +30,7 @@ + astring + (logs (>= 0.7.0)) + (cmdliner +- (>= 1.0.0)) ++ (>= 1.1.0)) + (re + (>= 1.7.2)) + result +--- mdx-2.1.0/mdx.opam.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/mdx.opam 2022-09-15 16:01:49.291121378 -0600 +@@ -27,7 +27,7 @@ depends: [ + "csexp" {>= "1.3.2"} + "astring" + "logs" {>= "0.7.0"} +- "cmdliner" {>= "1.0.0"} ++ "cmdliner" {>= "1.1.0"} + "re" {>= "1.7.2"} + "result" + "ocaml-version" {>= "2.3.0"} +@@ -50,4 +50,4 @@ build: [ + "@doc" {with-doc} + ] + ] +-dev-repo: "git+https://github.com/realworldocaml/mdx.git" +\ No newline at end of file ++dev-repo: "git+https://github.com/realworldocaml/mdx.git" +--- mdx-2.1.0/test/bin/gen_rule_helpers/gen_rule_helpers.ml.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/test/bin/gen_rule_helpers/gen_rule_helpers.ml 2022-09-15 16:06:04.275791867 -0600 +@@ -144,16 +144,19 @@ let run generator = + let cmds = + Term. + [ +- (const (rule_gen generator `Test_expect) $ const (), info "test_expect"); +- ( const (rule_gen generator `Test_failure) $ const (), +- info "test_failure" ); ++ (let term = const (rule_gen generator `Test_expect) $ const () in ++ let info = Cmd.info "test_expect" in ++ Cmd.v info term); ++ (let term = const (rule_gen generator `Test_failure) $ const () in ++ let info = Cmd.info "test_failure" in ++ Cmd.v info term); + ] + in +- let default = ++ let info = + let doc = "Generate dune files for the binary tests." in +- let exits = Term.default_exits in + let man = [] in +- Term. +- (ret (const (`Help (`Auto, None))), info "gen_dune_rules" ~doc ~exits ~man) ++ Cmd.info "gen_dune_rules" ~doc ~man + in +- Term.exit (Term.eval_choice default cmds) ++ let default = Term.(ret (const (`Help (`Auto, None)))) in ++ let group = Cmd.group ~default info cmds in ++ Stdlib.exit @@ Cmd.eval group +--- mdx-2.1.0/test/bin/mdx-test/misc/no-such-file/test.expected.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/test/bin/mdx-test/misc/no-such-file/test.expected 2022-02-10 21:19:58.145280205 -0700 +@@ -1,3 +1,3 @@ +-ocaml-mdx: FILE argument: no `foo' file +-Usage: ocaml-mdx test [OPTION]... FILE +-Try `ocaml-mdx test --help' or `ocaml-mdx --help' for more information. ++ocaml-mdx: FILE argument: no 'foo' file ++Usage: ocaml-mdx test [OPTION]… FILE ++Try 'ocaml-mdx test --help' or 'ocaml-mdx --help' for more information. +--- mdx-2.1.0/test/bin/mdx-test/misc/no-such-prelude/test.expected.orig 2022-01-28 04:32:36.000000000 -0700 ++++ mdx-2.1.0/test/bin/mdx-test/misc/no-such-prelude/test.expected 2022-02-10 21:20:38.128323836 -0700 +@@ -1,3 +1,3 @@ +-ocaml-mdx: option `--prelude': no `foo' file +-Usage: ocaml-mdx test [OPTION]... FILE +-Try `ocaml-mdx test --help' or `ocaml-mdx --help' for more information. ++ocaml-mdx: option '--prelude': no 'foo' file ++Usage: ocaml-mdx test [OPTION]… FILE ++Try 'ocaml-mdx test --help' or 'ocaml-mdx --help' for more information. diff --git a/ocaml-mdx.spec b/ocaml-mdx.spec index e1616bd..e0fbf7d 100644 --- a/ocaml-mdx.spec +++ b/ocaml-mdx.spec @@ -6,17 +6,22 @@ Name: ocaml-mdx Version: 2.1.0 -Release: 6%{?dist} +Release: 7%{?dist} Summary: Executable code blocks inside markdown files License: ISC URL: https://realworldocaml.github.io/mdx/ Source0: https://github.com/realworldocaml/mdx/releases/download/%{version}/mdx-%{version}.tbz +# Update to cmdliner 1.1.0. See: +# https://github.com/realworldocaml/mdx/commit/18481d8a48204b95ce66c0ce88cec416530fc6f5 +# https://github.com/realworldocaml/mdx/commit/85654df98e3a1f5821a22f12836555b47ea2ed93 +# https://github.com/realworldocaml/mdx/commit/b714cb6a9357d119185753bc59108e169d8bf246 +Patch0: %{name}-cmdliner.patch BuildRequires: ocaml >= 4.08.0 BuildRequires: ocaml-alcotest-devel BuildRequires: ocaml-astring-devel -BuildRequires: ocaml-cmdliner-devel >= 1.0.0 +BuildRequires: ocaml-cmdliner-devel >= 1.1.0 BuildRequires: ocaml-cppo >= 1.1.0 BuildRequires: ocaml-csexp-devel >= 1.3.2 BuildRequires: ocaml-dune >= 2.7 @@ -65,6 +70,9 @@ files for developing applications that use %{name}. %prep %autosetup -n mdx-%{version} -p1 +# Adapt to grep 3.8 +sed -i 's/egrep/grep -E/' test/bin/mdx-test/expect/padding/test-case.md + %build %dune_build @@ -81,6 +89,9 @@ files for developing applications that use %{name}. %files devel -f .ofiles-devel %changelog +* Tue Sep 20 2022 Jerry James - 2.1.0-7 +- Add patch to adapt tests to cmdliner 1.1.0 + * Tue Aug 2 2022 Jerry James - 2.1.0-6 - Rebuild for ocaml-odoc-parser 2.0.0